13#include <gtest/gtest.h>
41 return static_cast<long long>(
_getpid());
43 return static_cast<long long>(
getpid());
49 const auto *
test_info = ::testing::UnitTest::GetInstance()->current_test_info();
50 std::string base = std::string(
"alephw_") +
test_info->test_suite_name() +
"_" +
54 if (
ch ==
'/' ||
ch ==
'\\' ||
ch ==
' ')
57 auto dir = std::filesystem::temp_directory_path();
105 auto arc = it.get_curr();
116 params.ensure_connected =
true;
196 std::vector<size_t>
layers = {1, 5, 10, 5, 1};
205 std::vector<size_t>
layers = {1, 3, 3, 1};
224 std::ifstream
file(dot_file);
227 std::string
content((std::istreambuf_iterator<char>(
file)),
228 std::istreambuf_iterator<char>());
242 options.highlight_saturated =
true;
246 std::ifstream
file(dot_file);
271 std::ifstream
file(json_file);
274 std::string
content((std::istreambuf_iterator<char>(
file)),
275 std::istreambuf_iterator<char>());
304 std::ifstream
file(dimacs_file);
307 std::string
content((std::istreambuf_iterator<char>(
file)),
308 std::istreambuf_iterator<char>());
361 EXPECT_EQ(result.algorithm_name,
"Dinic");
366 std::vector<MaxFlowBenchmarkResult<double>>
results;
368 results.push_back({100.0, 1.5,
"Algorithm A"});
369 results.push_back({100.0, 2.3,
"Algorithm B"});
372 testing::internal::CaptureStdout();
374 std::string
output = testing::internal::GetCapturedStdout();
413 ::testing::InitGoogleTest(&
argc,
argv);
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
std::filesystem::path json_file
static long long process_id() noexcept
std::filesystem::path dot_file
std::filesystem::path dimacs_file
Main namespace for Aleph-w library functions.
void export_network_to_dimacs(const Net &net, const std::string &filename)
Export network to DIMACS max-flow format.
void export_network_to_dot(const Net &net, const std::string &filename, const DotExportOptions &options=DotExportOptions())
Export network to DOT format for GraphViz visualization.
Net::Flow_Type dinic_maximum_flow(Net &net)
Compute maximum flow using Dinic's algorithm.
void export_network_to_json(const Net &net, const std::string &filename)
Export network to JSON format.
std::string network_to_json_string(const Net &net)
Export network to JSON string.
MaxFlowBenchmarkResult< typename Net::Flow_Type > benchmark_maxflow(Net &net, Algo algo, const std::string &name)
Run and time a max-flow algorithm.
void print_benchmark_results(const std::vector< MaxFlowBenchmarkResult< Flow_Type > > &results)
Print benchmark results.
std::string network_to_dot_string(const Net &net, const DotExportOptions &options=DotExportOptions())
Generate DOT string for network (instead of file).
DynList< T > maps(const C &c, Op op)
Classic map operation.
Network flow utilities: generators, visualization, serialization.
TEST_F(NetUtilsTest, GenerateRandomNetworkBasic)
static struct argp_option options[]
Filtered iterator on all the arcs of a graph.
bool show_flow
Show flow values on arcs.
Arc of a flow network implemented with adjacency lists.
Flow network implemented with adjacency lists.
Parameters for random network generation.
Advanced maximum flow algorithms.