Rename StoreBoolMap to LoggerBoolMap (ticket #34).
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
22 #include "test_tools.h"
23 #include <lemon/maps.h>
24 #include <lemon/kruskal.h>
25 #include <lemon/list_graph.h>
27 #include <lemon/concepts/maps.h>
28 #include <lemon/concepts/digraph.h>
29 #include <lemon/concepts/graph.h>
33 using namespace lemon;
35 void checkCompileKruskal()
37 concepts::WriteMap<concepts::Digraph::Arc,bool> w;
38 concepts::WriteMap<concepts::Graph::Edge,bool> uw;
40 concepts::ReadMap<concepts::Digraph::Arc,int> r;
41 concepts::ReadMap<concepts::Graph::Edge,int> ur;
49 std::vector<std::pair<concepts::Digraph::Arc, int> > rs;
50 std::vector<std::pair<concepts::Graph::Edge, int> > urs;
55 std::vector<concepts::Digraph::Arc> ws;
56 std::vector<concepts::Graph::Edge> uws;
58 kruskal(g, r, ws.begin());
59 kruskal(ug, ur, uws.begin());
65 typedef ListGraph::Node Node;
66 typedef ListGraph::Edge Edge;
67 typedef ListGraph::NodeIt NodeIt;
68 typedef ListGraph::ArcIt ArcIt;
79 Edge e1 = G.addEdge(s, v1);
80 Edge e2 = G.addEdge(s, v2);
81 Edge e3 = G.addEdge(v1, v2);
82 Edge e4 = G.addEdge(v2, v1);
83 Edge e5 = G.addEdge(v1, v3);
84 Edge e6 = G.addEdge(v3, v2);
85 Edge e7 = G.addEdge(v2, v4);
86 Edge e8 = G.addEdge(v4, v3);
87 Edge e9 = G.addEdge(v3, t);
88 Edge e10 = G.addEdge(v4, t);
90 typedef ListGraph::EdgeMap<int> ECostMap;
91 typedef ListGraph::EdgeMap<bool> EBoolMap;
93 ECostMap edge_cost_map(G, 2);
97 //Test with const map.
98 check(kruskal(G, ConstMap<ListGraph::Edge,int>(2), tree_map)==10,
99 "Total cost should be 10");
100 //Test with a edge map (filled with uniform costs).
101 check(kruskal(G, edge_cost_map, tree_map)==10,
102 "Total cost should be 10");
104 edge_cost_map.set(e1, -10);
105 edge_cost_map.set(e2, -9);
106 edge_cost_map.set(e3, -8);
107 edge_cost_map.set(e4, -7);
108 edge_cost_map.set(e5, -6);
109 edge_cost_map.set(e6, -5);
110 edge_cost_map.set(e7, -4);
111 edge_cost_map.set(e8, -3);
112 edge_cost_map.set(e9, -2);
113 edge_cost_map.set(e10, -1);
115 vector<Edge> tree_edge_vec(5);
117 //Test with a edge map and inserter.
118 check(kruskal(G, edge_cost_map,
119 tree_edge_vec.begin())
121 "Total cost should be -31.");
123 tree_edge_vec.clear();
125 check(kruskal(G, edge_cost_map,
126 back_inserter(tree_edge_vec))
128 "Total cost should be -31.");
130 // tree_edge_vec.clear();
132 // //The above test could also be coded like this:
134 // makeKruskalMapInput(G, edge_cost_map),
135 // makeKruskalSequenceOutput(back_inserter(tree_edge_vec)))
137 // "Total cost should be -31.");
139 check(tree_edge_vec.size()==5,"The tree should have 5 edges.");
141 check(tree_edge_vec[0]==e1 &&
142 tree_edge_vec[1]==e2 &&
143 tree_edge_vec[2]==e5 &&
144 tree_edge_vec[3]==e7 &&
145 tree_edge_vec[4]==e9,