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