Index: src/work/marci/edmonds_karp.h
===================================================================
--- src/work/marci/edmonds_karp.h	(revision 317)
+++ src/work/marci/edmonds_karp.h	(revision 330)
@@ -14,241 +14,241 @@
 namespace hugo {
 
-  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ResGraph {
-  public:
-    typedef typename Graph::Node Node;
-    typedef typename Graph::NodeIt NodeIt;
-  private:
-    typedef typename Graph::SymEdgeIt OldSymEdgeIt;
-    const Graph& G;
-    FlowMap& flow;
-    const CapacityMap& capacity;
-  public:
-    ResGraph(const Graph& _G, FlowMap& _flow, 
-	     const CapacityMap& _capacity) : 
-      G(_G), flow(_flow), capacity(_capacity) { }
-
-    class Edge; 
-    class OutEdgeIt; 
-    friend class Edge; 
-    friend class OutEdgeIt; 
-
-    class Edge {
-      friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
-    protected:
-      const ResGraph<Graph, Number, FlowMap, CapacityMap>* resG;
-      OldSymEdgeIt sym;
-    public:
-      Edge() { } 
-      //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { }
-      Number free() const { 
-	if (resG->G.aNode(sym)==resG->G.tail(sym)) { 
-	  return (resG->capacity.get(sym)-resG->flow.get(sym)); 
-	} else { 
-	  return (resG->flow.get(sym)); 
-	}
-      }
-      bool valid() const { return sym.valid(); }
-      void augment(Number a) const {
-	if (resG->G.aNode(sym)==resG->G.tail(sym)) { 
-	  resG->flow.set(sym, resG->flow.get(sym)+a);
-	  //resG->flow[sym]+=a;
-	} else { 
-	  resG->flow.set(sym, resG->flow.get(sym)-a);
-	  //resG->flow[sym]-=a;
-	}
-      }
-    };
-
-    class OutEdgeIt : public Edge {
-      friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
-    public:
-      OutEdgeIt() { }
-      //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; }
-    private:
-      OutEdgeIt(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _resG, Node v) { 
-      	resG=&_resG;
-	sym=resG->G.template first<OldSymEdgeIt>(v);
-	while( sym.valid() && !(free()>0) ) { ++sym; }
-      }
-    public:
-      OutEdgeIt& operator++() { 
-	++sym; 
-	while( sym.valid() && !(free()>0) ) { ++sym; }
-	return *this; 
-      }
-    };
-
-    void /*getF*/first(OutEdgeIt& e, Node v) const { 
-      e=OutEdgeIt(*this, v); 
-    }
-    void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); }
+//   template<typename Graph, typename Number, typename CapacityMap, typename FlowMap>
+//   class ResGraph {
+//   public:
+//     typedef typename Graph::Node Node;
+//     typedef typename Graph::NodeIt NodeIt;
+//   private:
+//     typedef typename Graph::SymEdgeIt OldSymEdgeIt;
+//     const Graph& G;
+//     const CapacityMap& capacity;
+//     FlowMap& flow;
+//   public:
+//     ResGraph(const Graph& _G, const CapacityMap& _capacity, FlowMap& _flow) : 
+//       G(_G), capacity(_capacity), flow(_flow) { }
+
+//     class Edge; 
+//     class OutEdgeIt; 
+//     friend class Edge; 
+//     friend class OutEdgeIt; 
+
+//     class Edge {
+//       friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
+//     protected:
+//       const ResGraph<Graph, Number, FlowMap, CapacityMap>* resG;
+//       OldSymEdgeIt sym;
+//     public:
+//       Edge() { } 
+//       //Edge(const Edge& e) : resG(e.resG), sym(e.sym) { }
+//       Number free() const { 
+// 	if (resG->G.aNode(sym)==resG->G.tail(sym)) { 
+// 	  return (resG->capacity.get(sym)-resG->flow.get(sym)); 
+// 	} else { 
+// 	  return (resG->flow.get(sym)); 
+// 	}
+//       }
+//       bool valid() const { return sym.valid(); }
+//       void augment(Number a) const {
+// 	if (resG->G.aNode(sym)==resG->G.tail(sym)) { 
+// 	  resG->flow.set(sym, resG->flow.get(sym)+a);
+// 	  //resG->flow[sym]+=a;
+// 	} else { 
+// 	  resG->flow.set(sym, resG->flow.get(sym)-a);
+// 	  //resG->flow[sym]-=a;
+// 	}
+//       }
+//     };
+
+//     class OutEdgeIt : public Edge {
+//       friend class ResGraph<Graph, Number, FlowMap, CapacityMap>;
+//     public:
+//       OutEdgeIt() { }
+//       //OutEdgeIt(const OutEdgeIt& e) { resG=e.resG; sym=e.sym; }
+//     private:
+//       OutEdgeIt(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _resG, Node v) { 
+//       	resG=&_resG;
+// 	sym=resG->G.template first<OldSymEdgeIt>(v);
+// 	while( sym.valid() && !(free()>0) ) { ++sym; }
+//       }
+//     public:
+//       OutEdgeIt& operator++() { 
+// 	++sym; 
+// 	while( sym.valid() && !(free()>0) ) { ++sym; }
+// 	return *this; 
+//       }
+//     };
+
+//     void /*getF*/first(OutEdgeIt& e, Node v) const { 
+//       e=OutEdgeIt(*this, v); 
+//     }
+//     void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); }
     
