21 |
23 |
22 int main() { |
24 int main() { |
23 typedef SmartGraph Graph1; |
25 typedef SmartGraph Graph1; |
24 typedef ListGraph Graph2; |
26 typedef ListGraph Graph2; |
25 |
27 |
26 // { |
|
27 // checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >(); |
|
28 // } |
|
29 { |
28 { |
|
29 checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >(); |
|
30 } |
|
31 { |
|
32 checkConcept<StaticGraph, MergeEdgeGraphWrapper<Graph1, Graph2> >(); |
|
33 } |
|
34 |
30 Graph1 g; |
35 Graph1 g; |
31 Graph2 h; |
36 Graph2 h; |
32 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
37 typedef MergeEdgeGraphWrapper<Graph1, Graph2> GW; |
33 GW gw(g, h); |
38 GW gw(g, h); |
34 Graph1::Node n1=g.addNode(); |
39 |
35 Graph1::Node n2=g.addNode(); |
40 std::ifstream f1("graph1.dim"); |
36 Graph1::Node n3=g.addNode(); |
41 std::ifstream f2("graph2.dim"); |
37 Graph2::Node n4=h.addNode(); |
42 readDimacs(f1, g); |
38 Graph2::Node n5=h.addNode(); |
43 readDimacs(f2, h); |
|
44 { |
|
45 |
|
46 // Graph1::Node n1=g.addNode(); |
|
47 // Graph1::Node n2=g.addNode(); |
|
48 // Graph1::Node n3=g.addNode(); |
|
49 // Graph2::Node n4=h.addNode(); |
|
50 // Graph2::Node n5=h.addNode(); |
|
51 // Graph2::Node n6=h.addNode(); |
|
52 // Graph1::Edge e1=g.addEdge(n1, n2); |
|
53 // Graph1::Edge e2=g.addEdge(n1, n3); |
|
54 // Graph2::Edge e3=h.addEdge(n4, n5); |
|
55 // Graph2::Edge e4=h.addEdge(n4, n5); |
39 //GW::NodeIt n(gw) |
56 //GW::NodeIt n(gw) |
|
57 cout << "1st graph" << endl; |
|
58 cout << " nodes:" << endl; |
|
59 for (Graph1::NodeIt n(g); n!=INVALID; ++n) { |
|
60 cout << " " << g.id(n) << endl; |
|
61 } |
|
62 cout << " edges:" << endl; |
|
63 for (Graph1::EdgeIt n(g); n!=INVALID; ++n) { |
|
64 cout << " " << g.id(n) << ": " |
|
65 << g.id(g.source(n)) << "->" << g.id(g.target(n)) << endl; |
|
66 } |
|
67 cout << "2nd graph" << endl; |
|
68 cout << " nodes:" << endl; |
|
69 for (Graph2::NodeIt n(h); n!=INVALID; ++n) { |
|
70 cout << " " << h.id(n) << endl; |
|
71 } |
|
72 cout << " edges:" << endl; |
|
73 for (Graph2::EdgeIt n(h); n!=INVALID; ++n) { |
|
74 cout << " " << h.id(n) << ": " |
|
75 << h.id(h.source(n)) << "->" << h.id(h.target(n)) << endl; |
|
76 } |
|
77 cout << "merged graph" << endl; |
|
78 cout << " nodes:" << endl; |
40 for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
79 for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
41 cout << gw.id(n) << endl; |
80 cout << " "<< gw.id(n) << endl; |
|
81 } |
|
82 cout << " edges:" << endl; |
|
83 for (GW::EdgeIt n(gw); n!=INVALID; ++n) { |
|
84 cout << " " << gw.id(n) << ": " |
|
85 << gw.id(gw.source(n)) << "->" << gw.id(gw.target(n)) << endl; |
42 } |
86 } |
43 |
87 |
44 GW::NodeMap<int> nm(gw); |
88 GW::NodeMap<int> nm(gw); |
45 int i=0; |
89 int i=0; |
46 for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
90 for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
47 ++i; |
91 ++i; |
48 nm.set(n, i); |
92 nm.set(n, i); |
49 } |
93 } |
50 for (Graph1::NodeIt n(g); n!=INVALID; ++n) { |
94 for (Graph1::NodeIt n(g); n!=INVALID; ++n) { |
51 cout << nm[n] << endl; |
95 cout << nm[GW::Node(n,INVALID,false)] << endl; |
52 } |
96 } |
53 for (Graph2::NodeIt n(h); n!=INVALID; ++n) { |
97 for (Graph2::NodeIt n(h); n!=INVALID; ++n) { |
54 cout << nm[n] << endl; |
98 cout << nm[GW::Node(INVALID,n,true)] << endl; |
55 } |
99 } |
56 |
100 |
57 gw.print(); |
101 gw.printNode(); |
58 |
102 |
59 { |
103 { |
60 // typedef SmartGraph Graph1; |
104 // typedef SmartGraph Graph1; |
61 typedef ListGraph Graph1; |
105 typedef ListGraph Graph1; |
62 typedef ListGraph Graph2; |
106 typedef ListGraph Graph2; |
63 Graph1 g; |
107 Graph1 g; |
64 Graph2 h; |
108 Graph2 h; |
65 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
109 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
66 GW gw(g, h); |
110 GW gw(g, h); |
67 gw.print(); |
111 gw.printNode(); |
68 } |
112 } |
69 { |
113 { |
70 // typedef SmartGraph Graph1; |
114 // typedef SmartGraph Graph1; |
71 typedef Graph3 Graph1; |
115 typedef Graph3 Graph1; |
72 typedef ListGraph Graph2; |
116 typedef ListGraph Graph2; |
73 Graph1 g; |
117 Graph1 g; |
74 Graph2 h; |
118 Graph2 h; |
75 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
119 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
76 GW gw(g, h); |
120 GW gw(g, h); |
77 gw.print(); |
121 gw.printNode(); |
78 } |
122 } |
79 { |
123 { |
80 // typedef SmartGraph Graph1; |
124 // typedef SmartGraph Graph1; |
81 typedef ListGraph Graph1; |
125 typedef ListGraph Graph1; |
82 typedef Graph3 Graph2; |
126 typedef Graph3 Graph2; |
83 Graph1 g; |
127 Graph1 g; |
84 Graph2 h; |
128 Graph2 h; |
85 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
129 typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
86 GW gw(g, h); |
130 GW gw(g, h); |
87 gw.print(); |
131 gw.printNode(); |
88 } |
132 } |
89 } |
133 } |
90 { |
134 { |
91 Graph1 g; |
135 Graph1 g; |
92 Graph2 h; |
136 Graph2 h; |