.
2 #include <hugo/list_graph.h>
3 #include <hugo/minlengthpaths.h>
5 #include "test_tools.h"
18 typedef ListGraph::Node Node;
19 typedef ListGraph::Edge Edge;
25 Node s=graph.addNode();
26 Node v1=graph.addNode();
27 Node v2=graph.addNode();
28 Node v3=graph.addNode();
29 Node v4=graph.addNode();
30 Node v5=graph.addNode();
31 Node t=graph.addNode();
33 Edge s_v1=graph.addEdge(s, v1);
34 Edge v1_v2=graph.addEdge(v1, v2);
35 Edge s_v3=graph.addEdge(s, v3);
36 Edge v2_v4=graph.addEdge(v2, v4);
37 Edge v2_v5=graph.addEdge(v2, v5);
38 Edge v3_v5=graph.addEdge(v3, v5);
39 Edge v4_t=graph.addEdge(v4, t);
40 Edge v5_t=graph.addEdge(v5, t);
43 ListGraph::EdgeMap<int> length(graph);
54 std::cout << "Minlengthpaths algorithm test..." << std::endl;
58 MinLengthPaths< ListGraph, ListGraph::EdgeMap<int> >
59 surb_test(graph, length);
61 check( surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46,"Two paths, total length should be 46");
63 check( surb_test.checkComplementarySlackness(), "Complementary slackness conditions are not met.");
65 typedef DirPath<ListGraph> DPath;
69 surb_test.getPath(P,0);
70 check(P.length() == 4, "First path should contain 4 edges.");
71 cout<<P.length()<<endl;
72 surb_test.getPath(P,1);
73 check(P.length() == 3, "Second path: 3 edges.");
74 cout<<P.length()<<endl;
78 check( surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
80 check( surb_test.checkComplementarySlackness(), "Complementary slackness conditions are not met.");
82 surb_test.getPath(P,0);
83 check(P.length() == 4, "First path should contain 4 edges.");
85 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
88 return passed ? 0 : 1;