Index: src/work/marci/graph_wrapper.h
===================================================================
--- src/work/marci/graph_wrapper.h	(revision 265)
+++ src/work/marci/graph_wrapper.h	(revision 266)
@@ -124,5 +124,5 @@
     template<typename T> class NodeMap : public Graph::NodeMap<T> { 
     public:
-      NodeMap(const TrivGraphWrapper<Graph>& _G) : 
+      NodeMap(const TrivGraphWrapper<Graph>& _G) :  
 	Graph::NodeMap<T>(*(_G.graph)) { }
       NodeMap(const TrivGraphWrapper<Graph>& _G, T a) : 
@@ -132,8 +132,30 @@
     template<typename T> class EdgeMap : public Graph::EdgeMap<T> { 
     public:
-      EdgeMap(const TrivGraphWrapper<Graph>& _G) : 
+      EdgeMap(const TrivGraphWrapper<Graph>& _G) :  
 	Graph::EdgeMap<T>(*(_G.graph)) { }
       EdgeMap(const TrivGraphWrapper<Graph>& _G, T a) : 
 	Graph::EdgeMap<T>(*(_G.graph), a) { }
+    };
+
+    template<typename Map, typename T> class NodeMapWrapper {
+    protected:
+      Map* map;
+    public:
+      NodeMapWrapper(Map& _map) : map(&_map) { }
+      //template<typename T> 
+      void set(Node n, T a) { map->set(n, a); }
+      //template<typename T>
+      T get(Node n) const { return map->get(n); }
+    };
+
+    template<typename Map, typename T> class EdgeMapWrapper {
+    protected:
+      Map* map;
+    public:
+      EdgeMapWrapper(Map& _map) : map(&_map) { }
+      //template<typename T> 
+      void set(Edge n, T a) { map->set(n, a); }
+      //template<typename T>
+      T get(Edge n) const { return map->get(n); }
     };
   };
@@ -248,5 +270,5 @@
     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
     public:
-      NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 
+      NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :  
 	GraphWrapper::NodeMap<T>(_G.gw) { }
       NodeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : 
@@ -256,5 +278,5 @@
     template<typename T> class EdgeMap : public GraphWrapper::EdgeMap<T> { 
     public:
-      EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) : 
+      EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G) :  
 	GraphWrapper::EdgeMap<T>(_G.gw) { }
       EdgeMap(const GraphWrapperSkeleton<GraphWrapper>& _G, T a) : 
