2 #ifndef HUGO_GRAPH_WRAPPER_H
3 #define HUGO_GRAPH_WRAPPER_H
9 template<typename Graph>
10 class TrivGraphWrapper {
15 typedef Graph BaseGraph;
17 typedef typename Graph::Node Node;
18 typedef typename Graph::NodeIt NodeIt;
20 typedef typename Graph::Edge Edge;
21 typedef typename Graph::OutEdgeIt OutEdgeIt;
22 typedef typename Graph::InEdgeIt InEdgeIt;
23 //typedef typename Graph::SymEdgeIt SymEdgeIt;
24 typedef typename Graph::EdgeIt EdgeIt;
26 //TrivGraphWrapper() : graph(0) { }
27 TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
29 void setGraph(Graph& _graph) { graph = &_graph; }
30 Graph& getGraph() const { return (*graph); }
32 template<typename I> I& first(I& i) const { return graph->first(i); }
33 template<typename I, typename P> I& first(I& i, const P& p) const {
34 return graph->first(i, p); }
36 template<typename I> I getNext(const I& i) const {
37 return graph->getNext(i); }
38 template<typename I> I& next(I &i) const { return graph->next(i); }
40 template< typename It > It first() const {
41 It e; first(e); return e; }
43 template< typename It > It first(const Node& v) const {
44 It e; first(e, v); return e; }
46 Node head(const Edge& e) const { return graph->head(e); }
47 Node tail(const Edge& e) const { return graph->tail(e); }
49 template<typename I> bool valid(const I& i) const
50 { return graph->valid(i); }
52 //template<typename I> void setInvalid(const I &i);
53 //{ return graph->setInvalid(i); }
55 int nodeNum() const { return graph->nodeNum(); }
56 int edgeNum() const { return graph->edgeNum(); }
58 template<typename I> Node aNode(const I& e) const {
59 return graph->aNode(e); }
60 template<typename I> Node bNode(const I& e) const {
61 return graph->bNode(e); }
63 Node addNode() const { return graph->addNode(); }
64 Edge addEdge(const Node& tail, const Node& head) const {
65 return graph->addEdge(tail, head); }
67 template<typename I> void erase(const I& i) const { graph->erase(i); }
69 void clear() const { graph->clear(); }
71 template<typename T> class NodeMap : public Graph::NodeMap<T> {
73 NodeMap(const TrivGraphWrapper<Graph>& _G) :
74 Graph::NodeMap<T>(_G.getGraph()) { }
75 NodeMap(const TrivGraphWrapper<Graph>& _G, T a) :
76 Graph::NodeMap<T>(_G.getGraph(), a) { }
79 template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
81 EdgeMap(const TrivGraphWrapper<Graph>& _G) :
82 Graph::EdgeMap<T>(_G.getGraph()) { }
83 EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) :
84 Graph::EdgeMap<T>(_G.getGraph(), a) { }
88 template<typename GraphWrapper>
89 class GraphWrapperSkeleton {
94 typedef typename GraphWrapper::BaseGraph BaseGraph;
96 typedef typename GraphWrapper::Node Node;
97 typedef typename GraphWrapper::NodeIt NodeIt;
99 typedef typename GraphWrapper::Edge Edge;
100 typedef typename GraphWrapper::OutEdgeIt OutEdgeIt;
101 typedef typename GraphWrapper::InEdgeIt InEdgeIt;
102 //typedef typename GraphWrapper::SymEdgeIt SymEdgeIt;
103 typedef typename GraphWrapper::EdgeIt EdgeIt;
105 //GraphWrapperSkeleton() : gw() { }
106 GraphWrapperSkeleton(GraphWrapper _gw) : gw(_gw) { }
108 void setGraph(BaseGraph& _graph) { gw.setGraph(_graph); }
109 BaseGraph& getGraph() const { return gw.getGraph(); }
111 template<typename I> I& first(I& i) const { return gw.first(i); }
112 template<typename I, typename P> I& first(I& i, const P& p) const {
113 return gw.first(i, p); }
115 template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
116 template<typename I> I& next(I &i) const { return gw.next(i); }
118 template< typename It > It first() const {
119 It e; this->first(e); return e; }
121 template< typename It > It first(const Node& v) const {
122 It e; this->first(e, v); return e; }
124 Node head(const Edge& e) const { return gw.head(e); }
125 Node tail(const Edge& e) const { return gw.tail(e); }
127 template<typename I> bool valid(const I& i) const { return gw.valid(i); }
129 //template<typename I> void setInvalid(const I &i);
130 //{ return graph->setInvalid(i); }
132 int nodeNum() const { return gw.nodeNum(); }
133 int edgeNum() const { return gw.edgeNum(); }
135 template<typename I> Node aNode(const I& e) const { return gw.aNode(e); }
136 template<typename I> Node bNode(const I& e) const { return gw.bNode(e); }
138 Node addNode() const { return gw.addNode(); }
139 Edge addEdge(const Node& tail, const Node& head) const {
140 return gw.addEdge(tail, head); }
142 template<typename I> void erase(const I& i) const { gw.erase(i); }
144 void clear() const { gw.clear(); }
146 template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
148 NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
149 GraphWrapper::NodeMap<T>(_G.gw) { }
150 NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
151 GraphWrapper::NodeMap<T>(_G.gw, a) { }
154 template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> {
156 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :
157 GraphWrapper::EdgeMap<T>(_G.gw) { }
158 EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) :
159 GraphWrapper::EdgeMap<T>(_G.gw, a) { }
163 // template<typename Graph>
164 // class RevGraphWrapper
170 // typedef Graph BaseGraph;
172 // typedef typename Graph::Node Node;
173 // typedef typename Graph::NodeIt NodeIt;
175 // typedef typename Graph::Edge Edge;
176 // typedef typename Graph::OutEdgeIt InEdgeIt;
177 // typedef typename Graph::InEdgeIt OutEdgeIt;
178 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
179 // typedef typename Graph::EdgeIt EdgeIt;
181 // //RevGraphWrapper() : graph(0) { }
182 // RevGraphWrapper(Graph& _graph) : graph(&_graph) { }
184 // void setGraph(Graph& _graph) { graph = &_graph; }
185 // Graph& getGraph() const { return (*graph); }
187 // template<typename I> I& first(I& i) const { return graph->first(i); }
188 // template<typename I, typename P> I& first(I& i, const P& p) const {
189 // return graph->first(i, p); }
191 // template<typename I> I getNext(const I& i) const {
192 // return graph->getNext(i); }
193 // template<typename I> I& next(I &i) const { return graph->next(i); }
195 // template< typename It > It first() const {
196 // It e; first(e); return e; }
198 // template< typename It > It first(const Node& v) const {
199 // It e; first(e, v); return e; }
201 // Node head(const Edge& e) const { return graph->tail(e); }
202 // Node tail(const Edge& e) const { return graph->head(e); }
204 // template<typename I> bool valid(const I& i) const
205 // { return graph->valid(i); }
207 // //template<typename I> void setInvalid(const I &i);
208 // //{ return graph->setInvalid(i); }
210 // template<typename I> Node aNode(const I& e) const {
211 // return graph->aNode(e); }
212 // template<typename I> Node bNode(const I& e) const {
213 // return graph->bNode(e); }
215 // Node addNode() const { return graph->addNode(); }
216 // Edge addEdge(const Node& tail, const Node& head) const {
217 // return graph->addEdge(tail, head); }
219 // int nodeNum() const { return graph->nodeNum(); }
220 // int edgeNum() const { return graph->edgeNum(); }
222 // template<typename I> void erase(const I& i) const { graph->erase(i); }
224 // void clear() const { graph->clear(); }
226 // template<typename T> class NodeMap : public Graph::NodeMap<T> {
228 // NodeMap(const RevGraphWrapper<Graph>& _G) :
229 // Graph::NodeMap<T>(_G.getGraph()) { }
230 // NodeMap(const RevGraphWrapper<Graph>& _G, T a) :
231 // Graph::NodeMap<T>(_G.getGraph(), a) { }
234 // template<typename T> class EdgeMap : public Graph::EdgeMap<T> {
236 // EdgeMap(const RevGraphWrapper<Graph>& _G) :
237 // Graph::EdgeMap<T>(_G.getGraph()) { }
238 // EdgeMap(const RevGraphWrapper<Graph>& _G, T a) :
239 // Graph::EdgeMap<T>(_G.getGraph(), a) { }
243 // template<typename /*Graph*/GraphWrapper
244 // /*=typename GraphWrapperSkeleton< TrivGraphWrapper<Graph>*/ >
245 // class RevGraphWrapper :
246 // public GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/ {
251 // //typedef Graph BaseGraph;
253 // //typedef typename Graph::Node Node;
254 // //typedef typename Graph::NodeIt NodeIt;
256 // //typedef typename Graph::Edge Edge;
257 // typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::OutEdgeIt InEdgeIt;
258 // typedef typename GraphWrapper/*typename GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/::InEdgeIt OutEdgeIt;
259 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
260 // //typedef typename Graph::EdgeIt EdgeIt;
262 // //RevGraphWrapper() : graph(0) { }
263 // RevGraphWrapper(GraphWrapper _gw/*BaseGraph& _graph*/) : GraphWrapper/*GraphWrapperSkeleton< TrivGraphWrapper<Graph> >*/(_gw/*TrivGraphWrapper<Graph>(_graph)*/) { }
265 // //void setGraph(Graph& _graph) { graph = &_graph; }
266 // //Graph& getGraph() const { return (*graph); }
268 // //template<typename I> I& first(I& i) const { return graph->first(i); }
269 // //template<typename I, typename P> I& first(I& i, const P& p) const {
270 // // return graph->first(i, p); }
272 // //template<typename I> I getNext(const I& i) const {
273 // // return graph->getNext(i); }
274 // //template<typename I> I& next(I &i) const { return graph->next(i); }
276 // //template< typename It > It first() const {
277 // // It e; first(e); return e; }
279 // //template< typename It > It first(const Node& v) const {
280 // // It e; first(e, v); return e; }
282 // //Node head(const Edge& e) const { return graph->tail(e); }
283 // //Node tail(const Edge& e) const { return graph->head(e); }
285 // //template<typename I> bool valid(const I& i) const
286 // // { return graph->valid(i); }
288 // //template<typename I> void setInvalid(const I &i);
289 // //{ return graph->setInvalid(i); }
291 // //template<typename I> Node aNode(const I& e) const {
292 // // return graph->aNode(e); }
293 // //template<typename I> Node bNode(const I& e) const {
294 // // return graph->bNode(e); }
296 // //Node addNode() const { return graph->addNode(); }
297 // //Edge addEdge(const Node& tail, const Node& head) const {
298 // // return graph->addEdge(tail, head); }
300 // //int nodeNum() const { return graph->nodeNum(); }
301 // //int edgeNum() const { return graph->edgeNum(); }
303 // //template<typename I> void erase(const I& i) const { graph->erase(i); }
305 // //void clear() const { graph->clear(); }
307 // template<typename T> class NodeMap :
308 // public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>
311 // NodeMap(const RevGraphWrapper<GraphWrapper>& _gw) :
312 // GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw) { }
313 // NodeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) :
314 // GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::NodeMap<T>(_gw, a) { }
317 // template<typename T> class EdgeMap :
318 // public GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T> {
320 // EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw) :
321 // GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw) { }
322 // EdgeMap(const RevGraphWrapper<GraphWrapper>& _gw, T a) :
323 // GraphWrapper/*Skeleton< TrivGraphWrapper<Graph> >*/::EdgeMap<T>(_gw, a) { }
328 template<typename GraphWrapper>
329 class RevGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
331 typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
332 typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge Edge;
333 typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt InEdgeIt;
334 typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OutEdgeIt;
336 RevGraphWrapper(GraphWrapper _gw) :
337 GraphWrapperSkeleton<GraphWrapper>(_gw) { }
339 Node head(const Edge& e) const
340 { return GraphWrapperSkeleton<GraphWrapper>::tail(e); }
341 Node tail(const Edge& e) const
342 { return GraphWrapperSkeleton<GraphWrapper>::head(e); }
346 // template<typename GraphWrapper>
347 // class UndirGraphWrapper {
353 // typedef GraphWrapper BaseGraph;
355 // typedef typename GraphWrapper::Node Node;
356 // typedef typename GraphWrapper::NodeIt NodeIt;
358 // //typedef typename Graph::Edge Edge;
359 // //typedef typename Graph::OutEdgeIt OutEdgeIt;
360 // //typedef typename Graph::InEdgeIt InEdgeIt;
361 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
362 // //typedef typename Graph::EdgeIt EdgeIt;
365 // typedef typename GraphWrapper::Edge GraphEdge;
366 // typedef typename GraphWrapper::OutEdgeIt GraphOutEdgeIt;
367 // typedef typename GraphWrapper::InEdgeIt GraphInEdgeIt;
370 // //UndirGraphWrapper() : graph(0) { }
371 // UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
373 // //void setGraph(Graph& _graph) { graph = &_graph; }
374 // //Graph& getGraph() const { return (*graph); }
377 // friend class UndirGraphWrapper<GraphWrapper>;
378 // bool out_or_in; //true iff out
379 // GraphOutEdgeIt out;
382 // Edge() : out_or_in(), out(), in() { }
383 // Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
384 // operator GraphEdge() const {
385 // if (out_or_in) return(out); else return(in);
387 // friend bool operator==(const Edge& u, const Edge& v) {
389 // return (u.out_or_in && u.out==v.out);
391 // return (!u.out_or_in && u.in==v.in);
393 // friend bool operator!=(const Edge& u, const Edge& v) {
395 // return (!u.out_or_in || u.out!=v.out);
397 // return (u.out_or_in || u.in!=v.in);
401 // class OutEdgeIt : public Edge {
402 // friend class UndirGraphWrapper<GraphWrapper>;
404 // OutEdgeIt() : Edge() { }
405 // OutEdgeIt(const Invalid& i) : Edge(i) { }
406 // OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n)
409 // _G.gw.first(out, n);
410 // if (!(_G.gw.valid(out))) {
412 // _G.gw.first(in, n);
417 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
419 // gw.first(e.out, n);
420 // if (!(gw.valid(e.out))) {
421 // e.out_or_in=false;
422 // gw.first(e.in, n);
427 // OutEdgeIt& next(OutEdgeIt& e) const {
428 // if (e.out_or_in) {
429 // Node n=gw.tail(e.out);
431 // if (!gw.valid(e.out)) {
432 // e.out_or_in=false;
433 // gw.first(e.in, n);
441 // Node aNode(const OutEdgeIt& e) const {
442 // if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
443 // Node bNode(const OutEdgeIt& e) const {
444 // if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
446 // typedef OutEdgeIt InEdgeIt;
448 // template<typename I> I& first(I& i) const { return gw.first(i); }
449 // // template<typename I, typename P> I& first(I& i, const P& p) const {
450 // // return graph->first(i, p); }
452 // template<typename I> I getNext(const I& i) const {
453 // return gw.getNext(i); }
454 // template<typename I> I& next(I &i) const { return gw.next(i); }
456 // template< typename It > It first() const {
457 // It e; first(e); return e; }
459 // template< typename It > It first(const Node& v) const {
460 // It e; first(e, v); return e; }
462 // Node head(const Edge& e) const { return gw.head(e); }
463 // Node tail(const Edge& e) const { return gw.tail(e); }
465 // template<typename I> bool valid(const I& i) const
466 // { return gw.valid(i); }
468 // //template<typename I> void setInvalid(const I &i);
469 // //{ return graph->setInvalid(i); }
471 // int nodeNum() const { return gw.nodeNum(); }
472 // int edgeNum() const { return gw.edgeNum(); }
474 // // template<typename I> Node aNode(const I& e) const {
475 // // return graph->aNode(e); }
476 // // template<typename I> Node bNode(const I& e) const {
477 // // return graph->bNode(e); }
479 // Node addNode() const { return gw.addNode(); }
480 // // FIXME: ez igy nem jo, mert nem
481 // // Edge addEdge(const Node& tail, const Node& head) const {
482 // // return graph->addEdge(tail, head); }
484 // template<typename I> void erase(const I& i) const { gw.erase(i); }
486 // void clear() const { gw.clear(); }
488 // template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
490 // NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
491 // GraphWrapper::NodeMap<T>(_G.gw) { }
492 // NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
493 // GraphWrapper::NodeMap<T>(_G.gw, a) { }
496 // template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> {
498 // EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
499 // GraphWrapper::EdgeMap<T>(_G.gw) { }
500 // EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
501 // GraphWrapper::EdgeMap<T>(_G.gw, a) { }
506 template<typename GraphWrapper>
507 class UndirGraphWrapper : public GraphWrapperSkeleton<GraphWrapper> {
512 //typedef GraphWrapper BaseGraph;
514 typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
515 typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
518 typedef typename GraphWrapperSkeleton<GraphWrapper>::Edge GraphEdge;
519 typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt GraphOutEdgeIt;
520 typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt GraphInEdgeIt;
523 //UndirGraphWrapper() : graph(0) { }
524 UndirGraphWrapper(GraphWrapper _gw) :
525 GraphWrapperSkeleton<GraphWrapper>(_gw) { }
527 //UndirGraphWrapper(GraphWrapper _gw) : gw(_gw) { }
529 //void setGraph(Graph& _graph) { graph = &_graph; }
530 //Graph& getGraph() const { return (*graph); }
533 friend class UndirGraphWrapper<GraphWrapper>;
534 bool out_or_in; //true iff out
538 Edge() : out_or_in(), out(), in() { }
539 Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
540 operator GraphEdge() const {
541 if (out_or_in) return(out); else return(in);
544 //2 edges are equal if they "refer" to the same physical edge
546 friend bool operator==(const Edge& u, const Edge& v) {
548 if (u.out_or_in) return (u.out==v.out); else return (u.out==v.in);
549 //return (u.out_or_in && u.out==v.out);
551 if (u.out_or_in) return (u.out==v.in); else return (u.in==v.in);
552 //return (!u.out_or_in && u.in==v.in);
554 friend bool operator!=(const Edge& u, const Edge& v) {
556 if (u.out_or_in) return (u.out!=v.out); else return (u.out!=v.in);
557 //return (!u.out_or_in || u.out!=v.out);
559 if (u.out_or_in) return (u.out!=v.in); else return (u.in!=v.in);
560 //return (u.out_or_in || u.in!=v.in);
564 class OutEdgeIt : public Edge {
565 friend class UndirGraphWrapper<GraphWrapper>;
567 OutEdgeIt() : Edge() { }
568 OutEdgeIt(const Invalid& i) : Edge(i) { }
569 OutEdgeIt(const UndirGraphWrapper<GraphWrapper>& _G, const Node& n)
571 out_or_in=true; _G.gw.first(out, n);
572 if (!(_G.gw.valid(out))) { out_or_in=false; _G.gw.first(in, n); }
576 typedef OutEdgeIt InEdgeIt;
578 class EdgeIt : public Edge {
579 friend class UndirGraphWrapper<GraphWrapper>;
583 EdgeIt() : Edge() { }
584 EdgeIt(const Invalid& i) : Edge(i) { }
585 EdgeIt(const UndirGraphWrapper<GraphWrapper>& _G)
590 if (_G.valid(v)) _G.gw.first(out); else out=INVALID;
591 while (_G.valid(v) && !_G.gw.valid(out)) {
593 if (_G.valid(v)) _G.gw.first(out);
598 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
599 e.out_or_in=true; gw.first(e.out, n);
600 if (!(gw.valid(e.out))) { e.out_or_in=false; gw.first(e.in, n); }
604 EdgeIt& first(EdgeIt& e) const {
608 if (valid(e.v)) gw.first(e.out, e.v); else e.out=INVALID;
609 while (valid(e.v) && !gw.valid(e.out)) {
611 if (valid(e.v)) gw.first(e.out, e.v);
616 template<typename I> I& first(I& i) const { return gw.first(i); }
617 template<typename I, typename P> I& first(I& i, const P& p) const {
618 return graph->first(i, p); }
620 OutEdgeIt& next(OutEdgeIt& e) const {
622 Node n=gw.tail(e.out);
624 if (!gw.valid(e.out)) { e.out_or_in=false; gw.first(e.in, n); }
631 EdgeIt& next(EdgeIt& e) const {
634 while (valid(e.v) && !gw.valid(e.out)) {
636 if (valid(e.v)) gw.first(e.out, e.v);
641 template<typename I> I& next(I &i) const { return gw.next(i); }
642 template<typename I> I getNext(const I& i) const { return gw.getNext(i); }
644 template< typename It > It first() const {
645 It e; first(e); return e; }
647 template< typename It > It first(const Node& v) const {
648 It e; first(e, v); return e; }
650 // Node head(const Edge& e) const { return gw.head(e); }
651 // Node tail(const Edge& e) const { return gw.tail(e); }
653 // template<typename I> bool valid(const I& i) const
654 // { return gw.valid(i); }
656 // int nodeNum() const { return gw.nodeNum(); }
657 // int edgeNum() const { return gw.edgeNum(); }
659 // template<typename I> Node aNode(const I& e) const {
660 // return graph->aNode(e); }
661 // template<typename I> Node bNode(const I& e) const {
662 // return graph->bNode(e); }
664 Node aNode(const OutEdgeIt& e) const {
665 if (e.out_or_in) return gw.tail(e); else return gw.head(e); }
666 Node bNode(const OutEdgeIt& e) const {
667 if (e.out_or_in) return gw.head(e); else return gw.tail(e); }
669 // Node addNode() const { return gw.addNode(); }
671 // FIXME: ez igy nem jo, mert nem
672 // Edge addEdge(const Node& tail, const Node& head) const {
673 // return graph->addEdge(tail, head); }
675 // template<typename I> void erase(const I& i) const { gw.erase(i); }
677 // void clear() const { gw.clear(); }
679 // template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
681 // NodeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
682 // GraphWrapper::NodeMap<T>(_G.gw) { }
683 // NodeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
684 // GraphWrapper::NodeMap<T>(_G.gw, a) { }
687 // template<typename T> class EdgeMap :
688 // public GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T> {
690 // EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G) :
691 // GraphWrapperSkeleton<GraphWrapper>::EdgeMap<T>(_G.gw) { }
692 // EdgeMap(const UndirGraphWrapper<GraphWrapper>& _G, T a) :
693 // GraphWrapper::EdgeMap<T>(_G.gw, a) { }
701 // template<typename Graph>
702 // class SymGraphWrapper
707 // typedef Graph BaseGraph;
709 // typedef typename Graph::Node Node;
710 // typedef typename Graph::Edge Edge;
712 // typedef typename Graph::NodeIt NodeIt;
714 // //FIXME tag-ekkel megcsinalni, hogy abbol csinaljon
715 // //iranyitatlant, ami van
716 // //mert csak 1 dolgot lehet be typedef-elni
717 // typedef typename Graph::OutEdgeIt SymEdgeIt;
718 // //typedef typename Graph::InEdgeIt SymEdgeIt;
719 // //typedef typename Graph::SymEdgeIt SymEdgeIt;
720 // typedef typename Graph::EdgeIt EdgeIt;
722 // int nodeNum() const { return graph->nodeNum(); }
723 // int edgeNum() const { return graph->edgeNum(); }
725 // template<typename I> I& first(I& i) const { return graph->first(i); }
726 // template<typename I, typename P> I& first(I& i, const P& p) const {
727 // return graph->first(i, p); }
728 // //template<typename I> I next(const I i); { return graph->goNext(i); }
729 // //template<typename I> I &goNext(I &i); { return graph->goNext(i); }
731 // template< typename It > It first() const {
732 // It e; first(e); return e; }
734 // template< typename It > It first(Node v) const {
735 // It e; first(e, v); return e; }
737 // Node head(const Edge& e) const { return graph->head(e); }
738 // Node tail(const Edge& e) const { return graph->tail(e); }
740 // template<typename I> Node aNode(const I& e) const {
741 // return graph->aNode(e); }
742 // template<typename I> Node bNode(const I& e) const {
743 // return graph->bNode(e); }
745 // //template<typename I> bool valid(const I i);
746 // //{ return graph->valid(i); }
748 // //template<typename I> void setInvalid(const I &i);
749 // //{ return graph->setInvalid(i); }
751 // Node addNode() { return graph->addNode(); }
752 // Edge addEdge(const Node& tail, const Node& head) {
753 // return graph->addEdge(tail, head); }
755 // template<typename I> void erase(const I& i) { graph->erase(i); }
757 // void clear() { graph->clear(); }
759 // template<typename T> class NodeMap : public Graph::NodeMap<T> { };
760 // template<typename T> class EdgeMap : public Graph::EdgeMap<T> { };
762 // void setGraph(Graph& _graph) { graph = &_graph; }
763 // Graph& getGraph() { return (*graph); }
765 // //SymGraphWrapper() : graph(0) { }
766 // SymGraphWrapper(Graph& _graph) : graph(&_graph) { }
770 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
771 class ResGraphWrapper {
773 //typedef Graph BaseGraph;
774 typedef typename Graph::Node Node;
775 typedef typename Graph::NodeIt NodeIt;
777 typedef typename Graph::OutEdgeIt OldOutEdgeIt;
778 typedef typename Graph::InEdgeIt OldInEdgeIt;
780 //const Graph* graph;
781 typedef TrivGraphWrapper<const Graph> GraphWrapper;
784 const CapacityMap* capacity;
787 ResGraphWrapper(const Graph& _G, FlowMap& _flow,
788 const CapacityMap& _capacity) :
789 gw(_G), flow(&_flow), capacity(&_capacity) { }
791 //void setGraph(const Graph& _graph) { graph = &_graph; }
792 //const Graph& getGraph() const { return (*graph); }
797 friend class OutEdgeIt;
800 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
802 bool out_or_in; //true, iff out
806 Edge() : out_or_in(true) { }
807 Edge(const Invalid& i) : out_or_in(false), out(), in(i) { }
808 // bool valid() const {
809 // return out_or_in && out.valid() || in.valid(); }
810 friend bool operator==(const Edge& u, const Edge& v) {
812 return (u.out_or_in && u.out==v.out);
814 return (!u.out_or_in && u.in==v.in);
816 friend bool operator!=(const Edge& u, const Edge& v) {
818 return (!u.out_or_in || u.out!=v.out);
820 return (u.out_or_in || u.in!=v.in);
825 class OutEdgeIt : public Edge {
826 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
830 OutEdgeIt(const Edge& e) : Edge(e) { }
831 OutEdgeIt(const Invalid& i) : Edge(i) { }
833 OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() {
834 resG.gw.first(out, v);
835 while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
836 if (!resG.gw.valid(out)) {
838 resG.gw.first(in, v);
839 while( resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
843 // OutEdgeIt& operator++() {
845 // Node v=/*resG->*/G->aNode(out);
847 // while( out.valid() && !(Edge::free()>0) ) { ++out; }
848 // if (!out.valid()) {
851 // while( in.valid() && !(Edge::free()>0) ) { ++in; }
855 // while( in.valid() && !(Edge::free()>0) ) { ++in; }
861 class EdgeIt : public Edge {
862 friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
863 typename Graph::NodeIt v;
866 //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
867 EdgeIt(const Invalid& i) : Edge(i) { }
868 EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() {
870 if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID);
871 while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
872 while (resG.gw.valid(v) && !resG.gw.valid(out)) {
874 if (resG.gw.valid(v)) resG.gw.first(out, v);
875 while (resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
877 if (!resG.gw.valid(out)) {
880 if (resG.gw.valid(v)) resG.gw.first(in, v); else in=/*OldInEdgeIt*/(INVALID);
881 while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
882 while (resG.gw.valid(v) && !resG.gw.valid(in)) {
884 if (resG.gw.valid(v)) resG.gw.first(in, v);
885 while (resG.gw.valid(in) && !(resG.free(in)>0) ) { resG.gw.next(in); }
889 // EdgeIt& operator++() {
892 // while (out.valid() && !(Edge::free()>0) ) { ++out; }
893 // while (v.valid() && !out.valid()) {
895 // if (v.valid()) G->first(out, v);
896 // while (out.valid() && !(Edge::free()>0) ) { ++out; }
898 // if (!out.valid()) {
901 // if (v.valid()) G->first(in, v); else in=OldInEdgeIt();
902 // while (in.valid() && !(Edge::free()>0) ) { ++in; }
903 // while (v.valid() && !in.valid()) {
905 // if (v.valid()) G->first(in, v);
906 // while (in.valid() && !(Edge::free()>0) ) { ++in; }
911 // while (in.valid() && !(Edge::free()>0) ) { ++in; }
912 // while (v.valid() && !in.valid()) {
914 // if (v.valid()) G->first(in, v);
915 // while (in.valid() && !(Edge::free()>0) ) { ++in; }
922 NodeIt& first(NodeIt& v) const { return gw.first(v); }
923 OutEdgeIt& first(OutEdgeIt& e, Node v) const {
924 e=OutEdgeIt(*this, v);
927 EdgeIt& first(EdgeIt& e) const {
932 NodeIt& next(NodeIt& n) const { return gw.next(n); }
934 OutEdgeIt& next(OutEdgeIt& e) const {
936 Node v=gw.aNode(e.out);
938 while( gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
939 if (!gw.valid(e.out)) {
942 while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
946 while( gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
951 EdgeIt& next(EdgeIt& e) const {
954 while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
955 while (gw.valid(e.v) && !gw.valid(e.out)) {
957 if (gw.valid(e.v)) gw.first(e.out, e.v);
958 while (gw.valid(e.out) && !(free(e.out)>0) ) { gw.next(e.out); }
960 if (!gw.valid(e.out)) {
963 if (gw.valid(e.v)) gw.first(e.in, e.v); else e.in=/*OldInEdgeIt*/(INVALID);
964 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
965 while (gw.valid(e.v) && !gw.valid(e.in)) {
967 if (gw.valid(e.v)) gw.first(e.in, e.v);
968 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
973 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
974 while (gw.valid(e.v) && !gw.valid(e.in)) {
976 if (gw.valid(e.v)) gw.first(e.in, e.v);
977 while (gw.valid(e.in) && !(free(e.in)>0) ) { gw.next(e.in); }
984 template< typename It >
991 template< typename It >
992 It first(Node v) const {
998 Node tail(Edge e) const {
999 return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
1000 Node head(Edge e) const {
1001 return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
1003 Node aNode(OutEdgeIt e) const {
1004 return ((e.out_or_in) ? gw.aNode(e.out) : gw.aNode(e.in)); }
1005 Node bNode(OutEdgeIt e) const {
1006 return ((e.out_or_in) ? gw.bNode(e.out) : gw.bNode(e.in)); }
1008 int id(Node v) const { return gw.id(v); }
1010 bool valid(Node n) const { return gw.valid(n); }
1011 bool valid(Edge e) const {
1012 return e.out_or_in ? gw.valid(e.out) : gw.valid(e.in); }
1014 void augment(const Edge& e, Number a) const {
1016 flow->set(e.out, flow->get(e.out)+a);
1018 flow->set(e.in, flow->get(e.in)-a);
1021 Number free(const Edge& e) const {
1023 return (capacity->get(e.out)-flow->get(e.out));
1025 return (flow->get(e.in));
1028 Number free(OldOutEdgeIt out) const {
1029 return (capacity->get(out)-flow->get(out));
1032 Number free(OldInEdgeIt in) const {
1033 return (flow->get(in));
1036 template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> {
1038 NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G)
1039 : GraphWrapper::NodeMap<T>(_G.gw) { }
1040 NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G,
1041 T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
1044 // template <typename T>
1046 // typename Graph::NodeMap<T> node_map;
1048 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(*(_G.graph)) { }
1049 // NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : node_map(*(_G.graph), a) { }
1050 // void set(Node nit, T a) { node_map.set(nit, a); }
1051 // T get(Node nit) const { return node_map.get(nit); }
1054 template <typename T>
1056 typename GraphWrapper::EdgeMap<T> forward_map, backward_map;
1058 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
1059 EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
1060 void set(Edge e, T a) {
1062 forward_map.set(e.out, a);
1064 backward_map.set(e.in, a);
1068 return forward_map.get(e.out);
1070 return backward_map.get(e.in);
1075 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
1076 class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
1078 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
1079 //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
1081 ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow,
1082 const CapacityMap& _capacity) :
1083 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity),
1084 first_out_edges(*this) /*, dist(*this)*/ {
1085 for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
1087 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
1088 first_out_edges.set(n, e);
1092 //void setGraph(Graph& _graph) { graph = &_graph; }
1093 //Graph& getGraph() const { return (*graph); }
1095 //TrivGraphWrapper() : graph(0) { }
1096 //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
1098 //typedef Graph BaseGraph;
1100 //typedef typename Graph::Node Node;
1101 //typedef typename Graph::NodeIt NodeIt;
1103 //typedef typename Graph::Edge Edge;
1104 //typedef typename Graph::OutEdgeIt OutEdgeIt;
1105 //typedef typename Graph::InEdgeIt InEdgeIt;
1106 //typedef typename Graph::SymEdgeIt SymEdgeIt;
1107 //typedef typename Graph::EdgeIt EdgeIt;
1109 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
1110 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
1112 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
1113 typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
1114 //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
1115 //typedef typename Graph::SymEdgeIt SymEdgeIt;
1116 //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
1118 NodeIt& first(NodeIt& n) const {
1119 return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
1122 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
1123 e=first_out_edges.get(n);
1127 //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
1128 //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const {
1129 // return first(i, p); }
1131 //template<typename I> I getNext(const I& i) const {
1132 // return gw.getNext(i); }
1133 //template<typename I> I& next(I &i) const { return gw.next(i); }
1135 template< typename It > It first() const {
1136 It e; first(e); return e; }
1138 template< typename It > It first(const Node& v) const {
1139 It e; first(e, v); return e; }
1141 //Node head(const Edge& e) const { return gw.head(e); }
1142 //Node tail(const Edge& e) const { return gw.tail(e); }
1144 //template<typename I> bool valid(const I& i) const
1145 // { return gw.valid(i); }
1147 //int nodeNum() const { return gw.nodeNum(); }
1148 //int edgeNum() const { return gw.edgeNum(); }
1150 //template<typename I> Node aNode(const I& e) const {
1151 // return gw.aNode(e); }
1152 //template<typename I> Node bNode(const I& e) const {
1153 // return gw.bNode(e); }
1155 //Node addNode() const { return gw.addNode(); }
1156 //Edge addEdge(const Node& tail, const Node& head) const {
1157 // return gw.addEdge(tail, head); }
1159 //void erase(const OutEdgeIt& e) {
1160 // first_out_edge(this->tail(e))=e;
1162 void erase(const Edge& e) {
1165 first_out_edges.set(this->tail(e), f);
1167 //template<typename I> void erase(const I& i) const { gw.erase(i); }
1169 //void clear() const { gw.clear(); }
1171 template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
1173 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
1174 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
1175 NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
1176 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
1179 template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
1181 EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) :
1182 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
1183 EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) :
1184 ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
1188 template<typename GraphWrapper>
1189 class FilterGraphWrapper {
1192 template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
1193 class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
1198 //typedef Graph BaseGraph;
1200 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
1201 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
1203 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
1204 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
1205 //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
1206 //typedef typename Graph::SymEdgeIt SymEdgeIt;
1207 typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
1209 //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
1212 FilterGraphWrapper(const Graph& _G, FlowMap& _flow,
1213 const CapacityMap& _capacity) :
1214 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) {
1217 OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
1218 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
1219 while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e))))
1220 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
1224 NodeIt& next(NodeIt& e) const {
1225 return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
1228 OutEdgeIt& next(OutEdgeIt& e) const {
1229 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
1230 while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e))))
1231 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
1235 NodeIt& first(NodeIt& n) const {
1236 return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
1239 void erase(const Edge& e) {
1241 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
1242 while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f))))
1243 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
1244 first_out_edges.set(this->tail(e), f);
1247 //TrivGraphWrapper() : graph(0) { }
1248 //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
1250 //void setGraph(Graph& _graph) { graph = &_graph; }
1251 //Graph& getGraph() const { return (*graph); }
1253 //template<typename I> I& first(I& i) const { return gw.first(i); }
1254 //template<typename I, typename P> I& first(I& i, const P& p) const {
1255 // return gw.first(i, p); }
1257 //template<typename I> I getNext(const I& i) const {
1258 // return gw.getNext(i); }
1259 //template<typename I> I& next(I &i) const { return gw.next(i); }
1261 template< typename It > It first() const {
1262 It e; first(e); return e; }
1264 template< typename It > It first(const Node& v) const {
1265 It e; first(e, v); return e; }
1267 //Node head(const Edge& e) const { return gw.head(e); }
1268 //Node tail(const Edge& e) const { return gw.tail(e); }
1270 //template<typename I> bool valid(const I& i) const
1271 // { return gw.valid(i); }
1273 //template<typename I> void setInvalid(const I &i);
1274 //{ return gw.setInvalid(i); }
1276 //int nodeNum() const { return gw.nodeNum(); }
1277 //int edgeNum() const { return gw.edgeNum(); }
1279 //template<typename I> Node aNode(const I& e) const {
1280 // return gw.aNode(e); }
1281 //template<typename I> Node bNode(const I& e) const {
1282 // return gw.bNode(e); }
1284 //Node addNode() const { return gw.addNode(); }
1285 //Edge addEdge(const Node& tail, const Node& head) const {
1286 // return gw.addEdge(tail, head); }
1288 //template<typename I> void erase(const I& i) const { gw.erase(i); }
1290 //void clear() const { gw.clear(); }
1292 template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> {
1294 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
1295 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
1296 NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
1297 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
1300 template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> {
1302 EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) :
1303 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
1304 EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) :
1305 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
1309 ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
1315 // // FIXME: comparison should be made better!!!
1316 // template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>
1317 // class ResGraphWrapper
1322 // typedef Graph BaseGraph;
1324 // typedef typename Graph::Node Node;
1325 // typedef typename Graph::Edge Edge;
1327 // typedef typename Graph::NodeIt NodeIt;
1329 // class OutEdgeIt {
1333 // typename Graph::OutEdgeIt o;
1334 // typename Graph::InEdgeIt i;
1340 // typename Graph::OutEdgeIt o;
1341 // typename Graph::InEdgeIt i;
1343 // typedef typename Graph::SymEdgeIt SymEdgeIt;
1344 // typedef typename Graph::EdgeIt EdgeIt;
1346 // int nodeNum() const { return gw.nodeNum(); }
1347 // int edgeNum() const { return gw.edgeNum(); }
1349 // Node& first(Node& n) const { return gw.first(n); }
1351 // // Edge and SymEdge is missing!!!!
1352 // // Edge <-> In/OutEdgeIt conversion is missing!!!!
1355 // OutEdgeIt& first(OutEdgeIt& e, const Node& n) const
1359 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1361 // if(!gw.valid(e.o)) {
1363 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1369 // OutEdgeIt &goNext(OutEdgeIt &e)
1371 // if(gw.valid(e.o)) {
1372 // while(gw.valid(e.o) && fmap.get(e.o)>=himap.get(e.o))
1374 // if(gw.valid(e.o)) return e;
1375 // else gw.first(e.i,e.n);
1378 // while(gw.valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))
1383 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}
1385 // //bool valid(const OutEdgeIt e) { return gw.valid(e.o)||gw.valid(e.i);}
1388 // InEdgeIt& first(InEdgeIt& e, const Node& n) const
1392 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
1394 // if(!gw.valid(e.i)) {
1396 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
1402 // InEdgeIt &goNext(InEdgeIt &e)
1404 // if(gw.valid(e.i)) {
1405 // while(gw.valid(e.i) && fmap.get(e.i)>=himap.get(e.i))
1407 // if(gw.valid(e.i)) return e;
1408 // else gw.first(e.o,e.n);
1411 // while(gw.valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))
1416 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}
1418 // //bool valid(const InEdgeIt e) { return gw.valid(e.i)||gw.valid(e.o);}
1420 // //template<typename I> I &goNext(I &i); { return gw.goNext(i); }
1421 // //template<typename I> I next(const I i); { return gw.goNext(i); }
1423 // template< typename It > It first() const {
1424 // It e; first(e); return e; }
1426 // template< typename It > It first(Node v) const {
1427 // It e; first(e, v); return e; }
1429 // Node head(const Edge& e) const { return gw.head(e); }
1430 // Node tail(const Edge& e) const { return gw.tail(e); }
1432 // template<typename I> Node aNode(const I& e) const {
1433 // return gw.aNode(e); }
1434 // template<typename I> Node bNode(const I& e) const {
1435 // return gw.bNode(e); }
1437 // //template<typename I> bool valid(const I i);
1438 // //{ return gw.valid(i); }
1440 // //template<typename I> void setInvalid(const I &i);
1441 // //{ return gw.setInvalid(i); }
1443 // Node addNode() { return gw.addNode(); }
1444 // Edge addEdge(const Node& tail, const Node& head) {
1445 // return gw.addEdge(tail, head); }
1447 // template<typename I> void erase(const I& i) { gw.erase(i); }
1449 // void clear() { gw.clear(); }
1451 // template<typename S> class NodeMap : public Graph::NodeMap<S> { };
1452 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };
1454 // void setGraph(Graph& _graph) { graph = &_graph; }
1455 // Graph& getGraph() { return (*graph); }
1457 // //ResGraphWrapper() : graph(0) { }
1458 // ResGraphWrapper(Graph& _graph) : graph(&_graph) { }
1463 #endif //HUGO_GRAPH_WRAPPER_H