# HG changeset patch # User marci # Date 1085490832 0 # Node ID edb42cb9d352a5d95ef636bb18a88f4fd8819c27 # Parent c5984e925384d09a523cfbc5c4481188abdf11b2 ResCap, a map for the residual capacity in ResGraphWrapper diff -r c5984e925384 -r edb42cb9d352 src/hugo/graph_wrapper.h --- a/src/hugo/graph_wrapper.h Tue May 25 12:31:18 2004 +0000 +++ b/src/hugo/graph_wrapper.h Tue May 25 13:13:52 2004 +0000 @@ -1461,10 +1461,12 @@ Parent::setBackwardFilterMap(backward_filter); } + typedef typename Parent::Edge Edge; + // bool forward(const Parent::Edge& e) const { return Parent::forward(e); } //bool backward(const Edge& e) const { return e.backward; } - void augment(const typename Parent::Edge& e, Number a) const { + void augment(const Edge& e, Number a) const { if (Parent::forward(e)) // flow->set(e.out, flow->get(e.out)+a); flow->set(e, (*flow)[e]+a); @@ -1473,7 +1475,9 @@ flow->set(e, (*flow)[e]-a); } - Number resCap(const typename Parent::Edge& e) const { + /// \deprecated + /// + Number resCap(const Edge& e) const { if (Parent::forward(e)) // return (capacity->get(e.out)-flow->get(e.out)); return ((*capacity)[e]-(*flow)[e]); @@ -1482,11 +1486,32 @@ return ((*flow)[e]); } + /// \brief Residual capacity map. + /// + /// In generic residual graphs the residual capacity can be obtained as a map. + class ResCap { + protected: + const ResGraphWrapper* res_graph; + public: + typedef Number ValueType; + typedef Edge KeyType; + ResCap(const ResGraphWrapper& _res_graph) : + res_graph(&_res_graph) { } + Number operator[](const Edge& e) const { + if (res_graph->forward(e)) + // return (capacity->get(e.out)-flow->get(e.out)); + return (*(res_graph->capacity))[e]-(*(res_graph->flow))[e]; + else + // return (flow->get(e.in)); + return (*(res_graph->flow))[e]; + } + /// \bug not needed with dynamic maps, or does it? + void update() { } + }; + }; - - template class OldResGraphWrapper : public GraphWrapper {