Two examples showing a bit more convenient way to implement named parameters.
2 #ifndef GRAPH_WRAPPER_H
3 #define GRAPH_WRAPPER_H
15 typedef typename G::EdgeIt EdgeIt;
17 typedef typename G::InEdgeIt InEdgeIt;
18 typedef typename G::OutEdgeIt OutEdgeIt;
19 typedef typename G::SymEdgeIt SymEdgeIt;
20 typedef typename G::EachEdgeIt EachEdgeIt;
22 typedef typename G::NodeIt NodeIt;
24 template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
25 template<typename I,typename P> I &getFirst(I &i,const P &p);
26 { return graph->getFirst(i,p); }
27 template<typename I> I next(const I i); { return graph->goNext(i); }
28 template<typename I> I &goNext(I &i); { return graph->goNext(i); }
30 NodeIt target(const EdgeIt &e);
31 { return graph->target(e); }
32 NodeIt source(const EdgeIt &e);
33 { return graph->source(e); }
35 template<typename I> NodeIt aNode(const I e);
36 { return graph->aNode(e); }
37 template<typename I> NodeIt bNode(const I e);
38 { return graph->bNode(e); }
40 template<typename I> bool valid(const I i);
41 { return graph->valid(i); }
43 template<typename I> void setInvalid(const I &i);
44 { return graph->setInvalid(i); }
46 NodeIt addNode(); { return graph->addNode(); }
47 EdgeIt addEdge(const NodeIt from,const NodeIt to);
48 { return graph->addEdge(ftom,to); }
50 template<I> void delete(I i); { graph->delete(i); }
52 void clean(); { graph->clean(); }
54 template<class T> class NodeMap : public typename G::NodeMap<T>;
55 template<class T> class EdgeMap : public typename G::EdgeMap<T>;
57 void SetG(G &g) {graph = &g;}
59 TrivGraphWrapper() {graph = NULL;}
60 TrivGraphWrapper(G &g) {graph = &g;}
71 typedef typename G::EdgeIt EdgeIt;
73 typedef typename G::InEdgeIt OutEdgeIt;
74 typedef typename G::OutEdgeIt InEdgeIt;
75 typedef typename G::SymEdgeIt SymEdgeIt;
76 typedef typename G::EachEdgeIt EachEdgeIt;
78 typedef typename G::NodeIt NodeIt;
80 template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
81 template<typename I,typename P> I &getFirst(I &i,const P &p);
82 { return graph->getFirst(i,p); }
83 template<typename I> I next(const I i); { return graph->goNext(i); }
84 template<typename I> I &goNext(I &i); { return graph->goNext(i); }
86 NodeIt target(const EdgeIt &e);
87 { return graph->source(e); }
88 NodeIt source(const EdgeIt &e);
89 { return graph->target(e); }
91 template<typename I> NodeIt aNode(const I e);
92 { return graph->aNode(e); }
93 template<typename I> NodeIt bNode(const I e);
94 { return graph->bNode(e); }
96 template<typename I> bool valid(const I i);
97 { return graph->valid(i); }
99 template<typename I> void setInvalid(const I &i);
100 { return graph->setInvalid(i); }
102 NodeIt addNode(); { return graph->addNode(); }
103 EdgeIt addEdge(const NodeIt from,const NodeIt to);
104 { return graph->addEdge(to,from); }
106 template<I> void delete(I i); { graph->delete(i); }
108 void clean(); { graph->clean(); }
110 template<class T> class NodeMap : public typename G::NodeMap<T>;
111 template<class T> class EdgeMap : public typename G::EdgeMap<T>;
113 void SetG(G &g) {graph = &g;}
115 RevGraphWrapper() {graph = NULL;}
116 RevGraphWrapper(G &g) {graph = &g;}
120 class RevGraphExt : public G
123 // typedef G BaseGraph;
125 typedef typename G::EdgeIt EdgeIt;
127 typedef typename G::InEdgeIt OutEdgeIt;
128 typedef typename G::OutEdgeIt InEdgeIt;
129 typedef typename G::SymEdgeIt SymEdgeIt;
130 typedef typename G::EachEdgeIt EachEdgeIt;
132 typedef typename G::NodeIt NodeIt;
134 // template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
135 // template<typename I,typename P> I &getFirst(I &i,const P &p);
136 // { return graph->getFirst(i,p); }
137 // template<typename I> I next(const I i); { return graph->goNext(i); }
138 // template<typename I> I &goNext(I &i); { return graph->goNext(i); }
140 NodeIt target(const EdgeIt &e);
141 { return G::source(e); }
142 NodeIt source(const EdgeIt &e);
143 { return G::target(e); }
145 // template<typename I> NodeIt aNode(const I e);
146 // { return graph->aNode(e); }
147 // template<typename I> NodeIt bNode(const I e);
148 // { return graph->bNode(e); }
150 // template<typename I> bool valid(const I i);
151 // { return graph->valid(i); }
153 // template<typename I> void setInvalid(const I &i);
154 // { return graph->setInvalid(i); }
156 // NodeIt addNode(); { return graph->addNode(); }
158 EdgeIt addEdge(const NodeIt from,const NodeIt to);
159 { return G::addEdge(to,from); }
161 // template<I> void delete(I i); { graph->delete(i); }
163 // void clean(); { graph->clean(); }
165 // template<class T> class NodeMap : public typename G::NodeMap<T>;
166 // template<class T> class EdgeMap : public typename G::EdgeMap<T>;
168 // void SetG(G &g) {graph = &g;}
170 // RevGraphWrapper() {graph = NULL;}
171 // RevGraphWrapper(G &g) {graph = &g;}
175 class SymGraphWrapper
182 typedef typename G::EdgeIt EdgeIt;
184 typedef typename G::SymEdgeIt InEdgeIt;
185 typedef typename G::SymEdgeIt OutEdgeIt;
186 typedef typename G::SymEdgeIt SymEdgeIt;
187 typedef typename G::EachEdgeIt EachEdgeIt;
189 typedef typename G::NodeIt NodeIt;
191 template<typename I> I &getFirst(I &i); { return graph->getFirst(i); }
192 template<typename I,typename P> I &getFirst(I &i,const P &p);
193 { return graph->getFirst(i,p); }
194 template<typename I> I next(const I i); { return graph->goNext(i); }
195 template<typename I> I &goNext(I &i); { return graph->goNext(i); }
197 NodeIt target(const EdgeIt &e);
198 { return graph->target(e); }
199 NodeIt source(const EdgeIt &e);
200 { return graph->source(e); }
202 template<typename I> NodeIt aNode(const I e);
203 { return graph->aNode(e); }
204 template<typename I> NodeIt bNode(const I e);
205 { return graph->bNode(e); }
207 template<typename I> bool valid(const I i);
208 { return graph->valid(i); }
210 template<typename I> void setInvalid(const I &i);
211 { return graph->setInvalid(i); }
213 NodeIt addNode(); { return graph->addNode(); }
214 EdgeIt addEdge(const NodeIt from,const NodeIt to);
215 { return graph->addEdge(to,from); }
217 template<I> void delete(I i); { graph->delete(i); }
219 void clean(); { graph->clean(); }
221 template<class T> class NodeMap : public typename G::NodeMap<T>;
222 template<class T> class EdgeMap : public typename G::EdgeMap<T>;
224 void SetG(G &g) {graph = &g;}
226 RevGraphWrapper() {graph = NULL;}
227 RevGraphWrapper(G &g) {graph = &g;}
248 // FIXME: comparison should be made better!!!
249 template<typename G, typename lomap, typename fmap, typename himap>
250 class ResGraphWrapper
257 typedef typename G::EdgeIt EdgeIt;
273 typedef typename G::SymEdgeIt SymEdgeIt;
274 typedef typename G::EachEdgeIt EachEdgeIt;
276 typedef typename G::NodeIt NodeIt;
278 NodeIt &getFirst(NodeIt &n); { return graph->getFirst(n); }
280 // EachEdge and SymEdge is missing!!!!
281 // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!
283 InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n)
286 graph->getFirst(e.i,n);
287 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
289 if(!graph->valid(e.i)) {
290 graph->getFirst(e.o,n);
291 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
296 InEdgeIt &goNext(InEdgeIt &e)
298 if(graph->valid(e.i)) {
299 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
301 if(graph->valid(e.i)) return e;
302 else graph->getFirst(e.o,e.n);
305 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
310 InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
311 bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}
313 OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n)
316 graph->getFirst(e.o,n);
317 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
319 if(!graph->valid(e.o)) {
320 graph->getFirst(e.i,n);
321 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
326 OutEdgeIt &goNext(OutEdgeIt &e)
328 if(graph->valid(e.o)) {
329 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
331 if(graph->valid(e.o)) return e;
332 else graph->getFirst(e.i,e.n);
335 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
340 OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
341 bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}
343 template<typename I> I &goNext(I &i); { return graph->goNext(i); }
344 template<typename I> I next(const I i); { return graph->goNext(i); }
346 NodeIt target(const EdgeIt &e);
347 { return graph->target(e); }
348 NodeIt source(const EdgeIt &e);
349 { return graph->source(e); }
351 template<typename I> NodeIt aNode(const I e);
352 { return graph->aNode(e); }
353 template<typename I> NodeIt bNode(const I e);
354 { return graph->bNode(e); }
356 template<typename I> bool valid(const I i);
357 { return graph->valid(i); }
359 template<typename I> void setInvalid(const I &i);
360 { return graph->setInvalid(i); }
362 NodeIt addNode(); { return graph->addNode(); }
363 EdgeIt addEdge(const NodeIt from,const NodeIt to);
364 { return graph->addEdge(to,from); }
366 template<I> void delete(I i); { graph->delete(i); }
368 void clean(); { graph->clean(); }
370 template<class T> class NodeMap : public typename G::NodeMap<T>;
371 template<class T> class EdgeMap : public typename G::EdgeMap<T>;
373 void SetG(G &g) {graph = &g;}
375 RevGraphWrapper() {graph = NULL;}
376 RevGraphWrapper(G &g) {graph = &g;}
381 // NodeIt &getFirst(NodeIt &n) { return graph->getFirst(n); }
382 // InEdgeIt &getFirst(InEdgeIt &e,const NodeIt &n);
383 // { return graph->getFirst(e,n); }
384 // OutEdgeIt &getFirst(OutEdgeIt &e,const NodeIt &n);
385 // { return graph->getFirst(e,n); }
386 // SymEdgeIt &getFirst(SymEdgeIt &e,const NodeIt &n);
387 // { return graph->getFirst(e,n); }
388 // EachEdgeIt &getFirst(EachEdgeIt &e);
389 // { return graph->getFirst(e); }
391 // NodeIt next(const NodeIt &n);
392 // { return graph->next(n); }
393 // InEdgeIt next(const InEdgeIt &e);
394 // { return graph->next(e); }
395 // OutEdgeIt next(const OutEdgeIt &e);
396 // { return graph->next(e); }
397 // SymEdgeIt next(const SymEdgeIt &e);
398 // { return graph->next(e); }
399 // EachEdgeIt next(const EachEdgeIt &e);
400 // { return graph->next(e); }
402 // NodeIt &goNext(NodeIt &n);
403 // { return graph->goNext(n); }
404 // InEdgeIt &goNext(InEdgeIt &e);
405 // { return graph->goNext(e); }
406 // OutEdgeIt &goNext(OutEdgeIt &e);
407 // { return graph->goNext(e); }
408 // SymEdgeIt &goNext(SymEdgeIt &e);
409 // { return graph->goNext(e); }
410 // EachEdgeIt &goNext(EachEdgeIt &e);
411 // { return graph->goNext(e); }