@@ -760,5 +782,5 @@
     template<typename I> I& first(I& i) const { gw.first(i); return i; }
     template<typename I, typename P> I& first(I& i, const P& p) const { 
-      graph->first(i, p); return i; }
+      gw.first(i, p); return i; }
 
     OutEdgeIt& next(OutEdgeIt& e) const {
@@ -912,24 +934,25 @@
 
 
-  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ResGraphWrapper {
+  template<typename GraphWrapper, typename Number, typename FlowMap, typename CapacityMap>
+  class ResGraphWrapper : public GraphWrapperSkeleton<GraphWrapper>{
   public:
     //typedef Graph BaseGraph;
-    typedef TrivGraphWrapper<const Graph> GraphWrapper;
-    typedef typename GraphWrapper::Node Node;
-    typedef typename GraphWrapper::NodeIt NodeIt;
+    //typedef TrivGraphWrapper<const Graph> GraphWrapper;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::Node Node;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::NodeIt NodeIt;
   private:
-    typedef typename GraphWrapper::OutEdgeIt OldOutEdgeIt;
-    typedef typename GraphWrapper::InEdgeIt OldInEdgeIt;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::OutEdgeIt OldOutEdgeIt;
+    typedef typename GraphWrapperSkeleton<GraphWrapper>::InEdgeIt OldInEdgeIt;
   protected:
     //const Graph* graph;
-    GraphWrapper gw;
+    //GraphWrapper gw;
     FlowMap* flow;
     const CapacityMap* capacity;
   public:
 
-    ResGraphWrapper(const Graph& _G, FlowMap& _flow, 
-	     const CapacityMap& _capacity) : 
-      gw(_G), flow(&_flow), capacity(&_capacity) { }
+    ResGraphWrapper(const GraphWrapper& _gw, FlowMap& _flow, 
+		    const CapacityMap& _capacity) : 
+      GraphWrapperSkeleton<GraphWrapper>(_gw), 
+      flow(&_flow), capacity(&_capacity) { }
 
     //void setGraph(const Graph& _graph) { graph = &_graph; }
@@ -942,5 +965,5 @@
 
     class Edge {
-      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
     protected:
       bool out_or_in; //true, iff out
@@ -968,5 +991,5 @@
 
     class OutEdgeIt : public Edge {
-      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
     public:
       OutEdgeIt() { }
@@ -975,5 +998,5 @@
       OutEdgeIt(const Invalid& i) : Edge(i) { }
     protected:
-      OutEdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 
+      OutEdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG, Node v) : Edge() { 
 	resG.gw.first(out, v);
 	while( resG.gw.valid(out) && !(resG.free(out)>0) ) { resG.gw.next(out); }
@@ -1007,5 +1030,5 @@
 
     class EdgeIt : public Edge {
-      friend class ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>;
+      friend class ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>;
       NodeIt v; 
     public:
@@ -1013,5 +1036,5 @@
       //EdgeIt(const EdgeIt& e) : Edge(e), v(e.v) { }
       EdgeIt(const Invalid& i) : Edge(i) { }
-      EdgeIt(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& resG) : Edge() { 
+      EdgeIt(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& resG) : Edge() { 
 	resG.gw.first(v);
 	if (resG.gw.valid(v)) resG.gw.first(out, v); else out=/*OldOutEdgeIt*/(INVALID);
@@ -1067,5 +1090,5 @@
     };
 
-    NodeIt& first(NodeIt& v) const { return gw.first(v); }
+    NodeIt& first(NodeIt& v) const { gw.first(v); return v; }
     OutEdgeIt& first(OutEdgeIt& e, Node v) const { 
       e=OutEdgeIt(*this, v); 
@@ -1186,11 +1209,11 @@
     }
 
-    template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
-    public:
-      NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) 
-	: GraphWrapper::NodeMap<T>(_G.gw) { }
-      NodeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, 
-	      T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
-    };
+//     template<typename T> class NodeMap : public GraphWrapper::NodeMap<T> { 
+//     public:
+//       NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) 
+// 	: GraphWrapper::NodeMap<T>(_G.gw) { }
+//       NodeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, 
+// 	      T a) : GraphWrapper::NodeMap<T>(_G.gw, a) { }
+//     };
 
 //     template <typename T>
@@ -1208,6 +1231,6 @@
       typename GraphWrapper::EdgeMap<T> forward_map, backward_map; 
     public:
-      EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
-      EdgeMap(const ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
+      EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G) : forward_map(_G.gw), backward_map(_G.gw) { }
+      EdgeMap(const ResGraphWrapper<GraphWrapper, Number, FlowMap, CapacityMap>& _G, T a) : forward_map(_G.gw, a), backward_map(_G.gw, a) { }
       void set(Edge e, T a) { 
 	if (e.out_or_in) 
@@ -1225,241 +1248,241 @@
   };
 
-  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
-  protected:
-    ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
-    //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
-  public:
-    ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow, 
-			   const CapacityMap& _capacity) : 
-      ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), 
-      first_out_edges(*this) /*, dist(*this)*/ { 
-      for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
-	OutEdgeIt e;
-	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
-	first_out_edges.set(n, e);
-      }
-    }
-
-    //void setGraph(Graph& _graph) { graph = &_graph; }
-    //Graph& getGraph() const { return (*graph); }
-  
-    //TrivGraphWrapper() : graph(0) { }
-    //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
-
-    //typedef Graph BaseGraph;
-
-    //typedef typename Graph::Node Node;
-    //typedef typename Graph::NodeIt NodeIt;
-
-    //typedef typename Graph::Edge Edge;
-    //typedef typename Graph::OutEdgeIt OutEdgeIt;
-    //typedef typename Graph::InEdgeIt InEdgeIt;
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    //typedef typename Graph::EdgeIt EdgeIt;
-
-    typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
-    typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
-
-    typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
-    typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
-    //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
-
-    NodeIt& first(NodeIt& n) const { 
-      return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
-    }
-
-    OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 
-      e=first_out_edges.get(n);
-      return e;
-    }
-    
-    //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
-    //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { 
-    //  return first(i, p); }
-    
-    //template<typename I> I getNext(const I& i) const { 
-    //  return gw.getNext(i); }
-    //template<typename I> I& next(I &i) const { return gw.next(i); }    
-
-    template< typename It > It first() const { 
-      It e; first(e); return e; }
-
-    template< typename It > It first(const Node& v) const { 
-      It e; first(e, v); return e; }
-
-    //Node head(const Edge& e) const { return gw.head(e); }
-    //Node tail(const Edge& e) const { return gw.tail(e); }
-
-    //template<typename I> bool valid(const I& i) const 
-    //  { return gw.valid(i); }
-  
-    //int nodeNum() const { return gw.nodeNum(); }
-    //int edgeNum() const { return gw.edgeNum(); }
-  
-    //template<typename I> Node aNode(const I& e) const { 
-    //  return gw.aNode(e); }
-    //template<typename I> Node bNode(const I& e) const { 
-    //  return gw.bNode(e); }
-  
-    //Node addNode() const { return gw.addNode(); }
-    //Edge addEdge(const Node& tail, const Node& head) const { 
-    //  return gw.addEdge(tail, head); }
-  
-    //void erase(const OutEdgeIt& e) {
-    //  first_out_edge(this->tail(e))=e;
-    //}
-    void erase(const Edge& e) {
-      OutEdgeIt f(e);
-      next(f);
-      first_out_edges.set(this->tail(e), f);
-    }
-    //template<typename I> void erase(const I& i) const { gw.erase(i); }
-  
-    //void clear() const { gw.clear(); }
-    
-    template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
-    public:
-      NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
-	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
-      NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
-	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
-    };
-
-    template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
-    public:
-      EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
-	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
-      EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
-	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
-    };
-  };
-
-  template<typename GraphWrapper> 
-  class FilterGraphWrapper {
-  };
-
-  template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
-  class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
-
-    //Graph* graph;
-  
-  public:
-    //typedef Graph BaseGraph;
-
-    typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
-    typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
-
-    typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
-    typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
-    //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
-    //typedef typename Graph::SymEdgeIt SymEdgeIt;
-    typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
-
-    //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
-    
-  public:
-    FilterGraphWrapper(const Graph& _G, FlowMap& _flow, 
-			   const CapacityMap& _capacity) : 
-      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) { 
-    }
-
-    OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
-      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
-      while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
-      return e;
-    }
-
-    NodeIt& next(NodeIt& e) const {
-      return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
-    }
-
-    OutEdgeIt& next(OutEdgeIt& e) const {
-      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
-      while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e)))) 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
-      return e;
-    }
-
-    NodeIt& first(NodeIt& n) const {
-      return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
-    }
-
-    void erase(const Edge& e) {
-      OutEdgeIt f(e);
-      ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
-      while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f)))) 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
-      first_out_edges.set(this->tail(e), f);
-    }
-
-    //TrivGraphWrapper() : graph(0) { }
-    //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
-
-    //void setGraph(Graph& _graph) { graph = &_graph; }
-    //Graph& getGraph() const { return (*graph); }
-    
-    //template<typename I> I& first(I& i) const { return gw.first(i); }
-    //template<typename I, typename P> I& first(I& i, const P& p) const { 
-    //  return gw.first(i, p); }
-    
-    //template<typename I> I getNext(const I& i) const { 
-    //  return gw.getNext(i); }
-    //template<typename I> I& next(I &i) const { return gw.next(i); }    
-
-    template< typename It > It first() const { 
-      It e; first(e); return e; }
-
-    template< typename It > It first(const Node& v) const { 
-      It e; first(e, v); return e; }
-
-    //Node head(const Edge& e) const { return gw.head(e); }
-    //Node tail(const Edge& e) const { return gw.tail(e); }
-
-    //template<typename I> bool valid(const I& i) const 
-    //  { return gw.valid(i); }
-  
-    //template<typename I> void setInvalid(const I &i);
-    //{ return gw.setInvalid(i); }
-
-    //int nodeNum() const { return gw.nodeNum(); }
-    //int edgeNum() const { return gw.edgeNum(); }
-  
-    //template<typename I> Node aNode(const I& e) const { 
-    //  return gw.aNode(e); }
-    //template<typename I> Node bNode(const I& e) const { 
-    //  return gw.bNode(e); }
-  
-    //Node addNode() const { return gw.addNode(); }
-    //Edge addEdge(const Node& tail, const Node& head) const { 
-    //  return gw.addEdge(tail, head); }
-  
-    //template<typename I> void erase(const I& i) const { gw.erase(i); }
-  
-    //void clear() const { gw.clear(); }
-    
-    template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
-    public:
-      NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
-      NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
-    };
-
-    template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
-    public:
-      EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
-      EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
-	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
-    };
-
-  public:
-    ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
-
-  };
+//   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+//   class ErasingResGraphWrapper : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
+//   protected:
+//     ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
+//     //ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
+//   public:
+//     ErasingResGraphWrapper(const Graph& _G, FlowMap& _flow, 
+// 			   const CapacityMap& _capacity) : 
+//       ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), 
+//       first_out_edges(*this) /*, dist(*this)*/ { 
+//       for(NodeIt n=this->template first<NodeIt>(); this->valid(n); this->next(n)) {
+// 	OutEdgeIt e;
+// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
+// 	first_out_edges.set(n, e);
+//       }
+//     }
+
+//     //void setGraph(Graph& _graph) { graph = &_graph; }
+//     //Graph& getGraph() const { return (*graph); }
+  
+//     //TrivGraphWrapper() : graph(0) { }
+//     //ErasingResGraphWrapper(Graph& _graph) : graph(&_graph) { }
+
+//     //typedef Graph BaseGraph;
+
+//     //typedef typename Graph::Node Node;
+//     //typedef typename Graph::NodeIt NodeIt;
+
+//     //typedef typename Graph::Edge Edge;
+//     //typedef typename Graph::OutEdgeIt OutEdgeIt;
+//     //typedef typename Graph::InEdgeIt InEdgeIt;
+//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
+//     //typedef typename Graph::EdgeIt EdgeIt;
+
+//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
+//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
+
+//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
+//     typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
+//     //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
+//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
+//     //typedef typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
+
+//     NodeIt& first(NodeIt& n) const { 
+//       return ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
+//     }
+
+//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const { 
+//       e=first_out_edges.get(n);
+//       return e;
+//     }
+    
+//     //ROSSZ template<typename I> I& first(I& i) const { return first(i); }
+//     //ROSSZ template<typename I, typename P> I& first(I& i, const P& p) const { 
+//     //  return first(i, p); }
+    
+//     //template<typename I> I getNext(const I& i) const { 
+//     //  return gw.getNext(i); }
+//     //template<typename I> I& next(I &i) const { return gw.next(i); }    
+
+//     template< typename It > It first() const { 
+//       It e; first(e); return e; }
+
+//     template< typename It > It first(const Node& v) const { 
+//       It e; first(e, v); return e; }
+
+//     //Node head(const Edge& e) const { return gw.head(e); }
+//     //Node tail(const Edge& e) const { return gw.tail(e); }
+
+//     //template<typename I> bool valid(const I& i) const 
+//     //  { return gw.valid(i); }
+  
+//     //int nodeNum() const { return gw.nodeNum(); }
+//     //int edgeNum() const { return gw.edgeNum(); }
+  
+//     //template<typename I> Node aNode(const I& e) const { 
+//     //  return gw.aNode(e); }
+//     //template<typename I> Node bNode(const I& e) const { 
+//     //  return gw.bNode(e); }
+  
+//     //Node addNode() const { return gw.addNode(); }
+//     //Edge addEdge(const Node& tail, const Node& head) const { 
+//     //  return gw.addEdge(tail, head); }
+  
+//     //void erase(const OutEdgeIt& e) {
+//     //  first_out_edge(this->tail(e))=e;
+//     //}
+//     void erase(const Edge& e) {
+//       OutEdgeIt f(e);
+//       next(f);
+//       first_out_edges.set(this->tail(e), f);
+//     }
+//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
+  
+//     //void clear() const { gw.clear(); }
+    
+//     template<typename T> class NodeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
+//     public:
+//       NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
+// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
+//       NodeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
+// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
+//     };
+
+//     template<typename T> class EdgeMap : public ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
+//     public:
+//       EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G) : 
+// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
+//       EdgeMap(const ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>& _G, T a) : 
+// 	ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
+//     };
+//   };
+
+//   template<typename GraphWrapper> 
+//   class FilterGraphWrapper {
+//   };
+
+//   template<typename Graph, typename Number, typename FlowMap, typename CapacityMap>
+//   class FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> > : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> {
+
+//     //Graph* graph;
+  
+//   public:
+//     //typedef Graph BaseGraph;
+
+//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Node Node;
+//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeIt NodeIt;
+
+//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::Edge Edge;
+//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt OutEdgeIt;
+//     //typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::InEdgeIt InEdgeIt;
+//     //typedef typename Graph::SymEdgeIt SymEdgeIt;
+//     typedef typename ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeIt EdgeIt;
+
+//     //FilterGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<typename ResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::OutEdgeIt> first_out_edges;
+    
+//   public:
+//     FilterGraphWrapper(const Graph& _G, FlowMap& _flow, 
+// 			   const CapacityMap& _capacity) : 
+//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>(_G, _flow, _capacity), dist(*this, gw.nodeNum()) { 
+//     }
+
+//     OutEdgeIt& first(OutEdgeIt& e, const Node& n) const {
+//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(e, n);
+//       while (valid(e) && (dist.get(tail(e))/*+1!=*/>=dist.get(head(e)))) 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+//       return e;
+//     }
+
+//     NodeIt& next(NodeIt& e) const {
+//       return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+//     }
+
+//     OutEdgeIt& next(OutEdgeIt& e) const {
+//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+//       while (valid(e) && (dist.get(tail(e))/*+1!*/>=dist.get(head(e)))) 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(e);
+//       return e;
+//     }
+
+//     NodeIt& first(NodeIt& n) const {
+//       return ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::first(n);
+//     }
+
+//     void erase(const Edge& e) {
+//       OutEdgeIt f(e);
+//       ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
+//       while (valid(f) && (dist.get(tail(f))/*+1!=*/>=dist.get(head(f)))) 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::next(f);
+//       first_out_edges.set(this->tail(e), f);
+//     }
+
+//     //TrivGraphWrapper() : graph(0) { }
+//     //TrivGraphWrapper(Graph& _graph) : graph(&_graph) { }
+
+//     //void setGraph(Graph& _graph) { graph = &_graph; }
+//     //Graph& getGraph() const { return (*graph); }
+    
+//     //template<typename I> I& first(I& i) const { return gw.first(i); }
+//     //template<typename I, typename P> I& first(I& i, const P& p) const { 
+//     //  return gw.first(i, p); }
+    
+//     //template<typename I> I getNext(const I& i) const { 
+//     //  return gw.getNext(i); }
+//     //template<typename I> I& next(I &i) const { return gw.next(i); }    
+
+//     template< typename It > It first() const { 
+//       It e; first(e); return e; }
+
+//     template< typename It > It first(const Node& v) const { 
+//       It e; first(e, v); return e; }
+
+//     //Node head(const Edge& e) const { return gw.head(e); }
+//     //Node tail(const Edge& e) const { return gw.tail(e); }
+
+//     //template<typename I> bool valid(const I& i) const 
+//     //  { return gw.valid(i); }
+  
+//     //template<typename I> void setInvalid(const I &i);
+//     //{ return gw.setInvalid(i); }
+
+//     //int nodeNum() const { return gw.nodeNum(); }
+//     //int edgeNum() const { return gw.edgeNum(); }
+  
+//     //template<typename I> Node aNode(const I& e) const { 
+//     //  return gw.aNode(e); }
+//     //template<typename I> Node bNode(const I& e) const { 
+//     //  return gw.bNode(e); }
+  
+//     //Node addNode() const { return gw.addNode(); }
+//     //Edge addEdge(const Node& tail, const Node& head) const { 
+//     //  return gw.addEdge(tail, head); }
+  
+//     //template<typename I> void erase(const I& i) const { gw.erase(i); }
+  
+//     //void clear() const { gw.clear(); }
+    
+//     template<typename T> class NodeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T> { 
+//     public:
+//       NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/) { }
+//       NodeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<T>(_G /*_G.getGraph()*/, a) { }
+//     };
+
+//     template<typename T> class EdgeMap : public ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T> { 
+//     public:
+//       EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G) : 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/) { }
+//       EdgeMap(const FilterGraphWrapper<ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap> >& _G, T a) : 
+// 	ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::EdgeMap<T>(_G /*_G.getGraph()*/, a) { }
+//     };
+
+//   public:
+//     ErasingResGraphWrapper<Graph, Number, FlowMap, CapacityMap>::NodeMap<int> dist;
+
+//   };
 
 
