ResCap, a map for the residual capacity in ResGraphWrapper
authormarci
Tue, 25 May 2004 13:13:52 +0000
changeset 660edb42cb9d352
parent 659 c5984e925384
child 661 d306e777117e
ResCap, a map for the residual capacity in ResGraphWrapper
src/hugo/graph_wrapper.h
     1.1 --- a/src/hugo/graph_wrapper.h	Tue May 25 12:31:18 2004 +0000
     1.2 +++ b/src/hugo/graph_wrapper.h	Tue May 25 13:13:52 2004 +0000
     1.3 @@ -1461,10 +1461,12 @@
     1.4        Parent::setBackwardFilterMap(backward_filter);
     1.5      }
     1.6  
     1.7 +    typedef typename Parent::Edge Edge;
     1.8 +
     1.9      //    bool forward(const Parent::Edge& e) const { return Parent::forward(e); }
    1.10      //bool backward(const Edge& e) const { return e.backward; }
    1.11  
    1.12 -    void augment(const typename Parent::Edge& e, Number a) const {
    1.13 +    void augment(const Edge& e, Number a) const {
    1.14        if (Parent::forward(e))  
    1.15  // 	flow->set(e.out, flow->get(e.out)+a);
    1.16  	flow->set(e, (*flow)[e]+a);
    1.17 @@ -1473,7 +1475,9 @@
    1.18  	flow->set(e, (*flow)[e]-a);
    1.19      }
    1.20  
    1.21 -    Number resCap(const typename Parent::Edge& e) const { 
    1.22 +    /// \deprecated
    1.23 +    ///
    1.24 +    Number resCap(const Edge& e) const { 
    1.25        if (Parent::forward(e)) 
    1.26  //	return (capacity->get(e.out)-flow->get(e.out)); 
    1.27  	return ((*capacity)[e]-(*flow)[e]); 
    1.28 @@ -1482,11 +1486,32 @@
    1.29  	return ((*flow)[e]); 
    1.30      }
    1.31  
    1.32 +    /// \brief Residual capacity map.
    1.33 +    ///
    1.34 +    /// In generic residual graphs the residual capacity can be obtained as a map.
    1.35 +    class ResCap {
    1.36 +    protected:
    1.37 +      const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>* res_graph;
    1.38 +    public:
    1.39 +      typedef Number ValueType;
    1.40 +      typedef Edge KeyType;
    1.41 +      ResCap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& _res_graph) : 
    1.42 +	res_graph(&_res_graph) { }
    1.43 +      Number operator[](const Edge& e) const { 
    1.44 +	if (res_graph->forward(e)) 
    1.45 +	  //	return (capacity->get(e.out)-flow->get(e.out)); 
    1.46 +	  return (*(res_graph->capacity))[e]-(*(res_graph->flow))[e]; 
    1.47 +	else 
    1.48 +	  //	return (flow->get(e.in)); 
    1.49 +	  return (*(res_graph->flow))[e]; 
    1.50 +      }
    1.51 +      /// \bug not needed with dynamic maps, or does it?
    1.52 +      void update() { }
    1.53 +    };
    1.54 +
    1.55    };
    1.56  
    1.57  
    1.58 -
    1.59 -
    1.60    template<typename Graph, typename Number, 
    1.61  	   typename CapacityMap, typename FlowMap>
    1.62    class OldResGraphWrapper : public GraphWrapper<Graph> {