equal
deleted
inserted
replaced
|
1 #include <string> |
|
2 #include <iostream> |
|
3 #include <map> |
|
4 |
|
5 #include <kruskal.h> |
|
6 #include <list_graph.hh> |
|
7 |
|
8 |
|
9 using namespace std; |
|
10 using namespace hugo; |
|
11 |
|
12 class string_int_map : public map<string,int> { |
|
13 public: |
|
14 int get(const string &s) { |
|
15 // Bocs, ez igy gaaaany, de nem volt kedvem utananezni, hogy |
|
16 // hogy is mukodik ez a map :) |
|
17 if( count(s) == 0 ) { |
|
18 operator[](s) = -1; |
|
19 } |
|
20 return operator[](s); |
|
21 } |
|
22 void set(const string &s, int i) { |
|
23 operator[](s) = i; |
|
24 } |
|
25 }; |
|
26 |
|
27 |
|
28 int main() { |
|
29 |
|
30 typedef ListGraph::NodeIt NodeIt; |
|
31 typedef ListGraph::EdgeIt EdgeIt; |
|
32 typedef ListGraph::EachNodeIt EachNodeIt; |
|
33 typedef ListGraph::EachEdgeIt EachEdgeIt; |
|
34 |
|
35 ListGraph G; |
|
36 |
|
37 NodeIt s=G.addNode(); |
|
38 NodeIt v1=G.addNode(); |
|
39 NodeIt v2=G.addNode(); |
|
40 NodeIt v3=G.addNode(); |
|
41 NodeIt v4=G.addNode(); |
|
42 NodeIt t=G.addNode(); |
|
43 |
|
44 G.addEdge(s, v1); |
|
45 G.addEdge(s, v2); |
|
46 G.addEdge(v1, v2); |
|
47 G.addEdge(v2, v1); |
|
48 G.addEdge(v1, v3); |
|
49 G.addEdge(v3, v2); |
|
50 G.addEdge(v2, v4); |
|
51 G.addEdge(v4, v3); |
|
52 G.addEdge(v3, t); |
|
53 G.addEdge(v4, t); |
|
54 |
|
55 ListGraph::EdgeMap<double> edge_cost_map(G, 2); |
|
56 ListGraph::EdgeMap<bool> tree_map(G); |
|
57 |
|
58 double k0lts = MinCostTreeKruskal(G, edge_cost_map, tree_map); |
|
59 |
|
60 cout << k0lts << endl; |
|
61 |
|
62 return 0; |
|
63 } |