Changed to conform to the new iterator style.
4 #include "test_tools.h"
6 #include <hugo/kruskal.h>
7 #include <hugo/list_graph.h>
8 #include <hugo/skeletons/maps.h>
9 #include <hugo/skeletons/graph.h>
15 void checkCompileKruskal()
17 skeleton::WriteMap<skeleton::StaticGraphSkeleton::Edge,bool> w;
19 kruskalEdgeMap(skeleton::StaticGraphSkeleton(),
20 skeleton::ReadMap<skeleton::StaticGraphSkeleton::Edge,int>(),
26 typedef ListGraph::Node Node;
27 typedef ListGraph::Edge Edge;
28 typedef ListGraph::NodeIt NodeIt;
29 typedef ListGraph::EdgeIt EdgeIt;
40 Edge e1 = G.addEdge(s, v1);
41 Edge e2 = G.addEdge(s, v2);
42 Edge e3 = G.addEdge(v1, v2);
43 Edge e4 = G.addEdge(v2, v1);
44 Edge e5 = G.addEdge(v1, v3);
45 Edge e6 = G.addEdge(v3, v2);
46 Edge e7 = G.addEdge(v2, v4);
47 Edge e8 = G.addEdge(v4, v3);
48 Edge e9 = G.addEdge(v3, t);
49 Edge e10 = G.addEdge(v4, t);
51 typedef ListGraph::EdgeMap<int> ECostMap;
52 typedef ListGraph::EdgeMap<bool> EBoolMap;
54 ECostMap edge_cost_map(G, 2);
58 //Test with const map.
59 check(kruskalEdgeMap(G, ConstMap<ListGraph::Edge,int>(2), tree_map)==10,
60 "Total cost should be 10");
61 //Test with a edge map (filled with uniform costs).
62 check(kruskalEdgeMap(G, edge_cost_map, tree_map)==10,
63 "Total cost should be 10");
65 edge_cost_map.set(e1, -10);
66 edge_cost_map.set(e2, -9);
67 edge_cost_map.set(e3, -8);
68 edge_cost_map.set(e4, -7);
69 edge_cost_map.set(e5, -6);
70 edge_cost_map.set(e6, -5);
71 edge_cost_map.set(e7, -4);
72 edge_cost_map.set(e8, -3);
73 edge_cost_map.set(e9, -2);
74 edge_cost_map.set(e10, -1);
76 vector<Edge> tree_edge_vec;
78 //Test with a edge map and inserter.
79 check(kruskalEdgeMap_IteratorOut(G, edge_cost_map,
80 back_inserter(tree_edge_vec))
82 "Total cost should be -31.");
84 check(tree_edge_vec.size()==5,"The tree should have 5 edges.");
86 check(tree_edge_vec[0]==e1 &&
87 tree_edge_vec[1]==e2 &&
88 tree_edge_vec[2]==e5 &&
89 tree_edge_vec[3]==e7 &&