diff -r 3c30bd0f9ccc -r 7768d68909e8 tests/circulation.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/circulation.cc Sun Dec 11 06:55:47 2011 +0100 @@ -0,0 +1,67 @@ +#include +#include +#include +#include +#include +#include + +const char test_name[] = "circulation"; + +using namespace lemon; + +int main(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; + } + std::cerr << "Read the file: " << ti << '\n'; + ti.restart(); + + Circulation,SmartDigraph::ArcMap, + SmartDigraph::NodeMap > circ(g,lo_cap,up_cap,sup); + std::cerr << "Setup Circulation class: " << ti << '\n'; + ti.restart(); + bool res = circ.run(); + if(res) + { + std::cerr << "A feasible circulation is found: " << ti << "\n"; + ti.restart(); + bool res2 = circ.checkFlow(); + std::cerr << "Checked in time " << ti << "\n"; + if(res2) + std::cerr << "Success!\nn"; + else + std::cerr << "Oops!!!!\n\n"; + } + else + { + std::cerr << "A dual solution is found: " << ti << "\n"; + ti.restart(); + bool res2 = circ.checkBarrier(); + std::cerr << "Checked in time " << ti << "\n"; + if(res2) + std::cerr << "Success!\nn"; + else + std::cerr << "Dual-Oops!!!!\n\n"; + + } +} +