Index: src/lemon/graph_wrapper.h
===================================================================
--- src/lemon/graph_wrapper.h	(revision 992)
+++ src/lemon/graph_wrapper.h	(revision 997)
@@ -212,4 +212,28 @@
   };
 
+  template <typename _Graph>
+  class RevGraphWrapperBase : public GraphWrapperBase<_Graph> {
+  public:
+    typedef _Graph Graph;
+    typedef GraphWrapperBase<_Graph> Parent;
+  protected:
+    RevGraphWrapperBase() : Parent() { }
+  public:
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    using Parent::first;
+    void firstIn(Edge& i, const Node& n) const { Parent::firstOut(i, n); }
+    void firstOut(Edge& i, const Node& n ) const { Parent::firstIn(i, n); }
+
+    using Parent::next;
+    void nextIn(Edge& i) const { Parent::nextOut(i); }
+    void nextOut(Edge& i) const { Parent::nextIn(i); }
+
+    Node source(const Edge& e) const { return Parent::target(e); }
+    Node target(const Edge& e) const { return Parent::source(e); }
+  };
+    
+
   /// A graph wrapper which reverses the orientation of the edges.
 
@@ -235,69 +259,81 @@
   /// \endcode
   ///\author Marton Makai
-  template<typename Graph>
-  class RevGraphWrapper : public GraphWrapper<Graph> {
-  public:
-    typedef GraphWrapper<Graph> Parent; 
+  template<typename _Graph>
+  class RevGraphWrapper : 
+    public IterableGraphExtender<RevGraphWrapperBase<_Graph> > {
+  public:
+    typedef _Graph Graph;
+    typedef IterableGraphExtender<
+      RevGraphWrapperBase<_Graph> > Parent;
   protected:
-    RevGraphWrapper() : GraphWrapper<Graph>() { }
-  public:
-    RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }  
-    RevGraphWrapper(const RevGraphWrapper<Graph>& gw) : Parent(gw) { }
-
-    typedef typename GraphWrapper<Graph>::Node Node;
-    typedef typename GraphWrapper<Graph>::Edge Edge;
-    //remark: OutEdgeIt and InEdgeIt cannot be typedef-ed to each other
-    //because this does not work is some of them are not defined in the 
-    //original graph. The problem with this is that typedef-ed stuff 
-    //are instantiated in c++.
-    class OutEdgeIt : public Edge { 
-      const RevGraphWrapper<Graph>* gw;
-      friend class GraphWrapper<Graph>;
-     public:
-      OutEdgeIt() { }
-      OutEdgeIt(Invalid i) : Edge(i) { }
-      OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
-	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
-      OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
-	Edge(e), gw(&_gw) { }
-      OutEdgeIt& operator++() { 
-	*(static_cast<Edge*>(this))=
-	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
-	return *this; 
-      }
-    };
-    class InEdgeIt : public Edge { 
-      const RevGraphWrapper<Graph>* gw;
-      friend class GraphWrapper<Graph>;
-     public:
-      InEdgeIt() { }
-      InEdgeIt(Invalid i) : Edge(i) { }
-      InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
-	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
-      InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
-	Edge(e), gw(&_gw) { }
-      InEdgeIt& 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;
-    }
-    InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
-      i=InEdgeIt(*this, p); return i;
-    }
-
-    Node source(const Edge& e) const { 
-      return GraphWrapper<Graph>::target(e); }
-    Node target(const Edge& e) const { 
-      return GraphWrapper<Graph>::source(e); }
-
-    //    KEEP_MAPS(Parent, RevGraphWrapper);
-
+    RevGraphWrapper() { }
+  public:
+    RevGraphWrapper(_Graph& _graph) { setGraph(_graph); }
   };
+//   template<typename Graph>
+//   class RevGraphWrapper : public GraphWrapper<Graph> {
+//   public:
+//     typedef GraphWrapper<Graph> Parent; 
+//   protected:
+//     RevGraphWrapper() : GraphWrapper<Graph>() { }
+//   public:
+//     RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }  
+//     RevGraphWrapper(const RevGraphWrapper<Graph>& gw) : Parent(gw) { }
+
+//     typedef typename GraphWrapper<Graph>::Node Node;
+//     typedef typename GraphWrapper<Graph>::Edge Edge;
+//     //remark: OutEdgeIt and InEdgeIt cannot be typedef-ed to each other
+//     //because this does not work is some of them are not defined in the 
+//     //original graph. The problem with this is that typedef-ed stuff 
+//     //are instantiated in c++.
+//     class OutEdgeIt : public Edge { 
+//       const RevGraphWrapper<Graph>* gw;
+//       friend class GraphWrapper<Graph>;
+//      public:
+//       OutEdgeIt() { }
+//       OutEdgeIt(Invalid i) : Edge(i) { }
+//       OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
+// 	Edge(typename Graph::InEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
+//       OutEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
+// 	Edge(e), gw(&_gw) { }
+//       OutEdgeIt& operator++() { 
+// 	*(static_cast<Edge*>(this))=
+// 	  ++(typename Graph::InEdgeIt(*(gw->graph), *this));
+// 	return *this; 
+//       }
+//     };
+//     class InEdgeIt : public Edge { 
+//       const RevGraphWrapper<Graph>* gw;
+//       friend class GraphWrapper<Graph>;
+//      public:
+//       InEdgeIt() { }
+//       InEdgeIt(Invalid i) : Edge(i) { }
+//       InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Node& n) : 
+// 	Edge(typename Graph::OutEdgeIt(*(_gw.graph), n)), gw(&_gw) { }
+//       InEdgeIt(const RevGraphWrapper<Graph>& _gw, const Edge& e) : 
+// 	Edge(e), gw(&_gw) { }
+//       InEdgeIt& 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;
+//     }
+//     InEdgeIt& first(InEdgeIt& i, const Node& p) const { 
+//       i=InEdgeIt(*this, p); return i;
+//     }
+
+//     Node source(const Edge& e) const { 
+//       return GraphWrapper<Graph>::target(e); }
+//     Node target(const Edge& e) const { 
+//       return GraphWrapper<Graph>::source(e); }
+
+//     //    KEEP_MAPS(Parent, RevGraphWrapper);
+
+//   };
 
   
