1 | #include <iostream> |
---|
2 | |
---|
3 | #include <lemon/list_graph.h> |
---|
4 | #include <lemon/smart_graph.h> |
---|
5 | #include <merge_node_graph_wrapper.h> |
---|
6 | |
---|
7 | #include<lemon/concept_check.h> |
---|
8 | #include<lemon/concept/graph.h> |
---|
9 | |
---|
10 | using std::cout; |
---|
11 | using std::endl; |
---|
12 | |
---|
13 | using namespace lemon; |
---|
14 | using namespace lemon::concept; |
---|
15 | |
---|
16 | class Graph3 : ListGraph { |
---|
17 | public: |
---|
18 | class Node : public ListGraph::Node { }; |
---|
19 | class Edge { }; |
---|
20 | }; |
---|
21 | |
---|
22 | int main() { |
---|
23 | typedef SmartGraph Graph1; |
---|
24 | typedef ListGraph Graph2; |
---|
25 | |
---|
26 | // { |
---|
27 | // checkConcept<StaticGraph, NewEdgeSetGraphWrapper<Graph1, Graph2> >(); |
---|
28 | // } |
---|
29 | { |
---|
30 | Graph1 g; |
---|
31 | Graph2 h; |
---|
32 | typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
---|
33 | GW gw(g, h); |
---|
34 | Graph1::Node n1=g.addNode(); |
---|
35 | Graph1::Node n2=g.addNode(); |
---|
36 | Graph1::Node n3=g.addNode(); |
---|
37 | Graph2::Node n4=h.addNode(); |
---|
38 | Graph2::Node n5=h.addNode(); |
---|
39 | //GW::NodeIt n(gw) |
---|
40 | for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
---|
41 | cout << gw.id(n) << endl; |
---|
42 | } |
---|
43 | |
---|
44 | GW::NodeMap<int> nm(gw); |
---|
45 | int i=0; |
---|
46 | for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
---|
47 | ++i; |
---|
48 | nm.set(n, i); |
---|
49 | } |
---|
50 | for (Graph1::NodeIt n(g); n!=INVALID; ++n) { |
---|
51 | cout << nm[n] << endl; |
---|
52 | } |
---|
53 | for (Graph2::NodeIt n(h); n!=INVALID; ++n) { |
---|
54 | cout << nm[n] << endl; |
---|
55 | } |
---|
56 | |
---|
57 | gw.print(); |
---|
58 | |
---|
59 | { |
---|
60 | // typedef SmartGraph Graph1; |
---|
61 | typedef ListGraph Graph1; |
---|
62 | typedef ListGraph Graph2; |
---|
63 | Graph1 g; |
---|
64 | Graph2 h; |
---|
65 | typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
---|
66 | GW gw(g, h); |
---|
67 | gw.print(); |
---|
68 | } |
---|
69 | { |
---|
70 | // typedef SmartGraph Graph1; |
---|
71 | typedef Graph3 Graph1; |
---|
72 | typedef ListGraph Graph2; |
---|
73 | Graph1 g; |
---|
74 | Graph2 h; |
---|
75 | typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
---|
76 | GW gw(g, h); |
---|
77 | gw.print(); |
---|
78 | } |
---|
79 | { |
---|
80 | // typedef SmartGraph Graph1; |
---|
81 | typedef ListGraph Graph1; |
---|
82 | typedef Graph3 Graph2; |
---|
83 | Graph1 g; |
---|
84 | Graph2 h; |
---|
85 | typedef MergeNodeGraphWrapper<Graph1, Graph2> GW; |
---|
86 | GW gw(g, h); |
---|
87 | gw.print(); |
---|
88 | } |
---|
89 | } |
---|
90 | { |
---|
91 | Graph1 g; |
---|
92 | Graph2 h; |
---|
93 | typedef Graph1::Node Node1; |
---|
94 | typedef Graph2::Node Node2; |
---|
95 | typedef NewEdgeSetGraphWrapper<Graph1, Graph2> GW; |
---|
96 | Graph1::NodeMap<Graph2::Node> e_node(g); |
---|
97 | Graph2::NodeMap<Graph1::Node> n_node(h); |
---|
98 | GW gw(g, h, e_node, n_node); |
---|
99 | for (int i=0; i<4; ++i) { |
---|
100 | Node1 n=g.addNode(); |
---|
101 | e_node.set(n, INVALID); |
---|
102 | } |
---|
103 | for (int i=0; i<4; ++i) { |
---|
104 | Graph1::Node n1=g.addNode(); |
---|
105 | Graph2::Node n2=h.addNode(); |
---|
106 | e_node.set(n1, n2); |
---|
107 | n_node.set(n2, n1); |
---|
108 | } |
---|
109 | for (Graph2::NodeIt n(h); n!=INVALID; ++n) |
---|
110 | for (Graph2::NodeIt m(h); m!=INVALID; ++m) |
---|
111 | if ((h.id(n)+h.id(m))%3==0) h.addEdge(n, m); |
---|
112 | // Graph1::NodeIt n(g); |
---|
113 | // Node1 n1=n; |
---|
114 | // Node1 n2=++n; |
---|
115 | // Node1 n3=++n; |
---|
116 | // Node1 n4=n; |
---|
117 | // gw.addEdge(n1, n2); |
---|
118 | // gw.addEdge(n1, n2); |
---|
119 | // for (EdgeIt(e)) |
---|
120 | // Graph1::Node n1=g.addNode(); |
---|
121 | // Graph1::Node n2=g.addNode(); |
---|
122 | // Graph1::Node n3=g.addNode(); |
---|
123 | // Graph2::Node n4=h.addNode(); |
---|
124 | // Graph2::Node n5=h.addNode(); |
---|
125 | for (GW::EdgeIt e(gw); e!=INVALID; ++e) |
---|
126 | cout << gw.id(e) << endl; |
---|
127 | for (GW::NodeIt n(gw); n!=INVALID; ++n) { |
---|
128 | if (e_node[n]==INVALID) { |
---|
129 | cout<<gw.id(n)<<" INVALID"<<endl; |
---|
130 | } else { |
---|
131 | cout <<gw.id(n)<<" "<<h.id(e_node[n])<<" out_edges: "; |
---|
132 | // cout << &e_node << endl; |
---|
133 | //cout << &n_node << endl; |
---|
134 | for (GW::OutEdgeIt e(gw, n); e!=INVALID; ++e) { |
---|
135 | cout<<gw.id(e)<<" "; |
---|
136 | } |
---|
137 | cout<< endl; |
---|
138 | } |
---|
139 | } |
---|
140 | } |
---|
141 | } |
---|