NodeSubGraphWrapper, test, and ducumentation modifications.
2 * src/test/suurballe_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
18 #include <lemon/list_graph.h>
19 #include <lemon/suurballe.h>
21 #include "test_tools.h"
24 using namespace lemon;
34 typedef ListGraph::Node Node;
35 typedef ListGraph::Edge Edge;
41 Node s=graph.addNode();
42 Node v1=graph.addNode();
43 Node v2=graph.addNode();
44 Node v3=graph.addNode();
45 Node v4=graph.addNode();
46 Node v5=graph.addNode();
47 Node t=graph.addNode();
49 Edge s_v1=graph.addEdge(s, v1);
50 Edge v1_v2=graph.addEdge(v1, v2);
51 Edge s_v3=graph.addEdge(s, v3);
52 Edge v2_v4=graph.addEdge(v2, v4);
53 Edge v2_v5=graph.addEdge(v2, v5);
54 Edge v3_v5=graph.addEdge(v3, v5);
55 Edge v4_t=graph.addEdge(v4, t);
56 Edge v5_t=graph.addEdge(v5, t);
59 ListGraph::EdgeMap<int> length(graph);
70 std::cout << "Minlengthpaths algorithm test..." << std::endl;
74 Suurballe< ListGraph, ListGraph::EdgeMap<int> >
75 surb_test(graph, length);
77 check( surb_test.run(s,t,k) == 2 && surb_test.totalLength() == 46,
78 "Two paths, total length should be 46");
80 check( surb_test.checkComplementarySlackness(),
81 "Complementary slackness conditions are not met.");
83 // typedef DirPath<ListGraph> DPath;
87 surb_test.getPath(P,0);
88 check(P.length() == 4, "First path should contain 4 edges.");
89 cout<<P.length()<<endl;
90 surb_test.getPath(P,1);
91 check(P.length() == 3, "Second path: 3 edges.");
92 cout<<P.length()<<endl;
96 check( surb_test.run(s,t,k) == 1 && surb_test.totalLength() == 19,
97 "One path, total length should be 19");
99 check( surb_test.checkComplementarySlackness(),
100 "Complementary slackness conditions are not met.");
102 // surb_test.getPath(P,0);
103 // check(P.length() == 4, "First path should contain 4 edges.");
105 cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
108 return passed ? 0 : 1;