# HG changeset patch # User marci # Date 1083911582 0 # Node ID 18787f6db0db0714fffecabe823988f8cca61d16 # Parent f84611a14a33725ac86d5745e297351c693dbb6b ResGraphWrapper mods. diff -r f84611a14a33 -r 18787f6db0db src/hugo/graph_wrapper.h --- a/src/hugo/graph_wrapper.h Fri May 07 05:29:45 2004 +0000 +++ b/src/hugo/graph_wrapper.h Fri May 07 06:33:02 2004 +0000 @@ -597,21 +597,21 @@ class Edge : public Graph::Edge { friend class ResGraphWrapper; protected: - bool forward; //true, iff forward + bool backward; //true, iff backward // typename Graph::Edge e; public: Edge() { } - Edge(const typename Graph::Edge& _e, bool _forward) : - Graph::Edge(_e), forward(_forward) { } - Edge(const Invalid& i) : Graph::Edge(i), forward(false) { } + Edge(const typename Graph::Edge& _e, bool _backward) : + Graph::Edge(_e), backward(_backward) { } + Edge(const Invalid& i) : Graph::Edge(i), backward(true) { } //the unique invalid iterator friend bool operator==(const Edge& u, const Edge& v) { - return (v.forward==u.forward && + return (v.backward==u.backward && static_cast(u)== static_cast(v)); } friend bool operator!=(const Edge& u, const Edge& v) { - return (v.forward!=u.forward || + return (v.backward!=u.backward || static_cast(u)!= static_cast(v)); } @@ -622,19 +622,19 @@ protected: typename Graph::OutEdgeIt out; typename Graph::InEdgeIt in; - bool forward; + bool backward; public: OutEdgeIt() { } //FIXME // OutEdgeIt(const Edge& e) : Edge(e) { } - OutEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { } + OutEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { } //the unique invalid iterator OutEdgeIt(const ResGraphWrapper& resG, Node v) { - forward=true; + backward=false; resG.graph->first(out, v); while( resG.graph->valid(out) && !(resG.resCap(*this)>0) ) { resG.graph->next(out); } if (!resG.graph->valid(out)) { - forward=false; + backward=true; resG.graph->first(in, v); while( resG.graph->valid(in) && !(resG.resCap(*this)>0) ) { resG.graph->next(in); } } @@ -644,10 +644,10 @@ // e.forward=this->forward; // if (this->forward) e=out; else e=in; // return e; - if (this->forward) - return Edge(out, this->forward); + if (this->backward) + return Edge(in, this->backward); else - return Edge(in, this->forward); + return Edge(out, this->backward); } }; @@ -656,19 +656,19 @@ protected: typename Graph::OutEdgeIt out; typename Graph::InEdgeIt in; - bool forward; + bool backward; public: InEdgeIt() { } //FIXME // OutEdgeIt(const Edge& e) : Edge(e) { } - InEdgeIt(const Invalid& i) : out(i), in(i), forward(false) { } + InEdgeIt(const Invalid& i) : out(i), in(i), backward(true) { } //the unique invalid iterator InEdgeIt(const ResGraphWrapper& resG, Node v) { - forward=true; + backward=false; resG.graph->first(in, v); while( resG.graph->valid(in) && !(resG.resCap(*this)>0) ) { resG.graph->next(in); } if (!resG.graph->valid(in)) { - forward=false; + backward=true; resG.graph->first(out, v); while( resG.graph->valid(out) && !(resG.resCap(*this)>0) ) { resG.graph->next(out); } } @@ -678,10 +678,10 @@ // e.forward=this->forward; // if (this->forward) e=out; else e=in; // return e; - if (this->forward) - return Edge(in, this->forward); + if (this->backward) + return Edge(out, this->backward); else - return Edge(out, this->forward); + return Edge(in, this->backward); } }; @@ -689,22 +689,22 @@ friend class ResGraphWrapper; protected: typename Graph::EdgeIt e; - bool forward; + bool backward; public: EdgeIt() { } - EdgeIt(const Invalid& i) : e(i), forward(false) { } + EdgeIt(const Invalid& i) : e(i), backward(true) { } EdgeIt(const ResGraphWrapper& resG) { - forward=true; + backward=false; resG.graph->first(e); while (resG.graph->valid(e) && !(resG.resCap(*this)>0)) resG.graph->next(e); if (!resG.graph->valid(e)) { - forward=false; + backward=true; resG.graph->first(e); while (resG.graph->valid(e) && !(resG.resCap(*this)>0)) resG.graph->next(e); } } operator Edge() const { - return Edge(e, this->forward); + return Edge(e, this->backward); } }; @@ -726,13 +726,13 @@ using GraphWrapper::next; // NodeIt& next(NodeIt& n) const { GraphWrapper::next(n); return n; } OutEdgeIt& next(OutEdgeIt& e) const { - if (e.forward) { + if (!e.backward) { Node v=this->graph->aNode(e.out); this->graph->next(e.out); while( this->graph->valid(e.out) && !(resCap(e)>0) ) { this->graph->next(e.out); } if (!this->graph->valid(e.out)) { - e.forward=false; + e.backward=true; this->graph->first(e.in, v); while( this->graph->valid(e.in) && !(resCap(e)>0) ) { this->graph->next(e.in); } @@ -746,13 +746,13 @@ } // FIXME Not tested InEdgeIt& next(InEdgeIt& e) const { - if (e.forward) { + if (!e.backward) { Node v=this->graph->aNode(e.in); this->graph->next(e.in); while( this->graph->valid(e.in) && !(resCap(e)>0) ) { this->graph->next(e.in); } if (!this->graph->valid(e.in)) { - e.forward=false; + e.backward=true; this->graph->first(e.out, v); while( this->graph->valid(e.out) && !(resCap(e)>0) ) { this->graph->next(e.out); } @@ -765,12 +765,12 @@ return e; } EdgeIt& next(EdgeIt& e) const { - if (e.forward) { + if (!e.backward) { this->graph->next(e.e); while( this->graph->valid(e.e) && !(resCap(e)>0) ) { this->graph->next(e.e); } if (!this->graph->valid(e.e)) { - e.forward=false; + e.backward=true; this->graph->first(e.e); while( this->graph->valid(e.e) && !(resCap(e)>0) ) { this->graph->next(e.e); } @@ -784,22 +784,22 @@ } Node tail(Edge e) const { - return ((e.forward) ? this->graph->tail(e) : this->graph->head(e)); } + return ((!e.backward) ? this->graph->tail(e) : this->graph->head(e)); } Node head(Edge e) const { - return ((e.forward) ? this->graph->head(e) : this->graph->tail(e)); } + return ((!e.backward) ? this->graph->head(e) : this->graph->tail(e)); } Node aNode(OutEdgeIt e) const { - return ((e.forward) ? this->graph->aNode(e.out) : + return ((!e.backward) ? this->graph->aNode(e.out) : this->graph->aNode(e.in)); } Node bNode(OutEdgeIt e) const { - return ((e.forward) ? this->graph->bNode(e.out) : + return ((!e.backward) ? this->graph->bNode(e.out) : this->graph->bNode(e.in)); } Node aNode(InEdgeIt e) const { - return ((e.forward) ? this->graph->aNode(e.in) : + return ((!e.backward) ? this->graph->aNode(e.in) : this->graph->aNode(e.out)); } Node bNode(InEdgeIt e) const { - return ((e.forward) ? this->graph->bNode(e.in) : + return ((!e.backward) ? this->graph->bNode(e.in) : this->graph->bNode(e.out)); } // int nodeNum() const { return graph->nodeNum(); } @@ -816,11 +816,11 @@ //return e.forward ? graph->valid(e.out) : graph->valid(e.in); } - bool forward(const Edge& e) const { return e.forward; } - bool backward(const Edge& e) const { return !e.forward; } + bool forward(const Edge& e) const { return !e.backward; } + bool backward(const Edge& e) const { return e.backward; } void augment(const Edge& e, Number a) const { - if (e.forward) + if (!e.backward) // flow->set(e.out, flow->get(e.out)+a); flow->set(e, (*flow)[e]+a); else @@ -829,7 +829,7 @@ } Number resCap(const Edge& e) const { - if (e.forward) + if (!e.backward) // return (capacity->get(e.out)-flow->get(e.out)); return ((*capacity)[e]-(*flow)[e]); else @@ -854,13 +854,13 @@ EdgeMap(const ResGraphWrapper& _G) : forward_map(*(_G.graph)), backward_map(*(_G.graph)) { } EdgeMap(const ResGraphWrapper& _G, T a) : forward_map(*(_G.graph), a), backward_map(*(_G.graph), a) { } void set(Edge e, T a) { - if (e.forward) + if (!e.backward) forward_map.set(e.out, a); else backward_map.set(e.in, a); } T operator[](Edge e) const { - if (e.forward) + if (!e.backward) return forward_map[e.out]; else return backward_map[e.in];