#include #include #include #include #include #include const char test_name[] = "circulation"; using namespace lemon; int testMain(int argc, char **argv) { if(argc!=2) exit(1); typedef int Value; SmartDigraph g; SmartDigraph::ArcMap lo_cap(g); SmartDigraph::ArcMap up_cap(g); SmartDigraph::ArcMap cost(g); SmartDigraph::NodeMap sup(g); Timer ti; try { std::ifstream input; input.open(argv[1]); readDimacsMin(input, g, lo_cap, up_cap, cost, sup); } catch (FormatError& error) { std::cerr << error.what() << std::endl; return 1; } logTime("file-read",ti); Timer tf; ti.restart(); Circulation,SmartDigraph::ArcMap, SmartDigraph::NodeMap > circ(g,lo_cap,up_cap,sup); logTime("setup",ti); ti.restart(); bool res = circ.run(); logTime("alg",ti); logTime("full",tf); if(res) { std::cerr << "A feasible circulation is found\n"; std::cerr << "Checking...\n"; ti.restart(); bool res2 = circ.checkFlow(); logTime("check",ti); if(res2) std::cerr << "Success!\n"; else std::cerr << "Oops!!!!\n"; } else { std::cerr << "A dual solution is found\n"; std::cerr << "Checking...\n"; ti.restart(); bool res2 = circ.checkBarrier(); logTime("check",ti); if(res2) std::cerr << "Success!\n"; else std::cerr << "Dual-Oops!!!!\n"; } }