2 #ifndef HUGO_GRAPH_WRAPPER_H
3 #define HUGO_GRAPH_WRAPPER_H
9 template<typename Graph>
15 typedef Graph BaseGraph;
16 typedef Graph ParentGraph;
18 // GraphWrapper() : graph(0) { }
19 GraphWrapper(Graph& _graph) : graph(&_graph) { }
20 // void setGraph(Graph& _graph) { graph=&_graph; }
21 // Graph& getGraph() const { return *graph; }
23 // typedef typename Graph::Node Node;
24 class Node : public Graph::Node {
25 friend class GraphWrapper<Graph>;
28 Node(const typename Graph::Node& _n) : Graph::Node(_n) { }
29 Node(const Invalid& i) : Graph::Node(i) { }
32 friend class GraphWrapper<Graph>;
33 typename Graph::NodeIt n;
36 NodeIt(const typename Graph::NodeIt& _n) : n(_n) { }
37 NodeIt(const Invalid& i) : n(i) { }
38 NodeIt(const GraphWrapper<Graph>& _G) : n(*(_G.graph)) { }
39 operator Node() const { return Node(typename Graph::Node(n)); }
41 // typedef typename Graph::Edge Edge;
42 class Edge : public Graph::Edge {
43 friend class GraphWrapper<Graph>;
46 Edge(const typename Graph::Edge& _e) : Graph::Edge(_e) { }
47 Edge(const Invalid& i) : Graph::Edge(i) { }
50 friend class GraphWrapper<Graph>;
51 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
52 typename Graph::OutEdgeIt e;
55 OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { }
56 OutEdgeIt(const Invalid& i) : e(i) { }
57 OutEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) :
58 e(*(_G.graph), typename Graph::Node(_n)) { }
59 operator Edge() const { return Edge(typename Graph::Edge(e)); }
62 friend class GraphWrapper<Graph>;
63 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
64 typename Graph::InEdgeIt e;
67 InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
68 InEdgeIt(const Invalid& i) : e(i) { }
69 InEdgeIt(const GraphWrapper<Graph>& _G, const Node& _n) :
70 e(*(_G.graph), typename Graph::Node(_n)) { }
71 operator Edge() const { return Edge(typename Graph::Edge(e)); }
73 //typedef typename Graph::SymEdgeIt SymEdgeIt;
75 friend class GraphWrapper<Graph>;
76 // typedef typename Graph::EdgeIt GraphEdgeIt;
77 typename Graph::EdgeIt e;
80 EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
81 EdgeIt(const Invalid& i) : e(i) { }
82 EdgeIt(const GraphWrapper<Graph>& _G) : e(*(_G.graph)) { }
83 operator Edge() const { return Edge(typename Graph::Edge(e)); }
86 NodeIt& first(NodeIt& i) const {
87 i=NodeIt(*this); return i;
89 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
90 i=OutEdgeIt(*this, p); return i;
92 InEdgeIt& first(InEdgeIt& i, const Node& p) const {
93 i=InEdgeIt(*this, p); return i;
95 EdgeIt& first(EdgeIt& i) const {
96 i=EdgeIt(*this); return i;
98 // template<typename I> I& first(I& i) const {
102 // template<typename I, typename P> I& first(I& i, const P& p) const {
107 NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
108 OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
109 InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
110 EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }
111 // template<typename I> I& next(I &i) const { graph->next(i); return i; }
112 template< typename It > It first() const {
113 It e; this->first(e); return e; }
115 template< typename It > It first(const Node& v) const {
116 It e; this->first(e, v); return e; }
118 Node head(const Edge& e) const {
119 return Node(graph->head(static_cast<typename Graph::Edge>(e))); }
120 Node tail(const Edge& e) const {
121 return Node(graph->tail(static_cast<typename Graph::Edge>(e))); }
123 bool valid(const Node& n) const {
124 return graph->valid(static_cast<typename Graph::Node>(n)); }
125 bool valid(const Edge& e) const {
126 return graph->valid(static_cast<typename Graph::Edge>(e)); }
127 // template<typename I> bool valid(const I& i) const {
128 // return graph->valid(i); }
130 //template<typename I> void setInvalid(const I &i);
131 //{ return graph->setInvalid(i); }
133 int nodeNum() const { return graph->nodeNum(); }
134 int edgeNum() const { return graph->edgeNum(); }
136 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
137 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
138 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
139 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
140 // template<typename I> Node aNode(const I& e) const {
141 // return Node(graph->aNode(e.e)); }
142 // template<typename I> Node bNode(const I& e) const {
143 // return Node(graph->bNode(e.e)); }
145 Node addNode() const { return Node(graph->addNode()); }
146 Edge addEdge(const Node& tail, const Node& head) const {
147 return Edge(graph->addEdge(tail, head)); }
149 void erase(const Node& i) const { graph->erase(i); }
150 void erase(const Edge& i) const { graph->erase(i); }
151 // template<typename I> void erase(const I& i) const { graph->erase(i); }
153 void clear() const { graph->clear(); }
155 template<typename T> class NodeMap : public Graph::NodeMap<T> {
157 NodeMap(const GraphWrapper<Graph>& _G) :
158 Graph::NodeMap<T>(*(_G.graph)) { }
159 NodeMap(const GraphWrapper<Graph>& _G, T a) :
160 Graph::NodeMap<T>(*(_G.graph), a) { }
163 template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
165 EdgeMap(const GraphWrapper<Graph>& _G) :
166 Graph::EdgeMap<T>(*(_G.graph)) { }
167 EdgeMap(const GraphWrapper<Graph>& _G, T a) :
168 Graph::EdgeMap<T>(*(_G.graph), a) { }
173 // template<typename Graph>
174 // class RevGraphWrapper
180 // typedef Graph ParentGraph;
182 // typedef typename Graph::Node Node;
183 // typedef typename Graph::NodeIt NodeIt;
185 // typedef typename Graph::Edge Edge;
186 // typedef typename Graph::OutEdgeIt InEdgeIt;
187 // typedef typename Graph::InEdgeIt OutEdgeIt;
188 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
189 // typedef typename Graph::EdgeIt EdgeIt;
191 // //RevGraphWrapper() : graph(0) { }
192 // RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
194 // void setGraph(Graph& _graph) { graph = &_graph; }
195 // Graph& getGraph() const { return (*graph); }
197 // template<typename I> I& first(I& i) const { return graph->first(i); }
198 // template<typename I, typename P> I& first(I& i, const P& p) const {
199 // return graph->first(i, p); }
201 // template<typename I> I& next(I &i) const { return graph->next(i); }
203 // template< typename It > It first() const {
204 // It e; first(e); return e; }
206 // template< typename It > It first(const Node& v) const {
207 // It e; first(e, v); return e; }
209 // Node head(const Edge& e) const { return graph->tail(e); }
210 // Node tail(const Edge& e) const { return graph->head(e); }
212 // template<typename I> bool valid(const I& i) const
213 // { return graph->valid(i); }
215 // //template<typename I> void setInvalid(const I &i);
216 // //{ return graph->setInvalid(i); }
218 // template<typename I> Node aNode(const I& e) const {
219 // return graph->aNode(e); }
220 // template<typename I> Node bNode(const I& e) const {
221 // return graph->bNode(e); }
223 // Node addNode() const { return graph->addNode(); }
224 // Edge addEdge(const Node& tail, const Node& head) const {
225 // return graph->addEdge(tail, head); }
227 // int nodeNum() const { return graph->nodeNum(); }
228 // int edgeNum() const { return graph->edgeNum(); }
230 // template<typename I> void erase(const I& i) const { graph->erase(i); }
232 // void clear() const { graph->clear(); }
234 // template<typename T> class NodeMap : public Graph::NodeMap<T> {
236 // NodeMap(const RevGraphWrapper<Graph>& _G) :
237 // Graph::NodeMap<T>(_G.getGraph()) { }
238 // NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
239 // Graph::NodeMap<T>(_G.getGraph(), a) { }
242 // template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
244 // EdgeMap(const RevGraphWrapper<Graph>& _G) :
245 // Graph::EdgeMap<T>(_G.getGraph()) { }
246 // EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
247 // Graph::EdgeMap<T>(_G.getGraph(), a) { }
252 template<typename Graph>
253 class RevGraphWrapper : public GraphWrapper<Graph> {
255 typedef typename GraphWrapper<Graph>::Node Node;
256 typedef typename GraphWrapper<Graph>::Edge Edge;
258 //If Graph::OutEdgeIt is not defined
259 //and we do not want to use RevGraphWrapper::InEdgeIt,
260 //this won't work, because of typedef
262 //graphs have to define their non-existing iterators to void
263 //Unfortunately all the typedefs are instantiated in templates,
265 typedef typename GraphWrapper<Graph>::OutEdgeIt InEdgeIt;
266 typedef typename GraphWrapper<Graph>::InEdgeIt OutEdgeIt;
268 // RevGraphWrapper() : GraphWrapper<Graph>() { }
269 RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
271 Node head(const Edge& e) const
272 { return GraphWrapper<Graph>::tail(e); }
273 Node tail(const Edge& e) const
274 { return GraphWrapper<Graph>::head(e); }
277 //Subgraph on the same node-set and partial edge-set
278 template<typename Graph, typename NodeFilterMap,
279 typename EdgeFilterMap>
280 class SubGraphWrapper : public GraphWrapper<Graph> {
282 NodeFilterMap* node_filter_map;
283 EdgeFilterMap* edge_filter_map;
285 // SubGraphWrapper() : GraphWrapper<Graph>(), filter_map(0) { }
286 SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map,
287 EdgeFilterMap& _edge_filter_map) :
288 GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map),
289 edge_filter_map(&_edge_filter_map) { }
291 typedef typename GraphWrapper<Graph>::Node Node;
293 friend class GraphWrapper<Graph>;
294 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
295 typename Graph::NodeIt n;
298 NodeIt(const typename Graph::NodeIt& _n) : n(_n) { }
299 NodeIt(const Invalid& i) : n(i) { }
300 NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
302 while (_G.graph->valid(n) && !(*(_G.node_filter_map))[n])
305 operator Node() const { return Node(typename Graph::Node(n)); }
307 // class NodeIt : public Graph::NodeIt {
308 // // typedef typename Graph::NodeIt GraphNodeIt;
311 // NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
312 // NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
313 // NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
314 // Graph::NodeIt(*(_G.graph)) {
315 // while (_G.graph->valid((*this)/*.GraphNodeIt*/) &&
316 // !(*(_G.node_filter_map))[(*this)/*.GraphNodeIt*/])
317 // _G.graph->next((*this)/*.GraphNodeIt*/);
320 typedef typename GraphWrapper<Graph>::Edge Edge;
322 friend class GraphWrapper<Graph>;
323 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
324 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
325 typename Graph::OutEdgeIt e;
328 OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { }
329 OutEdgeIt(const Invalid& i) : e(i) { }
330 OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G,
332 e(*(_G.graph), typename Graph::Node(_n)) {
333 while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e])
336 operator Edge() const { return Edge(typename Graph::Edge(e)); }
339 friend class GraphWrapper<Graph>;
340 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
341 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
342 typename Graph::InEdgeIt e;
345 InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
346 InEdgeIt(const Invalid& i) : e(i) { }
347 InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G,
349 e(*(_G.graph), typename Graph::Node(_n)) {
350 while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e])
353 operator Edge() const { return Edge(typename Graph::Edge(e)); }
355 //typedef typename Graph::SymEdgeIt SymEdgeIt;
357 friend class GraphWrapper<Graph>;
358 friend class SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>;
359 // typedef typename Graph::EdgeIt GraphEdgeIt;
360 typename Graph::EdgeIt e;
363 EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
364 EdgeIt(const Invalid& i) : e(i) { }
365 EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
367 while (_G.graph->valid(e) && !(*(_G.edge_filter_map))[e])
370 operator Edge() const { return Edge(typename Graph::Edge(e)); }
372 // operator Edge() const { return Edge(typename Graph::Edge(e)); }
374 // class OutEdgeIt : public Graph::OutEdgeIt {
375 // // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
378 // OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
379 // OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
380 // OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>&
381 // _G, const Node& n) :
382 // Graph::OutEdgeIt(*(_G.graph), n) {
383 // while (_G.graph->valid((*this)/*.GraphOutEdgeIt*/) &&
384 // !(*(_G.edge_filter_map))[(*this)/*.GraphOutEdgeIt*/])
385 // _G.graph->next((*this)/*.GraphOutEdgeIt*/);
388 // class InEdgeIt : public Graph::InEdgeIt {
389 // // typedef typename Graph::InEdgeIt GraphInEdgeIt;
392 // InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
393 // InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
394 // InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G,
396 // Graph::InEdgeIt(*(_G.graph), n) {
397 // while (_G.graph->valid((*this)/*.GraphInEdgeIt*/) &&
398 // !(*(_G.edge_filter_map))[(*this)/*.GraphInEdgeIt*/])
399 // _G.graph->next((*this)/*.GraphInEdgeIt*/);
402 // // //typedef typename Graph::SymEdgeIt SymEdgeIt;
403 // class EdgeIt : public Graph::EdgeIt {
404 // // typedef typename Graph::EdgeIt GraphEdgeIt;
407 // EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
408 // EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
409 // EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
410 // Graph::EdgeIt(*(_G.graph)) {
411 // while (_G.graph->valid((*this)/*.GraphEdgeIt*/) &&
412 // !(*(_G.edge_filter_map))[(*this)/*.GraphEdgeIt*/])
413 // _G.graph->next((*this)/*.GraphEdgeIt*/);
418 NodeIt& first(NodeIt& i) const {
419 i=NodeIt(*this); return i;
421 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
422 i=OutEdgeIt(*this, p); return i;
424 InEdgeIt& first(InEdgeIt& i, const Node& p) const {
425 i=InEdgeIt(*this, p); return i;
427 EdgeIt& first(EdgeIt& i) const {
428 i=EdgeIt(*this); return i;
431 // template<typename I> I& first(I& i) const {
433 // //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
434 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
437 // template<typename I, typename P> I& first(I& i, const P& p) const {
438 // graph->first(i, p);
439 // // while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
440 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
444 NodeIt& next(NodeIt& i) const {
446 while (graph->valid(i) && !(*node_filter_map)[i.n]) { graph->next(i.n); }
449 OutEdgeIt& next(OutEdgeIt& i) const {
451 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
454 InEdgeIt& next(InEdgeIt& i) const {
456 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
459 EdgeIt& next(EdgeIt& i) const {
461 while (graph->valid(i) && !(*edge_filter_map)[i.e]) { graph->next(i.e); }
466 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
467 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
468 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
469 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
471 // template<typename I> I& next(I &i) const {
473 // // while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
474 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
478 template< typename It > It first() const {
479 It e; this->first(e); return e; }
481 template< typename It > It first(const Node& v) const {
482 It e; this->first(e, v); return e; }
485 // //Subgraph on the same node-set and partial edge-set
486 // template<typename Graph, typename NodeFilterMap,
487 // typename EdgeFilterMap>
488 // class SubGraphWrapper : public GraphWrapper<Graph> {
490 // NodeFilterMap* node_filter_map;
491 // EdgeFilterMap* edge_filter_map;
493 // // SubGraphWrapper() : GraphWrapper<Graph>(), filter_map(0) { }
494 // SubGraphWrapper(Graph& _graph, NodeFilterMap& _node_filter_map,
495 // EdgeFilterMap& _edge_filter_map) :
496 // GraphWrapper<Graph>(_graph), node_filter_map(&_node_filter_map),
497 // edge_filter_map(&_edge_filter_map) { }
500 // typedef typename Graph::Node Node;
501 // class NodeIt : public Graph::NodeIt {
502 // // typedef typename Graph::NodeIt GraphNodeIt;
505 // NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
506 // NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
507 // NodeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
508 // Graph::NodeIt(*(_G.graph)) {
509 // while (_G.graph->valid((*this)/*.GraphNodeIt*/) &&
510 // !(*(_G.node_filter_map))[(*this)/*.GraphNodeIt*/])
511 // _G.graph->next((*this)/*.GraphNodeIt*/);
514 // typedef typename Graph::Edge Edge;
515 // class OutEdgeIt : public Graph::OutEdgeIt {
516 // // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
519 // OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
520 // OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
521 // OutEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>&
522 // _G, const Node& n) :
523 // Graph::OutEdgeIt(*(_G.graph), n) {
524 // while (_G.graph->valid((*this)/*.GraphOutEdgeIt*/) &&
525 // !(*(_G.edge_filter_map))[(*this)/*.GraphOutEdgeIt*/])
526 // _G.graph->next((*this)/*.GraphOutEdgeIt*/);
529 // class InEdgeIt : public Graph::InEdgeIt {
530 // // typedef typename Graph::InEdgeIt GraphInEdgeIt;
533 // InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
534 // InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
535 // InEdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G,
537 // Graph::InEdgeIt(*(_G.graph), n) {
538 // while (_G.graph->valid((*this)/*.GraphInEdgeIt*/) &&
539 // !(*(_G.edge_filter_map))[(*this)/*.GraphInEdgeIt*/])
540 // _G.graph->next((*this)/*.GraphInEdgeIt*/);
543 // // //typedef typename Graph::SymEdgeIt SymEdgeIt;
544 // class EdgeIt : public Graph::EdgeIt {
545 // // typedef typename Graph::EdgeIt GraphEdgeIt;
548 // EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
549 // EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
550 // EdgeIt(const SubGraphWrapper<Graph, NodeFilterMap, EdgeFilterMap>& _G) :
551 // Graph::EdgeIt(*(_G.graph)) {
552 // while (_G.graph->valid((*this)/*.GraphEdgeIt*/) &&
553 // !(*(_G.edge_filter_map))[(*this)/*.GraphEdgeIt*/])
554 // _G.graph->next((*this)/*.GraphEdgeIt*/);
558 // NodeIt& first(NodeIt& i) const {
562 // OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
563 // i=OutEdgeIt(*this, n);
566 // InEdgeIt& first(InEdgeIt& i, const Node& n) const {
567 // i=InEdgeIt(*this, n);
570 // EdgeIt& first(EdgeIt& i) const {
575 // // template<typename I> I& first(I& i) const {
576 // // graph->first(i);
577 // // //while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
578 // // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
581 // // template<typename I, typename P> I& first(I& i, const P& p) const {
582 // // graph->first(i, p);
583 // // // while (graph->valid(i) && !filter_map->get(i)) { graph->next(i); }
584 // // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
588 // NodeIt& next(NodeIt& i) const {
590 // while (graph->valid(i) && !(*node_filter_map)[i]) { graph->next(i); }
593 // OutEdgeIt& next(OutEdgeIt& i) const {
595 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
598 // InEdgeIt& next(InEdgeIt& i) const {
600 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
603 // EdgeIt& next(EdgeIt& i) const {
605 // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
609 // // template<typename I> I& next(I &i) const {
610 // // graph->next(i);
611 // // // while (graph->valid(i) && !filter_map-get(i)) { graph->next(i); }
612 // // while (graph->valid(i) && !(*edge_filter_map)[i]) { graph->next(i); }
616 // template< typename It > It first() const {
617 // It e; this->first(e); return e; }
619 // template< typename It > It first(const Node& v) const {
620 // It e; this->first(e, v); return e; }
623 template<typename Graph>
624 class UndirGraphWrapper : public GraphWrapper<Graph> {
626 // typedef typename Graph::Edge GraphEdge;
627 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
628 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
630 typedef typename GraphWrapper<Graph>::Node Node;
631 typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
632 typedef typename GraphWrapper<Graph>::Edge Edge;
633 typedef typename GraphWrapper<Graph>::EdgeIt EdgeIt;
635 // UndirGraphWrapper() : GraphWrapper<Graph>() { }
636 UndirGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }
640 // friend class UndirGraphWrapper<Graph>;
642 // bool out_or_in; //true iff out
643 // GraphOutEdgeIt out;
646 // Edge() : out_or_in(), out(), in() { }
647 // Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
648 // operator GraphEdge() const {
649 // if (out_or_in) return(out); else return(in);
652 // //2 edges are equal if they "refer" to the same physical edge
654 // friend bool operator==(const Edge& u, const Edge& v) {
656 // if (u.out_or_in) return (u.out==v.out); else return (u.out==v.in);
657 // //return (u.out_or_in && u.out==v.out);
659 // if (u.out_or_in) return (u.out==v.in); else return (u.in==v.in);
660 // //return (!u.out_or_in && u.in==v.in);
662 // friend bool operator!=(const Edge& u, const Edge& v) {
664 // if (u.out_or_in) return (u.out!=v.out); else return (u.out!=v.in);
665 // //return (!u.out_or_in || u.out!=v.out);
667 // if (u.out_or_in) return (u.out!=v.in); else return (u.in!=v.in);
668 // //return (u.out_or_in || u.in!=v.in);
673 friend class UndirGraphWrapper<Graph>;
674 bool out_or_in; //true iff out
675 typename Graph::OutEdgeIt out;
676 typename Graph::InEdgeIt in;
679 OutEdgeIt(const Invalid& i) : Edge(i) { }
680 OutEdgeIt(const UndirGraphWrapper<Graph>& _G, const Node& _n) {
681 out_or_in=true; _G.graph->first(out, _n);
682 if (!(_G.graph->valid(out))) { out_or_in=false; _G.graph->first(in, _n); }
684 operator Edge() const {
685 if (out_or_in) return Edge(out); else return Edge(in);
688 // class OutEdgeIt : public Edge {
689 // friend class UndirGraphWrapper<Graph>;
691 // OutEdgeIt() : Edge() { }
692 // OutEdgeIt(const Invalid& i) : Edge(i) { }
693 // OutEdgeIt(const UndirGraphWrapper<Graph>& _G, const Node& n)
695 // out_or_in=true; _G.graph->first(out, n);
696 // if (!(_G.graph->valid(out))) { out_or_in=false; _G.graph->first(in, n); }
701 typedef OutEdgeIt InEdgeIt;
703 // class EdgeIt : public Edge {
704 // friend class UndirGraphWrapper<Graph>;
708 // EdgeIt() : Edge() { }
709 // EdgeIt(const Invalid& i) : Edge(i) { }
710 // EdgeIt(const UndirGraphWrapper<Graph>& _G)
715 // if (_G.valid(v)) _G.graph->first(out); else out=INVALID;
716 // while (_G.valid(v) && !_G.graph->valid(out)) {
717 // _G.graph->next(v);
718 // if (_G.valid(v)) _G.graph->first(out);
723 NodeIt& first(NodeIt& i) const {
724 i=NodeIt(*this); return i;
726 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
727 i=OutEdgeIt(*this, p); return i;
730 // InEdgeIt& first(InEdgeIt& i, const Node& p) const {
731 // i=InEdgeIt(*this, p); return i;
733 EdgeIt& first(EdgeIt& i) const {
734 i=EdgeIt(*this); return i;
737 template<typename I> I& first(I& i) const { graph->first(i); return i; }
738 template<typename I, typename P> I& first(I& i, const P& p) const {
739 graph->first(i, p); return i; }
741 NodeIt& next(NodeIt& n) const {
742 GraphWrapper<Graph>::next(n);
745 OutEdgeIt& next(OutEdgeIt& e) const {
747 typename Graph::Node n=graph->tail(e.out);
749 if (!graph->valid(e.out)) { e.out_or_in=false; graph->first(e.in, n); }
756 EdgeIt& next(EdgeIt& e) const {
757 GraphWrapper<Graph>::next(n);
762 // template<typename I> I& next(I &i) const { graph->next(i); return i; }
763 template< typename It > It first() const {
764 It e; this->first(e); return e; }
766 template< typename It > It first(const Node& v) const {
767 It e; this->first(e, v); return e; }
769 // Node head(const Edge& e) const { return gw.head(e); }
770 // Node tail(const Edge& e) const { return gw.tail(e); }
772 // template<typename I> bool valid(const I& i) const
773 // { return gw.valid(i); }
775 // int nodeNum() const { return gw.nodeNum(); }
776 // int edgeNum() const { return gw.edgeNum(); }
778 // template<typename I> Node aNode(const I& e) const {
779 // return graph->aNode(e); }
780 // template<typename I> Node bNode(const I& e) const {
781 // return graph->bNode(e); }
783 Node aNode(const OutEdgeIt& e) const {
784 if (e.out_or_in) return graph->tail(e); else return graph->head(e); }
785 Node bNode(const OutEdgeIt& e) const {
786 if (e.out_or_in) return graph->head(e); else return graph->tail(e); }
788 // Node addNode() const { return gw.addNode(); }
790 // FIXME: ez igy nem jo, mert nem
791 // Edge addEdge(const Node& tail, const Node& head) const {
792 // return graph->addEdge(tail, head); }
794 // template<typename I> void erase(const I& i) const { gw.erase(i); }
796 // void clear() const { gw.clear(); }
798 // template<typename T> class NodeMap : public Graph::NodeMap<T> {
800 // NodeMap(const UndirGraphWrapper<Graph>& _G) :
801 // Graph::NodeMap<T>(_G.gw) { }
802 // NodeMap(const UndirGraphWrapper<Graph>& _G, T a) :
803 // Graph::NodeMap<T>(_G.gw, a) { }
806 // template<typename T> class EdgeMap :
807 // public GraphWrapperSkeleton<Graph>::EdgeMap<T> {
809 // EdgeMap(const UndirGraphWrapper<Graph>& _G) :
810 // GraphWrapperSkeleton<Graph>::EdgeMap<T>(_G.gw) { }
811 // EdgeMap(const UndirGraphWrapper<Graph>& _G, T a) :
812 // Graph::EdgeMap<T>(_G.gw, a) { }
820 // template<typename Graph>
821 // class SymGraphWrapper
826 // typedef Graph ParentGraph;
828 // typedef typename Graph::Node Node;
829 // typedef typename Graph::Edge Edge;
831 // typedef typename Graph::NodeIt NodeIt;
833 // //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
834 // //iranyitatlant, ami van
835 // //mert csak 1 dolgot lehet be typedef-elni
836 // typedef typename Graph::OutEdgeIt SymEdgeIt;
837 // //typedef typename Graph::InEdgeIt SymEdgeIt;
838 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
839 // typedef typename Graph::EdgeIt EdgeIt;
841 // int nodeNum() const { return graph->nodeNum(); }
842 // int edgeNum() const { return graph->edgeNum(); }
844 // template<typename I> I& first(I& i) const { return graph->first(i); }
845 // template<typename I, typename P> I& first(I& i, const P& p) const {
846 // return graph->first(i, p); }
847 // //template<typename I> I next(const I i); { return graph->goNext(i); }
848 // //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
850 // template< typename It > It first() const {
851 // It e; first(e); return e; }
853 // template< typename It > It first(Node v) const {
854 // It e; first(e, v); return e; }
856 // Node head(const Edge& e) const { return graph->head(e); }
857 // Node tail(const Edge& e) const { return graph->tail(e); }
859 // template<typename I> Node aNode(const I& e) const {
860 // return graph->aNode(e); }
861 // template<typename I> Node bNode(const I& e) const {
862 // return graph->bNode(e); }
864 // //template<typename I> bool valid(const I i);
865 // //{ return graph->valid(i); }
867 // //template<typename I> void setInvalid(const I &i);
868 // //{ return graph->setInvalid(i); }
870 // Node addNode() { return graph->addNode(); }
871 // Edge addEdge(const Node& tail, const Node& head) {
872 // return graph->addEdge(tail, head); }
874 // template<typename I> void erase(const I& i) { graph->erase(i); }
876 // void clear() { graph->clear(); }
878 // template<typename T> class NodeMap : public Graph::NodeMap<T> { };
879 // template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
881 // void setGraph(Graph& _graph) { graph = &_graph; }
882 // Graph& getGraph() { return (*graph); }
884 // //SymGraphWrapper() : graph(0) { }
885 // SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
891 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
892 class ResGraphWrapper : public GraphWrapper<Graph> {
894 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
895 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
896 // typedef typename Graph::Edge GraphEdge;
898 const CapacityMap* capacity;
901 ResGraphWrapper(Graph& _graph, FlowMap& _flow,
902 const CapacityMap& _capacity) :
903 GraphWrapper<Graph>(_graph), flow(&_flow), capacity(&_capacity) { }
908 friend class OutEdgeIt;
910 typedef typename GraphWrapper<Graph>::Node Node;
911 typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
912 class Edge : public Graph::Edge {
913 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
915 bool forward; //true, iff forward
916 // typename Graph::Edge e;
919 Edge(const typename Graph::Edge& _e, bool _forward) :
920 Graph::Edge(_e), forward(_forward) { }
921 Edge(const Invalid& i) : Graph::Edge(i), forward(false) { }
922 //the unique invalid iterator
923 friend bool operator==(const Edge& u, const Edge& v) {
924 return (v.forward==u.forward &&
925 static_cast<typename Graph::Edge>(u)==
926 static_cast<typename Graph::Edge>(v));
928 friend bool operator!=(const Edge& u, const Edge& v) {
929 return (v.forward!=u.forward ||
930 static_cast<typename Graph::Edge>(u)!=
931 static_cast<typename Graph::Edge>(v));
935 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
937 // bool out_or_in; //true, iff out
938 // GraphOutEdgeIt out;
941 // Edge() : out_or_in(true) { }
942 // Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
943 // // bool valid() const {
944 // // return out_or_in && out.valid() || in.valid(); }
945 // friend bool operator==(const Edge& u, const Edge& v) {
947 // return (u.out_or_in && u.out==v.out);
949 // return (!u.out_or_in && u.in==v.in);
951 // friend bool operator!=(const Edge& u, const Edge& v) {
953 // return (!u.out_or_in || u.out!=v.out);
955 // return (u.out_or_in || u.in!=v.in);
957 // operator GraphEdge() const {
958 // if (out_or_in) return(out); else return(in);
962 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
964 typename Graph::OutEdgeIt out;
965 typename Graph::InEdgeIt in;
970 // OutEdgeIt(const Edge& e) : Edge(e) { }
971 OutEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { }
972 //the unique invalid iterator
973 OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) {
975 resG.graph->first(out, v);
976 while( resG.graph->valid(out) && !(resG.resCap(*this)>0) ) { resG.graph->next(out); }
977 if (!resG.graph->valid(out)) {
979 resG.graph->first(in, v);
980 while( resG.graph->valid(in) && !(resG.resCap(*this)>0) ) { resG.graph->next(in); }
983 operator Edge() const {
985 // e.forward=this->forward;
986 // if (this->forward) e=out; else e=in;
989 return Edge(out, this->forward);
991 return Edge(in, this->forward);
994 // class OutEdgeIt : public Edge {
995 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
999 // OutEdgeIt(const Edge& e) : Edge(e) { }
1000 // OutEdgeIt(const Invalid& i) : Edge(i) { }
1001 // OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
1002 // resG.graph->first(out, v);
1003 // while( resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1004 // if (!resG.graph->valid(out)) {
1006 // resG.graph->first(in, v);
1007 // while( resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1011 // OutEdgeIt& operator++() {
1013 // Node v=/*resG->*/G->aNode(out);
1015 // while( out.valid() && !(Edge::resCap()>0) ) { ++out; }
1016 // if (!out.valid()) {
1019 // while( in.valid() && !(Edge::resCap()>0) ) { ++in; }
1023 // while( in.valid() && !(Edge::resCap()>0) ) { ++in; }
1029 //FIXME This is just for having InEdgeIt
1030 // class InEdgeIt : public Edge { };
1033 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1035 typename Graph::OutEdgeIt out;
1036 typename Graph::InEdgeIt in;
1041 // OutEdgeIt(const Edge& e) : Edge(e) { }
1042 InEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { }
1043 //the unique invalid iterator
1044 InEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) {
1046 resG.graph->first(in, v);
1047 while( resG.graph->valid(in) && !(resG.resCap(*this)>0) ) { resG.graph->next(in); }
1048 if (!resG.graph->valid(in)) {
1050 resG.graph->first(out, v);
1051 while( resG.graph->valid(out) && !(resG.resCap(*this)>0) ) { resG.graph->next(out); }
1054 operator Edge() const {
1056 // e.forward=this->forward;
1057 // if (this->forward) e=out; else e=in;
1060 return Edge(in, this->forward);
1062 return Edge(out, this->forward);
1067 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1069 typename Graph::EdgeIt e;
1073 EdgeIt(const Invalid& i) : e(i), forward(false) { }
1074 EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) {
1076 resG.graph->first(e);
1077 while (resG.graph->valid(e) && !(resG.resCap(*this)>0)) resG.graph->next(e);
1078 if (!resG.graph->valid(e)) {
1080 resG.graph->first(e);
1081 while (resG.graph->valid(e) && !(resG.resCap(*this)>0)) resG.graph->next(e);
1084 operator Edge() const {
1085 return Edge(e, this->forward);
1088 // class EdgeIt : public Edge {
1089 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1093 // //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
1094 // EdgeIt(const Invalid& i) : Edge(i) { }
1095 // EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
1096 // resG.graph->first(v);
1097 // if (resG.graph->valid(v)) resG.graph->first(out, v); else out=INVALID;
1098 // while (resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1099 // while (resG.graph->valid(v) && !resG.graph->valid(out)) {
1100 // resG.graph->next(v);
1101 // if (resG.graph->valid(v)) resG.graph->first(out, v);
1102 // while (resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1104 // if (!resG.graph->valid(out)) {
1106 // resG.graph->first(v);
1107 // if (resG.graph->valid(v)) resG.graph->first(in, v); else in=INVALID;
1108 // while (resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1109 // while (resG.graph->valid(v) && !resG.graph->valid(in)) {
1110 // resG.graph->next(v);
1111 // if (resG.graph->valid(v)) resG.graph->first(in, v);
1112 // while (resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1116 // EdgeIt& operator++() {
1119 // while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
1120 // while (v.valid() && !out.valid()) {
1122 // if (v.valid()) G->first(out, v);
1123 // while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
1125 // if (!out.valid()) {
1128 // if (v.valid()) G->first(in, v); else in=GraphInEdgeIt();
1129 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1130 // while (v.valid() && !in.valid()) {
1132 // if (v.valid()) G->first(in, v);
1133 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1138 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1139 // while (v.valid() && !in.valid()) {
1141 // if (v.valid()) G->first(in, v);
1142 // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1149 NodeIt& first(NodeIt& i) const {
1150 i=NodeIt(*this); return i;
1152 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
1153 i=OutEdgeIt(*this, p); return i;
1156 InEdgeIt& first(InEdgeIt& i, const Node& p) const {
1157 i=InEdgeIt(*this, p); return i;
1159 EdgeIt& first(EdgeIt& i) const {
1160 i=EdgeIt(*this); return i;
1163 NodeIt& next(NodeIt& n) const { GraphWrapper<Graph>::next(n); return n; }
1164 OutEdgeIt& next(OutEdgeIt& e) const {
1166 Node v=graph->aNode(e.out);
1168 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
1169 if (!graph->valid(e.out)) {
1171 graph->first(e.in, v);
1172 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
1176 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
1181 InEdgeIt& next(InEdgeIt& e) const {
1183 Node v=graph->aNode(e.in);
1185 while( graph->valid(e.in) && !(resCap(e)>0) ) { graph->next(e.in); }
1186 if (!graph->valid(e.in)) {
1188 graph->first(e.out, v);
1189 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
1193 while( graph->valid(e.out) && !(resCap(e)>0) ) { graph->next(e.out); }
1197 EdgeIt& next(EdgeIt& e) const {
1200 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
1201 if (!graph->valid(e.e)) {
1204 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
1208 while( graph->valid(e.e) && !(resCap(e)>0) ) { graph->next(e.e); }
1212 // EdgeIt& next(EdgeIt& e) const {
1213 // if (e.out_or_in) {
1214 // graph->next(e.out);
1215 // while (graph->valid(e.out) && !(resCap(e.out)>0) ) { graph->next(e.out); }
1216 // while (graph->valid(e.v) && !graph->valid(e.out)) {
1217 // graph->next(e.v);
1218 // if (graph->valid(e.v)) graph->first(e.out, e.v);
1219 // while (graph->valid(e.out) && !(resCap(e.out)>0) ) { graph->next(e.out); }
1221 // if (!graph->valid(e.out)) {
1223 // graph->first(e.v);
1224 // if (graph->valid(e.v)) graph->first(e.in, e.v); else e.in=INVALID;
1225 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1226 // while (graph->valid(e.v) && !graph->valid(e.in)) {
1227 // graph->next(e.v);
1228 // if (graph->valid(e.v)) graph->first(e.in, e.v);
1229 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1233 // graph->next(e.in);
1234 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1235 // while (graph->valid(e.v) && !graph->valid(e.in)) {
1236 // graph->next(e.v);
1237 // if (graph->valid(e.v)) graph->first(e.in, e.v);
1238 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1245 template< typename It >
1252 template< typename It >
1253 It first(Node v) const {
1259 Node tail(Edge e) const {
1260 return ((e.forward) ? graph->tail(e) : graph->head(e)); }
1261 Node head(Edge e) const {
1262 return ((e.forward) ? graph->head(e) : graph->tail(e)); }
1264 Node aNode(OutEdgeIt e) const {
1265 return ((e.forward) ? graph->aNode(e.out) : graph->aNode(e.in)); }
1266 Node bNode(OutEdgeIt e) const {
1267 return ((e.forward) ? graph->bNode(e.out) : graph->bNode(e.in)); }
1269 int nodeNum() const { return graph->nodeNum(); }
1271 //int edgeNum() const { return graph->edgeNum(); }
1274 // int id(Node v) const { return graph->id(v); }
1276 bool valid(Node n) const { return GraphWrapper<Graph>::valid(n); }
1277 bool valid(Edge e) const {
1278 return graph->valid(e);
1279 //return e.forward ? graph->valid(e.out) : graph->valid(e.in);
1282 void augment(const Edge& e, Number a) const {
1284 // flow->set(e.out, flow->get(e.out)+a);
1285 flow->set(e, (*flow)[e]+a);
1287 // flow->set(e.in, flow->get(e.in)-a);
1288 flow->set(e, (*flow)[e]-a);
1291 Number resCap(const Edge& e) const {
1293 // return (capacity->get(e.out)-flow->get(e.out));
1294 return ((*capacity)[e]-(*flow)[e]);
1296 // return (flow->get(e.in));
1297 return ((*flow)[e]);
1300 // Number resCap(typename Graph::OutEdgeIt out) const {
1301 // // return (capacity->get(out)-flow->get(out));
1302 // return ((*capacity)[out]-(*flow)[out]);
1305 // Number resCap(typename Graph::InEdgeIt in) const {
1306 // // return (flow->get(in));
1307 // return ((*flow)[in]);
1310 // template<typename T> class NodeMap : public Graph::NodeMap<T> {
1312 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
1313 // : Graph::NodeMap<T>(_G.gw) { }
1314 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
1315 // T a) : Graph::NodeMap<T>(_G.gw, a) { }
1318 // template <typename T>
1320 // typename Graph::NodeMap<T> node_map;
1322 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
1323 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
1324 // void set(Node nit, T a) { node_map.set(nit, a); }
1325 // T get(Node nit) const { return node_map.get(nit); }
1328 template <typename T>
1330 typename Graph::EdgeMap<T> forward_map, backward_map;
1332 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { }
1333 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { }
1334 void set(Edge e, T a) {
1336 forward_map.set(e.out, a);
1338 backward_map.set(e.in, a);
1340 T operator[](Edge e) const {
1342 return forward_map[e.out];
1344 return backward_map[e.in];
1346 // T get(Edge e) const {
1348 // return forward_map.get(e.out);
1350 // return backward_map.get(e.in);
1357 // template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
1358 // class ResGraphWrapper : public GraphWrapper<Graph> {
1360 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
1361 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
1362 // typedef typename Graph::Edge GraphEdge;
1364 // const CapacityMap* capacity;
1367 // ResGraphWrapper(Graph& _graph, FlowMap& _flow,
1368 // const CapacityMap& _capacity) :
1369 // GraphWrapper<Graph>(_graph), flow(&_flow), capacity(&_capacity) { }
1373 // friend class Edge;
1374 // friend class OutEdgeIt;
1376 // typedef typename GraphWrapper<Graph>::Node Node;
1377 // typedef typename GraphWrapper<Graph>::NodeIt NodeIt;
1379 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1381 // bool out_or_in; //true, iff out
1382 // GraphOutEdgeIt out;
1383 // GraphInEdgeIt in;
1385 // Edge() : out_or_in(true) { }
1386 // Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
1387 // // bool valid() const {
1388 // // return out_or_in && out.valid() || in.valid(); }
1389 // friend bool operator==(const Edge& u, const Edge& v) {
1391 // return (u.out_or_in && u.out==v.out);
1393 // return (!u.out_or_in && u.in==v.in);
1395 // friend bool operator!=(const Edge& u, const Edge& v) {
1397 // return (!u.out_or_in || u.out!=v.out);
1399 // return (u.out_or_in || u.in!=v.in);
1401 // operator GraphEdge() const {
1402 // if (out_or_in) return(out); else return(in);
1405 // class OutEdgeIt : public Edge {
1406 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1410 // OutEdgeIt(const Edge& e) : Edge(e) { }
1411 // OutEdgeIt(const Invalid& i) : Edge(i) { }
1412 // OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
1413 // resG.graph->first(out, v);
1414 // while( resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1415 // if (!resG.graph->valid(out)) {
1417 // resG.graph->first(in, v);
1418 // while( resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1422 // // OutEdgeIt& operator++() {
1423 // // if (out_or_in) {
1424 // // Node v=/*resG->*/G->aNode(out);
1426 // // while( out.valid() && !(Edge::resCap()>0) ) { ++out; }
1427 // // if (!out.valid()) {
1429 // // G->first(in, v);
1430 // // while( in.valid() && !(Edge::resCap()>0) ) { ++in; }
1434 // // while( in.valid() && !(Edge::resCap()>0) ) { ++in; }
1440 // //FIXME This is just for having InEdgeIt
1441 // // class InEdgeIt : public Edge { };
1443 // class EdgeIt : public Edge {
1444 // friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
1448 // //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
1449 // EdgeIt(const Invalid& i) : Edge(i) { }
1450 // EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
1451 // resG.graph->first(v);
1452 // if (resG.graph->valid(v)) resG.graph->first(out, v); else out=INVALID;
1453 // while (resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1454 // while (resG.graph->valid(v) && !resG.graph->valid(out)) {
1455 // resG.graph->next(v);
1456 // if (resG.graph->valid(v)) resG.graph->first(out, v);
1457 // while (resG.graph->valid(out) && !(resG.resCap(out)>0) ) { resG.graph->next(out); }
1459 // if (!resG.graph->valid(out)) {
1461 // resG.graph->first(v);
1462 // if (resG.graph->valid(v)) resG.graph->first(in, v); else in=INVALID;
1463 // while (resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1464 // while (resG.graph->valid(v) && !resG.graph->valid(in)) {
1465 // resG.graph->next(v);
1466 // if (resG.graph->valid(v)) resG.graph->first(in, v);
1467 // while (resG.graph->valid(in) && !(resG.resCap(in)>0) ) { resG.graph->next(in); }
1471 // // EdgeIt& operator++() {
1472 // // if (out_or_in) {
1474 // // while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
1475 // // while (v.valid() && !out.valid()) {
1477 // // if (v.valid()) G->first(out, v);
1478 // // while (out.valid() && !(Edge::resCap()>0) ) { ++out; }
1480 // // if (!out.valid()) {
1483 // // if (v.valid()) G->first(in, v); else in=GraphInEdgeIt();
1484 // // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1485 // // while (v.valid() && !in.valid()) {
1487 // // if (v.valid()) G->first(in, v);
1488 // // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1493 // // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1494 // // while (v.valid() && !in.valid()) {
1496 // // if (v.valid()) G->first(in, v);
1497 // // while (in.valid() && !(Edge::resCap()>0) ) { ++in; }
1504 // NodeIt& first(NodeIt& i) const {
1508 // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
1509 // i=OutEdgeIt(*this, p);
1512 // //FIXME Not yet implemented
1513 // //InEdgeIt& first(InEdgeIt& i, const Node& p) const {
1514 // //i=InEdgeIt(*this, p);
1517 // EdgeIt& first(EdgeIt& e) const {
1522 // NodeIt& next(NodeIt& n) const { graph->next(n); return n; }
1523 // OutEdgeIt& next(OutEdgeIt& e) const {
1524 // if (e.out_or_in) {
1525 // Node v=graph->aNode(e.out);
1526 // graph->next(e.out);
1527 // while( graph->valid(e.out) && !(resCap(e.out)>0) ) { graph->next(e.out); }
1528 // if (!graph->valid(e.out)) {
1530 // graph->first(e.in, v);
1531 // while( graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1534 // graph->next(e.in);
1535 // while( graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1539 // //FIXME Not yet implemented
1540 // //InEdgeIt& next(InEdgeIt& e) const {
1543 // EdgeIt& next(EdgeIt& e) const {
1544 // if (e.out_or_in) {
1545 // graph->next(e.out);
1546 // while (graph->valid(e.out) && !(resCap(e.out)>0) ) { graph->next(e.out); }
1547 // while (graph->valid(e.v) && !graph->valid(e.out)) {
1548 // graph->next(e.v);
1549 // if (graph->valid(e.v)) graph->first(e.out, e.v);
1550 // while (graph->valid(e.out) && !(resCap(e.out)>0) ) { graph->next(e.out); }
1552 // if (!graph->valid(e.out)) {
1554 // graph->first(e.v);
1555 // if (graph->valid(e.v)) graph->first(e.in, e.v); else e.in=INVALID;
1556 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1557 // while (graph->valid(e.v) && !graph->valid(e.in)) {
1558 // graph->next(e.v);
1559 // if (graph->valid(e.v)) graph->first(e.in, e.v);
1560 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1564 // graph->next(e.in);
1565 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1566 // while (graph->valid(e.v) && !graph->valid(e.in)) {
1567 // graph->next(e.v);
1568 // if (graph->valid(e.v)) graph->first(e.in, e.v);
1569 // while (graph->valid(e.in) && !(resCap(e.in)>0) ) { graph->next(e.in); }
1576 // template< typename It >
1577 // It first() const {
1583 // template< typename It >
1584 // It first(Node v) const {
1590 // Node tail(Edge e) const {
1591 // return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); }
1592 // Node head(Edge e) const {
1593 // return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); }
1595 // Node aNode(OutEdgeIt e) const {
1596 // return ((e.out_or_in) ? graph->aNode(e.out) : graph->aNode(e.in)); }
1597 // Node bNode(OutEdgeIt e) const {
1598 // return ((e.out_or_in) ? graph->bNode(e.out) : graph->bNode(e.in)); }
1600 // int nodeNum() const { return graph->nodeNum(); }
1602 // //int edgeNum() const { return graph->edgeNum(); }
1605 // int id(Node v) const { return graph->id(v); }
1607 // bool valid(Node n) const { return graph->valid(n); }
1608 // bool valid(Edge e) const {
1609 // return e.out_or_in ? graph->valid(e.out) : graph->valid(e.in); }
1611 // void augment(const Edge& e, Number a) const {
1613 // // flow->set(e.out, flow->get(e.out)+a);
1614 // flow->set(e.out, (*flow)[e.out]+a);
1616 // // flow->set(e.in, flow->get(e.in)-a);
1617 // flow->set(e.in, (*flow)[e.in]-a);
1620 // Number resCap(const Edge& e) const {
1622 // // return (capacity->get(e.out)-flow->get(e.out));
1623 // return ((*capacity)[e.out]-(*flow)[e.out]);
1625 // // return (flow->get(e.in));
1626 // return ((*flow)[e.in]);
1629 // Number resCap(GraphOutEdgeIt out) const {
1630 // // return (capacity->get(out)-flow->get(out));
1631 // return ((*capacity)[out]-(*flow)[out]);
1634 // Number resCap(GraphInEdgeIt in) const {
1635 // // return (flow->get(in));
1636 // return ((*flow)[in]);
1639 // // template<typename T> class NodeMap : public Graph::NodeMap<T> {
1641 // // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
1642 // // : Graph::NodeMap<T>(_G.gw) { }
1643 // // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
1644 // // T a) : Graph::NodeMap<T>(_G.gw, a) { }
1647 // // template <typename T>
1648 // // class NodeMap {
1649 // // typename Graph::NodeMap<T> node_map;
1651 // // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
1652 // // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
1653 // // void set(Node nit, T a) { node_map.set(nit, a); }
1654 // // T get(Node nit) const { return node_map.get(nit); }
1657 // template <typename T>
1659 // typename Graph::EdgeMap<T> forward_map, backward_map;
1661 // EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { }
1662 // EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { }
1663 // void set(Edge e, T a) {
1665 // forward_map.set(e.out, a);
1667 // backward_map.set(e.in, a);
1669 // T operator[](Edge e) const {
1671 // return forward_map[e.out];
1673 // return backward_map[e.in];
1675 // // T get(Edge e) const {
1676 // // if (e.out_or_in)
1677 // // return forward_map.get(e.out);
1679 // // return backward_map.get(e.in);
1685 //ErasingFirstGraphWrapper for blocking flows
1686 template<typename Graph, typename FirstOutEdgesMap>
1687 class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
1689 FirstOutEdgesMap* first_out_edges;
1691 ErasingFirstGraphWrapper(Graph& _graph,
1692 FirstOutEdgesMap& _first_out_edges) :
1693 GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }
1695 typedef typename GraphWrapper<Graph>::Node Node;
1697 friend class GraphWrapper<Graph>;
1698 friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
1699 typename Graph::NodeIt n;
1702 NodeIt(const typename Graph::NodeIt& _n) : n(_n) { }
1703 NodeIt(const Invalid& i) : n(i) { }
1704 NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
1706 operator Node() const { return Node(typename Graph::Node(n)); }
1708 typedef typename GraphWrapper<Graph>::Edge Edge;
1710 friend class GraphWrapper<Graph>;
1711 friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
1712 // typedef typename Graph::OutEdgeIt GraphOutEdgeIt;
1713 typename Graph::OutEdgeIt e;
1716 OutEdgeIt(const typename Graph::OutEdgeIt& _e) : e(_e) { }
1717 OutEdgeIt(const Invalid& i) : e(i) { }
1718 OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
1720 e((*_G.first_out_edges)[_n]) { }
1721 operator Edge() const { return Edge(typename Graph::Edge(e)); }
1724 friend class GraphWrapper<Graph>;
1725 friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
1726 // typedef typename Graph::InEdgeIt GraphInEdgeIt;
1727 typename Graph::InEdgeIt e;
1730 InEdgeIt(const typename Graph::InEdgeIt& _e) : e(_e) { }
1731 InEdgeIt(const Invalid& i) : e(i) { }
1732 InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
1734 e(*(_G.graph), typename Graph::Node(_n)) { }
1735 operator Edge() const { return Edge(typename Graph::Edge(e)); }
1737 //typedef typename Graph::SymEdgeIt SymEdgeIt;
1739 friend class GraphWrapper<Graph>;
1740 friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
1741 // typedef typename Graph::EdgeIt GraphEdgeIt;
1742 typename Graph::EdgeIt e;
1745 EdgeIt(const typename Graph::EdgeIt& _e) : e(_e) { }
1746 EdgeIt(const Invalid& i) : e(i) { }
1747 EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
1749 operator Edge() const { return Edge(typename Graph::Edge(e)); }
1752 NodeIt& first(NodeIt& i) const {
1753 i=NodeIt(*this); return i;
1755 OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
1756 i=OutEdgeIt(*this, p); return i;
1758 InEdgeIt& first(InEdgeIt& i, const Node& p) const {
1759 i=InEdgeIt(*this, p); return i;
1761 EdgeIt& first(EdgeIt& i) const {
1762 i=EdgeIt(*this); return i;
1765 // template<typename I> I& first(I& i) const {
1769 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
1770 // // e=first_out_edges->get(n);
1771 // e=(*first_out_edges)[n];
1774 // template<typename I, typename P> I& first(I& i, const P& p) const {
1775 // graph->first(i, p);
1779 NodeIt& next(NodeIt& i) const { graph->next(i.n); return i; }
1780 OutEdgeIt& next(OutEdgeIt& i) const { graph->next(i.e); return i; }
1781 InEdgeIt& next(InEdgeIt& i) const { graph->next(i.e); return i; }
1782 EdgeIt& next(EdgeIt& i) const { graph->next(i.e); return i; }
1784 Node aNode(const OutEdgeIt& e) const { return Node(graph->aNode(e.e)); }
1785 Node aNode(const InEdgeIt& e) const { return Node(graph->aNode(e.e)); }
1786 Node bNode(const OutEdgeIt& e) const { return Node(graph->bNode(e.e)); }
1787 Node bNode(const InEdgeIt& e) const { return Node(graph->bNode(e.e)); }
1789 // template<typename I> I& next(I &i) const {
1794 template< typename It > It first() const {
1795 It e; this->first(e); return e; }
1797 template< typename It > It first(const Node& v) const {
1798 It e; this->first(e, v); return e; }
1800 void erase(const OutEdgeIt& e) const {
1803 first_out_edges->set(this->tail(e), f.e);
1807 // //ErasingFirstGraphWrapper for blocking flows
1808 // template<typename Graph, typename FirstOutEdgesMap>
1809 // class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
1811 // FirstOutEdgesMap* first_out_edges;
1813 // ErasingFirstGraphWrapper(Graph& _graph,
1814 // FirstOutEdgesMap& _first_out_edges) :
1815 // GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }
1817 // typedef typename Graph::Node Node;
1818 // class NodeIt : public Graph::NodeIt {
1821 // NodeIt(const typename Graph::NodeIt& n) : Graph::NodeIt(n) { }
1822 // NodeIt(const Invalid& i) : Graph::NodeIt(i) { }
1823 // NodeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
1824 // Graph::NodeIt(*(_G.graph)) { }
1826 // typedef typename Graph::Edge Edge;
1827 // class OutEdgeIt : public Graph::OutEdgeIt {
1830 // OutEdgeIt(const typename Graph::OutEdgeIt& e) : Graph::OutEdgeIt(e) { }
1831 // OutEdgeIt(const Invalid& i) : Graph::OutEdgeIt(i) { }
1832 // OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
1834 // Graph::OutEdgeIt((*_G.first_out_edges)[n]) { }
1836 // class InEdgeIt : public Graph::InEdgeIt {
1839 // InEdgeIt(const typename Graph::InEdgeIt& e) : Graph::InEdgeIt(e) { }
1840 // InEdgeIt(const Invalid& i) : Graph::InEdgeIt(i) { }
1841 // InEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G,
1843 // Graph::InEdgeIt(*(_G.graph), n) { }
1845 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
1846 // class EdgeIt : public Graph::EdgeIt {
1849 // EdgeIt(const typename Graph::EdgeIt& e) : Graph::EdgeIt(e) { }
1850 // EdgeIt(const Invalid& i) : Graph::EdgeIt(i) { }
1851 // EdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _G) :
1852 // Graph::EdgeIt(*(_G.graph)) { }
1855 // NodeIt& first(NodeIt& i) const {
1859 // OutEdgeIt& first(OutEdgeIt& i, const Node& n) const {
1860 // i=OutEdgeIt(*this, n);
1861 // // i=(*first_out_edges)[n];
1864 // InEdgeIt& first(InEdgeIt& i, const Node& n) const {
1865 // i=InEdgeIt(*this, n);
1868 // EdgeIt& first(EdgeIt& i) const {
1873 // // template<typename I> I& first(I& i) const {
1874 // // graph->first(i);
1877 // // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
1878 // // // e=first_out_edges->get(n);
1879 // // e=(*first_out_edges)[n];
1882 // // template<typename I, typename P> I& first(I& i, const P& p) const {
1883 // // graph->first(i, p);
1887 // NodeIt& next(NodeIt& i) const {
1891 // OutEdgeIt& next(OutEdgeIt& i) const {
1895 // InEdgeIt& next(InEdgeIt& i) const {
1899 // EdgeIt& next(EdgeIt& i) const {
1904 // // template<typename I> I& next(I &i) const {
1905 // // graph->next(i);
1909 // template< typename It > It first() const {
1910 // It e; this->first(e); return e; }
1912 // template< typename It > It first(const Node& v) const {
1913 // It e; this->first(e, v); return e; }
1915 // void erase(const OutEdgeIt& e) const {
1918 // first_out_edges->set(this->tail(e), f);
1923 // // FIXME: comparison should be made better!!!
1924 // template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
1925 // class ResGraphWrapper
1930 // typedef Graph ParentGraph;
1932 // typedef typename Graph::Node Node;
1933 // typedef typename Graph::Edge Edge;
1935 // typedef typename Graph::NodeIt NodeIt;
1937 // class OutEdgeIt {
1941 // typename Graph::OutEdgeIt o;
1942 // typename Graph::InEdgeIt i;
1948 // typename Graph::OutEdgeIt o;
1949 // typename Graph::InEdgeIt i;
1951 // typedef typename Graph::SymEdgeIt SymEdgeIt;
1952 // typedef typename Graph::EdgeIt EdgeIt;
1954 // int nodeNum() const { return gw.nodeNum(); }
1955 // int edgeNum() const { return gw.edgeNum(); }
1957 // Node& first(Node& n) const { return gw.first(n); }
1959 // // Edge and SymEdge is missing!!!!
1960 // // Edge <-> In/OutEdgeIt conversion is missing!!!!
1963 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const
1967 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1969 // if(!gw.valid(e.o)) {
1971 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1977 // OutEdgeIt &goNext(OutEdgeIt &e)
1979 // if(gw.valid(e.o)) {
1980 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1982 // if(gw.valid(e.o)) return e;
1983 // else gw.first(e.i,e.n);
1986 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1991 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
1993 // //bool valid(const OutEdgeIt e) { return gw.valid(e.o)||gw.valid(e.i);}
1996 // InEdgeIt& first(InEdgeIt& e, const Node& n) const
2000 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
2002 // if(!gw.valid(e.i)) {
2004 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
2010 // InEdgeIt &goNext(InEdgeIt &e)
2012 // if(gw.valid(e.i)) {
2013 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
2015 // if(gw.valid(e.i)) return e;
2016 // else gw.first(e.o,e.n);
2019 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
2024 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
2026 // //bool valid(const InEdgeIt e) { return gw.valid(e.i)||gw.valid(e.o);}
2028 // //template<typename I> I &goNext(I &i); { return gw.goNext(i); }
2029 // //template<typename I> I next(const I i); { return gw.goNext(i); }
2031 // template< typename It > It first() const {
2032 // It e; first(e); return e; }
2034 // template< typename It > It first(Node v) const {
2035 // It e; first(e, v); return e; }
2037 // Node head(const Edge& e) const { return gw.head(e); }
2038 // Node tail(const Edge& e) const { return gw.tail(e); }
2040 // template<typename I> Node aNode(const I& e) const {
2041 // return gw.aNode(e); }
2042 // template<typename I> Node bNode(const I& e) const {
2043 // return gw.bNode(e); }
2045 // //template<typename I> bool valid(const I i);
2046 // //{ return gw.valid(i); }
2048 // //template<typename I> void setInvalid(const I &i);
2049 // //{ return gw.setInvalid(i); }
2051 // Node addNode() { return gw.addNode(); }
2052 // Edge addEdge(const Node& tail, const Node& head) {
2053 // return gw.addEdge(tail, head); }
2055 // template<typename I> void erase(const I& i) { gw.erase(i); }
2057 // void clear() { gw.clear(); }
2059 // template<typename S> class NodeMap : public Graph::NodeMap<S> { };
2060 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
2062 // void setGraph(Graph& _graph) { graph = &_graph; }
2063 // Graph& getGraph() { return (*graph); }
2065 // //ResGraphWrapper() : graph(0) { }
2066 // ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
2071 #endif //HUGO_GRAPH_WRAPPER_H