-    template< typename It >
-    It first() const { 
-      It e;      
-      /*getF*/first(e);
-      return e; 
-    }
-
-    template< typename It >
-    It first(Node v) const { 
-      It e;
-      /*getF*/first(e, v);
-      return e; 
-    }
-
-    Node tail(Edge e) const { return G.aNode(e.sym); }
-    Node head(Edge e) const { return G.bNode(e.sym); }
-
-    Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); }
-    Node bNode(OutEdgeIt e) const { return G.bNode(e.sym); }
-
-    int id(Node v) const { return G.id(v); }
-
-    template <typename S>
-    class NodeMap {
-      typename Graph::NodeMap<S> node_map; 
-    public:
-      NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
-      NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
-      void set(Node nit, S a) { node_map.set(nit, a); }
-      S get(Node nit) const { return node_map.get(nit); }
-      S& operator[](Node nit) { return node_map[nit]; } 
-      const S& operator[](Node nit) const { return node_map[nit]; } 
-    };
-
-  };
-
-
-  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ResGraph2 {
-  public:
-    typedef typename Graph::Node Node;
-    typedef typename Graph::NodeIt NodeIt;
-  private:
-    //typedef typename Graph::SymEdgeIt OldSymEdgeIt;
-    typedef typename Graph::OutEdgeIt OldOutEdgeIt;
-    typedef typename Graph::InEdgeIt OldInEdgeIt;
+//     template< typename It >
+//     It first() const { 
+//       It e;      
+//       /*getF*/first(e);
+//       return e; 
+//     }
+
+//     template< typename It >
+//     It first(Node v) const { 
+//       It e;
+//       /*getF*/first(e, v);
+//       return e; 
+//     }
+
+//     Node tail(Edge e) const { return G.aNode(e.sym); }
+//     Node head(Edge e) const { return G.bNode(e.sym); }
+
+//     Node aNode(OutEdgeIt e) const { return G.aNode(e.sym); }
+//     Node bNode(OutEdgeIt e) const { return G.bNode(e.sym); }
+
+//     int id(Node v) const { return G.id(v); }
+
+//     template <typename S>
+//     class NodeMap {
+//       typename Graph::NodeMap<S> node_map; 
+//     public:
+//       NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
+//       NodeMap(const ResGraph<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
+//       void set(Node nit, S a) { node_map.set(nit, a); }
+//       S get(Node nit) const { return node_map.get(nit); }
+//       S& operator[](Node nit) { return node_map[nit]; } 
+//       const S& operator[](Node nit) const { return node_map[nit]; } 
+//     };
+
+//   };
+
+
+//   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+//   class ResGraph2 {
+//   public:
+//     typedef typename Graph::Node Node;
+//     typedef typename Graph::NodeIt NodeIt;
+//   private:
+//     //typedef typename Graph::SymEdgeIt OldSymEdgeIt;
+//     typedef typename Graph::OutEdgeIt OldOutEdgeIt;
+//     typedef typename Graph::InEdgeIt OldInEdgeIt;
     
-    const Graph& G;
-    FlowMap& flow;
-    const CapacityMap& capacity;
-  public:
-    ResGraph2(const Graph& _G, FlowMap& _flow, 
-	     const CapacityMap& _capacity) : 
-      G(_G), flow(_flow), capacity(_capacity) { }
-
-    class Edge; 
-    class OutEdgeIt; 
-    friend class Edge; 
-    friend class OutEdgeIt; 
-
-    class Edge {
-      friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
-    protected:
-      const ResGraph2<Graph, Number, FlowMap, CapacityMap>* resG;
-      //OldSymEdgeIt sym;
-      OldOutEdgeIt out;
-      OldInEdgeIt in;
-      bool out_or_in; //true, iff out
-    public:
-      Edge() : out_or_in(true) { } 
-      Number free() const { 
-	if (out_or_in) { 
-	  return (resG->capacity.get(out)-resG->flow.get(out)); 
-	} else { 
-	  return (resG->flow.get(in)); 
-	}
-      }
-      bool valid() const { 
-	return out_or_in && out.valid() || in.valid(); }
-      void augment(Number a) const {
-	if (out_or_in) { 
-	  resG->flow.set(out, resG->flow.get(out)+a);
-	} else { 
-	  resG->flow.set(in, resG->flow.get(in)-a);
-	}
-      }
-    };
-
-    class OutEdgeIt : public Edge {
-      friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
-    public:
-      OutEdgeIt() { }
-    private:
-      OutEdgeIt(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _resG, Node v) { 
-      	resG=&_resG;
-	out=resG->G.template first<OldOutEdgeIt>(v);
-	while( out.valid() && !(free()>0) ) { ++out; }
-	if (!out.valid()) {
-	  out_or_in=0;
-	  in=resG->G.template first<OldInEdgeIt>(v);
-	  while( in.valid() && !(free()>0) ) { ++in; }
-	}
-      }
-    public:
-      OutEdgeIt& operator++() { 
-	if (out_or_in) {
-	  Node v=resG->G.aNode(out);
-	  ++out;
-	  while( out.valid() && !(free()>0) ) { ++out; }
-	  if (!out.valid()) {
-	    out_or_in=0;
-	    in=resG->G.template first<OldInEdgeIt>(v);
-	    while( in.valid() && !(free()>0) ) { ++in; }
-	  }
-	} else {
-	  ++in;
-	  while( in.valid() && !(free()>0) ) { ++in; } 
-	}
-	return *this; 
-      }
-    };
-
-    void /*getF*/first(OutEdgeIt& e, Node v) const { 
-      e=OutEdgeIt(*this, v); 
-    }
-    void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); }
+//     const Graph& G;
+//     FlowMap& flow;
+//     const CapacityMap& capacity;
+//   public:
+//     ResGraph2(const Graph& _G, FlowMap& _flow, 
+// 	     const CapacityMap& _capacity) : 
+//       G(_G), flow(_flow), capacity(_capacity) { }
+
+//     class Edge; 
+//     class OutEdgeIt; 
+//     friend class Edge; 
+//     friend class OutEdgeIt; 
+
+//     class Edge {
+//       friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
+//     protected:
+//       const ResGraph2<Graph, Number, FlowMap, CapacityMap>* resG;
+//       //OldSymEdgeIt sym;
+//       OldOutEdgeIt out;
+//       OldInEdgeIt in;
+//       bool out_or_in; //true, iff out
+//     public:
+//       Edge() : out_or_in(true) { } 
+//       Number free() const { 
+// 	if (out_or_in) { 
+// 	  return (resG->capacity.get(out)-resG->flow.get(out)); 
+// 	} else { 
+// 	  return (resG->flow.get(in)); 
+// 	}
+//       }
+//       bool valid() const { 
+// 	return out_or_in && out.valid() || in.valid(); }
+//       void augment(Number a) const {
+// 	if (out_or_in) { 
+// 	  resG->flow.set(out, resG->flow.get(out)+a);
+// 	} else { 
+// 	  resG->flow.set(in, resG->flow.get(in)-a);
+// 	}
+//       }
+//     };
+
+//     class OutEdgeIt : public Edge {
+//       friend class ResGraph2<Graph, Number, FlowMap, CapacityMap>;
+//     public:
+//       OutEdgeIt() { }
+//     private:
+//       OutEdgeIt(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _resG, Node v) { 
+//       	resG=&_resG;
+// 	out=resG->G.template first<OldOutEdgeIt>(v);
+// 	while( out.valid() && !(free()>0) ) { ++out; }
+// 	if (!out.valid()) {
+// 	  out_or_in=0;
+// 	  in=resG->G.template first<OldInEdgeIt>(v);
+// 	  while( in.valid() && !(free()>0) ) { ++in; }
+// 	}
+//       }
+//     public:
+//       OutEdgeIt& operator++() { 
+// 	if (out_or_in) {
+// 	  Node v=resG->G.aNode(out);
+// 	  ++out;
+// 	  while( out.valid() && !(free()>0) ) { ++out; }
+// 	  if (!out.valid()) {
+// 	    out_or_in=0;
+// 	    in=resG->G.template first<OldInEdgeIt>(v);
+// 	    while( in.valid() && !(free()>0) ) { ++in; }
+// 	  }
+// 	} else {
+// 	  ++in;
+// 	  while( in.valid() && !(free()>0) ) { ++in; } 
+// 	}
+// 	return *this; 
+//       }
+//     };
+
+//     void /*getF*/first(OutEdgeIt& e, Node v) const { 
+//       e=OutEdgeIt(*this, v); 
+//     }
+//     void /*getF*/first(NodeIt& v) const { G./*getF*/first(v); }
     
