2 #include <list_graph.h>
3 #include <minlengthpaths.h>
16 void check(bool rc, char *msg="") {
17 passed = passed && rc;
19 std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
30 typedef ListGraph::Node Node;
31 typedef ListGraph::Edge Edge;
37 Node s=graph.addNode();
38 Node v2=graph.addNode();
39 Node v3=graph.addNode();
40 Node v4=graph.addNode();
41 Node v5=graph.addNode();
42 Node t=graph.addNode();
44 Edge s_v2=graph.addEdge(s, v2);
45 Edge s_v3=graph.addEdge(s, v3);
46 Edge v2_v4=graph.addEdge(v2, v4);
47 Edge v2_v5=graph.addEdge(v2, v5);
48 Edge v3_v5=graph.addEdge(v3, v5);
49 Edge v4_t=graph.addEdge(v4, t);
50 Edge v5_t=graph.addEdge(v5, t);
53 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 && suurb_test.totalLength == 46,"Two paths, total length should be 46");
73 check( surb_test.run(s,t,k) == 1 && suurb_test.totalLength == 19,"One path, total length should be 19");
75 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
78 return passed ? 0 : 1;