Sorry, the other half of the move comes here.
2 #include <hugo/list_graph.h>
3 #include <hugo/minlengthpaths.h>
13 void check(bool rc, char *msg="") {
14 passed = passed && rc;
16 std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
27 typedef ListGraph::Node Node;
28 typedef ListGraph::Edge Edge;
34 Node s=graph.addNode();
35 Node v1=graph.addNode();
36 Node v2=graph.addNode();
37 Node v3=graph.addNode();
38 Node v4=graph.addNode();
39 Node v5=graph.addNode();
40 Node t=graph.addNode();
42 Edge s_v1=graph.addEdge(s, v1);
43 Edge v1_v2=graph.addEdge(v1, v2);
44 Edge s_v3=graph.addEdge(s, v3);
45 Edge v2_v4=graph.addEdge(v2, v4);
46 Edge v2_v5=graph.addEdge(v2, v5);
47 Edge v3_v5=graph.addEdge(v3, v5);
48 Edge v4_t=graph.addEdge(v4, t);
49 Edge v5_t=graph.addEdge(v5, t);
52 ListGraph::EdgeMap<int> length(graph);
63 std::cout << "Minlengthpaths algorithm test..." << std::endl;
67 MinLengthPaths< ListGraph, ListGraph::EdgeMap<int> >
68 surb_test(graph, length);
70 check( surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46,"Two paths, total length should be 46");
72 check( surb_test.checkComplementarySlackness(), "Complementary slackness conditions are not met.");
74 typedef DirPath<ListGraph> DPath;
78 surb_test.getPath(P,0);
79 check(P.length() == 4, "First path should contain 4 edges.");
80 cout<<P.length()<<endl;
81 surb_test.getPath(P,1);
82 check(P.length() == 3, "Second path: 3 edges.");
83 cout<<P.length()<<endl;
87 check( surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
89 check( surb_test.checkComplementarySlackness(), "Complementary slackness conditions are not met.");
91 surb_test.getPath(P,0);
92 check(P.length() == 4, "First path should contain 4 edges.");
94 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
97 return passed ? 0 : 1;