Reserve is resolved.
1 #ifndef HUGO_TEST_GRAPH_TEST_H
2 #define HUGO_TEST_GRAPH_TEST_H
5 #include "test_tools.h"
9 //! \brief Some utility to test graph classes.
13 template<class Graph> void checkCompileStaticGraph(Graph &G)
15 typedef typename Graph::Node Node;
16 typedef typename Graph::NodeIt NodeIt;
17 typedef typename Graph::Edge Edge;
18 typedef typename Graph::EdgeIt EdgeIt;
19 typedef typename Graph::InEdgeIt InEdgeIt;
20 typedef typename Graph::OutEdgeIt OutEdgeIt;
23 Node i; Node j(i); Node k(INVALID);
25 // bool b=G.valid(i); b=b;
27 b=(i==INVALID); b=(i!=INVALID);
28 b=(i==j); b=(i!=j); b=(i<j);
31 NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
35 // bool b=G.valid(i); b=b;
37 b=(i==INVALID); b=(i!=INVALID);
40 b=(i==j); b=(i!=j); b=(i<j);
41 //Node ->NodeIt conversion
45 Edge i; Edge j(i); Edge k(INVALID);
47 // bool b=G.valid(i); b=b;
49 b=(i==INVALID); b=(i!=INVALID);
50 b=(i==j); b=(i!=j); b=(i<j);
53 EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
57 // bool b=G.valid(i); b=b;
59 b=(i==INVALID); b=(i!=INVALID);
62 b=(i==j); b=(i!=j); b=(i<j);
63 //Edge ->EdgeIt conversion
68 InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
72 // bool b=G.valid(i); b=b;
74 b=(i==INVALID); b=(i!=INVALID);
77 b=(i==j); b=(i!=j); b=(i<j);
78 //Edge ->InEdgeIt conversion
83 OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
87 // bool b=G.valid(i); b=b;
89 b=(i==INVALID); b=(i!=INVALID);
92 b=(i==j); b=(i!=j); b=(i<j);
93 //Edge ->OutEdgeIt conversion
105 { Node n; int i=G.id(n); i=i; }
106 { Edge e; int i=G.id(e); i=i; }
110 typename Graph::template NodeMap<int> m(G);
112 typename Graph::template NodeMap<int> const &cm = m;
113 //Inicialize with default value
114 typename Graph::template NodeMap<int> mdef(G,12);
116 typename Graph::template NodeMap<int> mm(cm);
117 //Copy from another type
118 typename Graph::template NodeMap<double> dm(cm);
120 v=m[k]; m[k]=v; m.set(k,v);
124 dm=cm; //Copy from another type
126 //Check the typedef's
127 typename Graph::template NodeMap<int>::ValueType val;
129 typename Graph::template NodeMap<int>::KeyType key;
130 key = typename Graph::NodeIt(G);
135 typename Graph::template NodeMap<bool> m(G);
136 typename Graph::template NodeMap<bool> const &cm = m; //Const map
137 //Inicialize with default value
138 typename Graph::template NodeMap<bool> mdef(G,12);
139 typename Graph::template NodeMap<bool> mm(cm); //Copy
140 typename Graph::template NodeMap<int> dm(cm); //Copy from another type
142 v=m[k]; m[k]=v; m.set(k,v);
146 dm=cm; //Copy from another type
147 m=dm; //Copy to another type
150 //Check the typedef's
151 typename Graph::template NodeMap<bool>::ValueType val;
153 typename Graph::template NodeMap<bool>::KeyType key;
154 key= typename Graph::NodeIt(G);
160 typename Graph::template EdgeMap<int> m(G);
161 typename Graph::template EdgeMap<int> const &cm = m; //Const map
162 //Inicialize with default value
163 typename Graph::template EdgeMap<int> mdef(G,12);
164 typename Graph::template EdgeMap<int> mm(cm); //Copy
165 typename Graph::template EdgeMap<double> dm(cm); //Copy from another type
167 v=m[k]; m[k]=v; m.set(k,v);
171 dm=cm; //Copy from another type
173 //Check the typedef's
174 typename Graph::template EdgeMap<int>::ValueType val;
176 typename Graph::template EdgeMap<int>::KeyType key;
177 key= typename Graph::EdgeIt(G);
182 typename Graph::template EdgeMap<bool> m(G);
183 typename Graph::template EdgeMap<bool> const &cm = m; //Const map
184 //Inicialize with default value
185 typename Graph::template EdgeMap<bool> mdef(G,12);
186 typename Graph::template EdgeMap<bool> mm(cm); //Copy
187 typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
189 v=m[k]; m[k]=v; m.set(k,v);
193 dm=cm; //Copy from another type
194 m=dm; //Copy to another type
196 //Check the typedef's
197 typename Graph::template EdgeMap<bool>::ValueType val;
199 typename Graph::template EdgeMap<bool>::KeyType key;
200 key= typename Graph::EdgeIt(G);
205 template<class Graph> void checkCompileGraph(Graph &G)
207 checkCompileStaticGraph(G);
209 typedef typename Graph::Node Node;
210 typedef typename Graph::NodeIt NodeIt;
211 typedef typename Graph::Edge Edge;
212 typedef typename Graph::EdgeIt EdgeIt;
213 typedef typename Graph::InEdgeIt InEdgeIt;
214 typedef typename Graph::OutEdgeIt OutEdgeIt;
225 template<class Graph> void checkCompileGraphEraseEdge(Graph &G)
227 typename Graph::Edge e;
231 template<class Graph> void checkCompileGraphEraseNode(Graph &G)
233 typename Graph::Node n;
237 template<class Graph> void checkCompileErasableGraph(Graph &G)
239 checkCompileGraph(G);
240 checkCompileGraphEraseNode(G);
241 checkCompileGraphEraseEdge(G);
244 template<class Graph> void checkCompileGraphFindEdge(Graph &G)
246 typedef typename Graph::NodeIt Node;
247 typedef typename Graph::NodeIt NodeIt;
249 G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
250 G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));
253 template<class Graph> void checkGraphNodeList(Graph &G, int nn)
255 typename Graph::NodeIt n(G);
256 for(int i=0;i<nn;i++) {
257 check(n!=INVALID,"Wrong Node list linking.");
260 check(n==INVALID,"Wrong Node list linking.");
263 template<class Graph> void checkGraphEdgeList(Graph &G, int nn)
265 typedef typename Graph::EdgeIt EdgeIt;
268 for(int i=0;i<nn;i++) {
269 check(e!=INVALID,"Wrong Edge list linking.");
272 check(e==INVALID,"Wrong Edge list linking.");
275 template<class Graph> void checkGraphOutEdgeList(Graph &G,
276 typename Graph::Node n,
279 typename Graph::OutEdgeIt e(G,n);
280 for(int i=0;i<nn;i++) {
281 check(e!=INVALID,"Wrong OutEdge list linking.");
284 check(e==INVALID,"Wrong OutEdge list linking.");
287 template<class Graph> void checkGraphInEdgeList(Graph &G,
288 typename Graph::Node n,
291 typename Graph::InEdgeIt e(G,n);
292 for(int i=0;i<nn;i++) {
293 check(e!=INVALID,"Wrong InEdge list linking.");
296 check(e==INVALID,"Wrong InEdge list linking.");
300 ///\todo Check head(), tail() as well;