Set up automake environment.
2 #include <list_graph.h>
3 #include <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 typedef DirPath<ListGraph> DPath;
75 surb_test.getPath(P,0);
76 check(P.length() == 4, "First path should contain 4 edges.");
78 surb_test.getPath(P,1);
79 check(P.length() == 3, "Second path: 3 edges.");
82 check( surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
84 surb_test.getPath(P,0);
85 check(P.length() == 4, "First path should contain 4 edges.");
87 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
90 return passed ? 0 : 1;