Peter is able to read xy vector from file.
4 #include <lemon/maps.h>
5 #include <lemon/kruskal.h>
6 #include <lemon/list_graph.h>
10 using namespace lemon;
15 typedef ListGraph::Node Node;
16 typedef ListGraph::Edge Edge;
17 typedef ListGraph::NodeIt NodeIt;
18 typedef ListGraph::EdgeIt EdgeIt;
29 Edge e1 = G.addEdge(s, v1);
30 Edge e2 = G.addEdge(s, v2);
31 Edge e3 = G.addEdge(v1, v2);
32 Edge e4 = G.addEdge(v2, v1);
33 Edge e5 = G.addEdge(v1, v3);
34 Edge e6 = G.addEdge(v3, v2);
35 Edge e7 = G.addEdge(v2, v4);
36 Edge e8 = G.addEdge(v4, v3);
37 Edge e9 = G.addEdge(v3, t);
38 Edge e10 = G.addEdge(v4, t);
40 typedef ListGraph::EdgeMap<int> ECostMap;
41 typedef ListGraph::EdgeMap<bool> EBoolMap;
43 ECostMap edge_cost_map(G, 2);
47 //Test with const map.
48 std::cout << "The weight of the minimum spanning tree is " << kruskalEdgeMap(G, ConstMap<ListGraph::Edge,int>(2), tree_map)<<std::endl;
52 "Total cost should be 10");
53 //Test with a edge map (filled with uniform costs).
54 check(kruskalEdgeMap(G, edge_cost_map, tree_map)==10,
55 "Total cost should be 10");
57 edge_cost_map.set(e1, -10);
58 edge_cost_map.set(e2, -9);
59 edge_cost_map.set(e3, -8);
60 edge_cost_map.set(e4, -7);
61 edge_cost_map.set(e5, -6);
62 edge_cost_map.set(e6, -5);
63 edge_cost_map.set(e7, -4);
64 edge_cost_map.set(e8, -3);
65 edge_cost_map.set(e9, -2);
66 edge_cost_map.set(e10, -1);
68 vector<Edge> tree_edge_vec;
70 //Test with a edge map and inserter.
71 check(kruskalEdgeMap_IteratorOut(G, edge_cost_map,
72 back_inserter(tree_edge_vec))
74 "Total cost should be -31.");
76 tree_edge_vec.clear();
78 //The above test could also be coded like this:
80 makeKruskalMapInput(G, edge_cost_map),
81 makeKruskalSequenceOutput(back_inserter(tree_edge_vec)))
83 "Total cost should be -31.");
85 check(tree_edge_vec.size()==5,"The tree should have 5 edges.");
87 check(tree_edge_vec[0]==e1 &&
88 tree_edge_vec[1]==e2 &&
89 tree_edge_vec[2]==e5 &&
90 tree_edge_vec[3]==e7 &&