Index: src/lemon/graph_wrapper.h
===================================================================
--- src/lemon/graph_wrapper.h	(revision 997)
+++ src/lemon/graph_wrapper.h	(revision 998)
@@ -1800,4 +1800,66 @@
 
 
+
+  template <typename _Graph, typename FirstOutEdgesMap>
+  class ErasingFirstGraphWrapperBase : public GraphWrapperBase<_Graph> {
+  public:
+    typedef _Graph Graph;
+    typedef GraphWrapperBase<_Graph> Parent;
+  protected:
+    FirstOutEdgesMap* first_out_edges;
+    ErasingFirstGraphWrapperBase() : Parent(), 
+				     first_out_edges(0) { }
+
+    void setFirstOutEdgesMap(FirstOutEdgesMap& _first_out_edges) {
+      first_out_edges=&_first_out_edges;
+    }
+
+  public:
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+//     using Parent::first;
+//     void first(Node& i) const { 
+//       Parent::first(i); 
+//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
+//     }
+//     void first(Edge& i) const { 
+//       Parent::first(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); 
+//     }
+//     void firstIn(Edge& i, const Node& n) const { 
+//       Parent::firstIn(i, n); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); 
+//     }
+    void firstOut(Edge& i, const Node& n) const { 
+      i=(*first_out_edges)[n];
+    }
+
+    void erase(const Edge& e) const {
+      Node n=source(e);
+      Edge f=e;
+      Parent::nextOut(f);
+      first_out_edges->set(n, f);
+    }    
+//     void next(Node& i) const { 
+//       Parent::next(i); 
+//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i); 
+//     }
+//     void next(Edge& i) const { 
+//       Parent::next(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i); 
+//     }
+//     void nextIn(Edge& i) const { 
+//       Parent::nextIn(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i); 
+//     }
+//     void nextOut(Edge& i) const { 
+//       Parent::nextOut(i); 
+//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextOut(i); 
+//     }
+  };
+
+
   /// For blocking flows.
 
@@ -1814,50 +1876,68 @@
   ///
   /// \author Marton Makai
-  template<typename Graph, typename FirstOutEdgesMap>
-  class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
-  public:
-    typedef GraphWrapper<Graph> Parent; 
-  protected:
-    FirstOutEdgesMap* first_out_edges;
-  public:
+  template <typename _Graph, typename FirstOutEdgesMap>
+  class ErasingFirstGraphWrapper : 
+    public IterableGraphExtender<
+    ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > {
+  public:
+    typedef _Graph Graph;
+    typedef IterableGraphExtender<
+      ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > Parent;
     ErasingFirstGraphWrapper(Graph& _graph, 
-			     FirstOutEdgesMap& _first_out_edges) : 
-      GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
-
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::Edge Edge;
-    class OutEdgeIt : public Edge { 
-      friend class GraphWrapper<Graph>;
-      friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
-      const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
-    public:
-      OutEdgeIt() { }
-      OutEdgeIt(Invalid i) : Edge(i) { }
-      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
-		const Node& n) : 
-	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
-      OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
-		const Edge& e) : 
-	Edge(e), gw(&_gw) { }
-      OutEdgeIt& operator++() { 
-	*(static_cast<Edge*>(this))=
-	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
-	return *this; 
-      }
-    };
-
+			     FirstOutEdgesMap& _first_out_edges) { 
+      setGraph(_graph);
+      setFirstOutEdgesMap(_first_out_edges);
+    } 
 //     using GraphWrapper<Graph>::first;
 //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
 //       i=OutEdgeIt(*this, p); return i;
 //     }
-    void erase(const Edge& e) const {
-      Node n=source(e);
-      typename Graph::OutEdgeIt f(*Parent::graph, n);
-      ++f;
-      first_out_edges->set(n, f);
-    }
-
-    //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
   };
+//   template<typename Graph, typename FirstOutEdgesMap>
+//   class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
+//   public:
+//     typedef GraphWrapper<Graph> Parent; 
+//   protected:
+//     FirstOutEdgesMap* first_out_edges;
+//   public:
+//     ErasingFirstGraphWrapper(Graph& _graph, 
+// 			     FirstOutEdgesMap& _first_out_edges) : 
+//       GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { }  
+
+//     typedef typename GraphWrapper<Graph>::Node Node;
+//     typedef typename GraphWrapper<Graph>::Edge Edge;
+//     class OutEdgeIt : public Edge { 
+//       friend class GraphWrapper<Graph>;
+//       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
+//       const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
+//     public:
+//       OutEdgeIt() { }
+//       OutEdgeIt(Invalid i) : Edge(i) { }
+//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
+// 		const Node& n) : 
+// 	Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
+//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw, 
+// 		const Edge& e) : 
+// 	Edge(e), gw(&_gw) { }
+//       OutEdgeIt& operator++() { 
+// 	*(static_cast<Edge*>(this))=
+// 	  ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
+// 	return *this; 
+//       }
+//     };
+
+// //     using GraphWrapper<Graph>::first;
+// //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 
+// //       i=OutEdgeIt(*this, p); return i;
+// //     }
+//     void erase(const Edge& e) const {
+//       Node n=source(e);
+//       typename Graph::OutEdgeIt f(*Parent::graph, n);
+//       ++f;
+//       first_out_edges->set(n, f);
+//     }
+
+//     //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
+//   };
 
   ///@}
