resetXxx() changed to setXxx().
2 #include<hugo/smart_graph.h>
3 #include<hugo/skeletons/graph.h>
4 #include<hugo/list_graph.h>
5 #include<hugo/full_graph.h>
10 This test makes consistency checks of list graph structures.
12 G.addNode(), G.addEdge(), G.valid(), G.tail(), G.head()
14 \todo Checks for empty graphs and isolated points.
18 using namespace hugo::skeleton;
20 template<class Graph> void checkCompileStaticGraph(Graph &G)
22 typedef typename Graph::Node Node;
23 typedef typename Graph::NodeIt NodeIt;
24 typedef typename Graph::Edge Edge;
25 typedef typename Graph::EdgeIt EdgeIt;
26 typedef typename Graph::InEdgeIt InEdgeIt;
27 typedef typename Graph::OutEdgeIt OutEdgeIt;
30 Node i; Node j(i); Node k(INVALID);
32 bool b=G.valid(i); b=b;
33 b=(i==j); b=(i!=j); b=(i<j);
36 NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
40 bool b=G.valid(i); b=b;
43 b=(i==j); b=(i!=j); b=(i<j);
46 Edge i; Edge j(i); Edge k(INVALID);
48 bool b=G.valid(i); b=b;
49 b=(i==j); b=(i!=j); b=(i<j);
52 EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
56 bool b=G.valid(i); b=b;
59 b=(i==j); b=(i!=j); b=(i<j);
63 InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
67 bool b=G.valid(i); b=b;
70 b=(i==j); b=(i!=j); b=(i<j);
74 OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
78 bool b=G.valid(i); b=b;
81 b=(i==j); b=(i!=j); b=(i<j);
94 { int i=G.id(n); i=i; }
95 { int i=G.id(e); i=i; }
102 typename Graph::template NodeMap<int> m(G);
103 typename Graph::template NodeMap<int> const &cm = m; //Const map
104 //Inicialize with default value
105 typename Graph::template NodeMap<int> mdef(G,12);
106 typename Graph::template NodeMap<int> mm(cm); //Copy
107 typename Graph::template NodeMap<double> dm(cm); //Copy from another type
109 v=m[k]; m[k]=v; m.set(k,v);
113 dm=cm; //Copy from another type
117 typename Graph::template NodeMap<bool> m(G);
118 typename Graph::template NodeMap<bool> const &cm = m; //Const map
119 //Inicialize with default value
120 typename Graph::template NodeMap<bool> mdef(G,12);
121 typename Graph::template NodeMap<bool> mm(cm); //Copy
122 typename Graph::template NodeMap<int> dm(cm); //Copy from another type
124 v=m[k]; m[k]=v; m.set(k,v);
128 dm=cm; //Copy from another type
129 m=dm; //Copy to another type
134 typename Graph::template EdgeMap<int> m(G);
135 typename Graph::template EdgeMap<int> const &cm = m; //Const map
136 //Inicialize with default value
137 typename Graph::template EdgeMap<int> mdef(G,12);
138 typename Graph::template EdgeMap<int> mm(cm); //Copy
139 typename Graph::template EdgeMap<double> dm(cm); //Copy from another type
141 v=m[k]; m[k]=v; m.set(k,v);
145 dm=cm; //Copy from another type
149 typename Graph::template EdgeMap<bool> m(G);
150 typename Graph::template EdgeMap<bool> const &cm = m; //Const map
151 //Inicialize with default value
152 typename Graph::template EdgeMap<bool> mdef(G,12);
153 typename Graph::template EdgeMap<bool> mm(cm); //Copy
154 typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
156 v=m[k]; m[k]=v; m.set(k,v);
160 dm=cm; //Copy from another type
161 m=dm; //Copy to another type
166 template<class Graph> void checkCompile(Graph &G)
168 checkCompileStaticGraph(G);
170 typedef typename Graph::Node Node;
171 typedef typename Graph::NodeIt NodeIt;
172 typedef typename Graph::Edge Edge;
173 typedef typename Graph::EdgeIt EdgeIt;
174 typedef typename Graph::InEdgeIt InEdgeIt;
175 typedef typename Graph::OutEdgeIt OutEdgeIt;
185 template<class Graph> void checkNodeList(Graph &G, int nn)
187 typename Graph::NodeIt n(G);
188 for(int i=0;i<nn;i++) {
189 check(G.valid(n),"Wrong Node list linking.");
192 check(!G.valid(n),"Wrong Node list linking.");
195 template<class Graph> void checkEdgeList(Graph &G, int nn)
197 typedef typename Graph::EdgeIt EdgeIt;
200 for(int i=0;i<nn;i++) {
201 check(G.valid(e),"Wrong Edge list linking.");
204 check(!G.valid(e),"Wrong Edge list linking.");
207 template<class Graph> void checkOutEdgeList(Graph &G,
208 typename Graph::Node n,
211 typename Graph::OutEdgeIt e(G,n);
212 for(int i=0;i<nn;i++) {
213 check(G.valid(e),"Wrong OutEdge list linking.");
216 check(!G.valid(e),"Wrong OutEdge list linking.");
219 template<class Graph> void checkInEdgeList(Graph &G,
220 typename Graph::Node n,
223 typename Graph::InEdgeIt e(G,n);
224 for(int i=0;i<nn;i++) {
225 check(G.valid(e),"Wrong InEdge list linking.");
228 check(!G.valid(e),"Wrong InEdge list linking.");
231 //Checks head(), tail() as well;
232 template<class Graph> void bidirPetersen(Graph &G)
234 typedef typename Graph::Edge Edge;
235 typedef typename Graph::EdgeIt EdgeIt;
239 std::vector<Edge> ee;
241 for(EdgeIt e(G);G.valid(e);G.next(e)) ee.push_back(e);
243 for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
244 G.addEdge(G.head(*p),G.tail(*p));
247 template<class Graph> void checkPetersen(Graph &G)
249 typedef typename Graph::Node Node;
251 typedef typename Graph::EdgeIt EdgeIt;
252 typedef typename Graph::NodeIt NodeIt;
257 for(NodeIt n(G);G.valid(n);G.next(n)) {
258 checkInEdgeList(G,n,3);
259 checkOutEdgeList(G,n,3);
265 void checkCompileStaticGraph<StaticGraphSkeleton>(StaticGraphSkeleton &);
266 template void checkCompile<GraphSkeleton>(GraphSkeleton &);
268 template void checkCompile<SmartGraph>(SmartGraph &);
269 template void checkCompile<SymSmartGraph>(SymSmartGraph &);
270 template void checkCompile<ListGraph>(ListGraph &);
271 template void checkCompile<SymListGraph>(SymListGraph &);
272 template void checkCompileStaticGraph<FullGraph>(FullGraph &);
274 template void checkCompile<EdgeSet <ListGraph> >(EdgeSet <ListGraph> &);
275 template void checkCompile<EdgeSet <NodeSet> >(EdgeSet <NodeSet> &);
303 //\todo copy constr tests.
305 std::cout << __FILE__ ": All tests passed.\n";