[Lemon-commits] [lemon_svn] marci: r863 - hugo/trunk/src/hugo

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:41:55 CET 2006


Author: marci
Date: Tue May 25 15:13:52 2004
New Revision: 863

Modified:
   hugo/trunk/src/hugo/graph_wrapper.h

Log:
ResCap, a map for the residual capacity in ResGraphWrapper


Modified: hugo/trunk/src/hugo/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/hugo/graph_wrapper.h	(original)
+++ hugo/trunk/src/hugo/graph_wrapper.h	Tue May 25 15:13:52 2004
@@ -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,9 +1486,30 @@
 	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<Graph, Number, CapacityMap, FlowMap>* res_graph;
+    public:
+      typedef Number ValueType;
+      typedef Edge KeyType;
+      ResCap(const ResGraphWrapper<Graph, Number, CapacityMap, FlowMap>& _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<typename Graph, typename Number, 



More information about the Lemon-commits mailing list