-    template< typename It >
-    It first() const { 
-      It e;
-      /*getF*/first(e);
-      return e; 
-    }
-
-    template< typename It >
-    It first(Node v) const { 
-      It e;
-      /*getF*/first(e, v);
-      return e; 
-    }
-
-    Node tail(Edge e) const { 
-      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
-    Node head(Edge e) const { 
-      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
-
-    Node aNode(OutEdgeIt e) const { 
-      return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
-    Node bNode(OutEdgeIt e) const { 
-      return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
-
-    int id(Node v) const { return G.id(v); }
-
-    template <typename S>
-    class NodeMap {
-      typename Graph::NodeMap<S> node_map; 
-    public:
-      NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
-      NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
-      void set(Node nit, S a) { node_map.set(nit, a); }
-      S get(Node nit) const { return node_map.get(nit); }
-    };
-  };
-
-
-  template <typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+//     template< typename It >
+//     It first() const { 
+//       It e;
+//       /*getF*/first(e);
+//       return e; 
+//     }
+
+//     template< typename It >
+//     It first(Node v) const { 
+//       It e;
+//       /*getF*/first(e, v);
+//       return e; 
+//     }
+
+//     Node tail(Edge e) const { 
+//       return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
+//     Node head(Edge e) const { 
+//       return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
+
+//     Node aNode(OutEdgeIt e) const { 
+//       return ((e.out_or_in) ? G.aNode(e.out) : G.aNode(e.in)); }
+//     Node bNode(OutEdgeIt e) const { 
+//       return ((e.out_or_in) ? G.bNode(e.out) : G.bNode(e.in)); }
+
+//     int id(Node v) const { return G.id(v); }
+
+//     template <typename S>
+//     class NodeMap {
+//       typename Graph::NodeMap<S> node_map; 
+//     public:
+//       NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G) : node_map(_G.G) { }
+//       NodeMap(const ResGraph2<Graph, Number, FlowMap, CapacityMap>& _G, S a) : node_map(_G.G, a) { }
+//       void set(Node nit, S a) { node_map.set(nit, a); }
+//       S get(Node nit) const { return node_map.get(nit); }
+//     };
+//   };
+
+
+  template <typename Graph, typename Number, 
+	    typename CapacityMap, typename FlowMap>
   class MaxFlow {
   protected:
@@ -261,16 +261,17 @@
     Node s;
     Node t;
+    const CapacityMap* capacity;
     FlowMap* flow;
-    const CapacityMap* capacity;
-    typedef ResGraphWrapper<const Graph, Number, FlowMap, CapacityMap > ResGW;
+    typedef ResGraphWrapper<const Graph, Number, CapacityMap, FlowMap> ResGW;
     typedef typename ResGW::OutEdgeIt ResGWOutEdgeIt;
     typedef typename ResGW::Edge ResGWEdge;
   public:
 
-    MaxFlow(const Graph& _g, Node _s, Node _t, FlowMap& _flow, const CapacityMap& _capacity) : 
-      g(&_g), s(_s), t(_t), flow(&_flow), capacity(&_capacity) { }
+    MaxFlow(const Graph& _g, Node _s, Node _t, const CapacityMap& _capacity, 
+	    FlowMap& _flow) : 
+      g(&_g), s(_s), t(_t), capacity(&_capacity), flow(&_flow) { }
 
     bool augmentOnShortestPath() {
-      ResGW res_graph(*g, *flow, *capacity);
+      ResGW res_graph(*g, *capacity, *flow);
       bool _augment=false;
       
@@ -337,5 +338,5 @@
       bool _augment=false;
 
-      ResGW res_graph(*g, *flow, *capacity);
+      ResGW res_graph(*g, *capacity, *flow);
 
       BfsIterator5< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph);
@@ -446,5 +447,5 @@
       bool _augment=false;
 
-      ResGW res_graph(*g, *flow, *capacity);
+      ResGW res_graph(*g, *capacity, *flow);
 
       //bfs for distances on the residual graph
@@ -551,5 +552,5 @@
       bool _augment=false;
 
-      ResGW res_graph(*g, *flow, *capacity);
+      ResGW res_graph(*g, *capacity, *flow);
 
       BfsIterator5< ResGW, typename ResGW::NodeMap<bool> > bfs(res_graph);
