Several changes. \n If new map is added to mapstorage it emits signal with the name of the new map. This was important, because from now on not only tha mapwin should be updated. \n Furthermore algobox gets a pointer to mapstorage instead of only the mapnames from it. This is important because without it it would be complicated to pass all of the required maps to algobox.
2 * test/min_cost_flow_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2006 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Research Group on Combinatorial Optimization, 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 "test_tools.h"
19 #include <lemon/list_graph.h>
20 #include <lemon/min_cost_flow.h>
24 using namespace lemon;
29 void check(bool rc, char *msg="") {
30 passed = passed && rc;
32 std::cerr << "Test failed! ("<< msg << ")" << std::endl; \
42 typedef ListGraph Graph;
43 typedef Graph::Node Node;
44 typedef Graph::Edge Edge;
50 Node s=graph.addNode();
51 Node v1=graph.addNode();
52 Node v2=graph.addNode();
53 Node v3=graph.addNode();
54 Node v4=graph.addNode();
55 Node v5=graph.addNode();
56 Node t=graph.addNode();
58 Edge s_v1=graph.addEdge(s, v1);
59 Edge v1_v2=graph.addEdge(v1, v2);
60 Edge s_v3=graph.addEdge(s, v3);
61 Edge v2_v4=graph.addEdge(v2, v4);
62 Edge v2_v5=graph.addEdge(v2, v5);
63 Edge v3_v5=graph.addEdge(v3, v5);
64 Edge v4_t=graph.addEdge(v4, t);
65 Edge v5_t=graph.addEdge(v5, t);
68 Graph::EdgeMap<int> length(graph);
79 Graph::EdgeMap<int> capacity(graph);
81 capacity.set(s_v1, 2);
82 capacity.set(v1_v2, 2);
83 capacity.set(s_v3, 1);
84 capacity.set(v2_v4, 1);
85 capacity.set(v2_v5, 1);
86 capacity.set(v3_v5, 1);
87 capacity.set(v4_t, 1);
88 capacity.set(v5_t, 2);
90 // ConstMap<Edge, int> const1map(1);
91 std::cout << "Mincostflows algorithm test..." << std::endl;
93 MinCostFlow< Graph, Graph::EdgeMap<int>, Graph::EdgeMap<int> >
94 surb_test(graph, length, capacity, s, t);
99 check( surb_test.flowValue() == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
101 check( surb_test.run(k) == 1 && surb_test.totalLength() == 19,"One path, total length should be 19");
103 check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
107 check( surb_test.run(k) == 2 && surb_test.totalLength() == 41,"Two paths, total length should be 41");
109 check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
116 check( surb_test.run(k) == 3 && surb_test.totalLength() == 64,"Three paths, total length should be 64");
118 check(surb_test.checkComplementarySlackness(), "Is the primal-dual solution pair really optimal?");
121 std::cout << (passed ? "All tests passed." : "Some of the tests failed!!!")
124 return passed ? 0 : 1;