[Lemon-commits] [lemon_svn] marci: r1387 - in hugo/trunk/src: lemon test

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


Author: marci
Date: Mon Nov 15 17:39:55 2004
New Revision: 1387

Modified:
   hugo/trunk/src/lemon/graph_wrapper.h
   hugo/trunk/src/test/graph_wrapper_test.cc

Log:
RevGraphWrapper modified according to the factory


Modified: hugo/trunk/src/lemon/graph_wrapper.h
==============================================================================
--- hugo/trunk/src/lemon/graph_wrapper.h	(original)
+++ hugo/trunk/src/lemon/graph_wrapper.h	Mon Nov 15 17:39:55 2004
@@ -211,6 +211,30 @@
     GraphWrapper(Graph& _graph) { setGraph(_graph); }
   };
 
+  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.
 
   ///\warning Graph wrappers are in even more experimental state than the other
@@ -234,71 +258,83 @@
   /// RevGraphWrapper<ListGraph> gw(g);
   /// \endcode
   ///\author Marton Makai
-  template<typename Graph>
-  class RevGraphWrapper : public GraphWrapper<Graph> {
+  template<typename _Graph>
+  class RevGraphWrapper : 
+    public IterableGraphExtender<RevGraphWrapperBase<_Graph> > {
   public:
-    typedef GraphWrapper<Graph> Parent; 
+    typedef _Graph Graph;
+    typedef IterableGraphExtender<
+      RevGraphWrapperBase<_Graph> > Parent;
   protected:
-    RevGraphWrapper() : GraphWrapper<Graph>() { }
+    RevGraphWrapper() { }
   public:
-    RevGraphWrapper(Graph& _graph) : GraphWrapper<Graph>(_graph) { }  
-    RevGraphWrapper(const RevGraphWrapper<Graph>& gw) : Parent(gw) { }
+    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; 
-      }
-    };
+//     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;
-    }
+//     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); }
+//     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);
+//     //    KEEP_MAPS(Parent, RevGraphWrapper);
 
-  };
+//   };
 
   
   template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap>

Modified: hugo/trunk/src/test/graph_wrapper_test.cc
==============================================================================
--- hugo/trunk/src/test/graph_wrapper_test.cc	(original)
+++ hugo/trunk/src/test/graph_wrapper_test.cc	Mon Nov 15 17:39:55 2004
@@ -44,7 +44,7 @@
   {
     checkConcept<StaticGraph, GraphWrapper<StaticGraph> >();
 
-//     function_requires<StaticGraphConcept<RevGraphWrapper<Graph> > >();
+    checkConcept<StaticGraph, RevGraphWrapper<StaticGraph> >();
 
     checkConcept<StaticGraph, SubGraphWrapper<StaticGraph, 
       StaticGraph::NodeMap<bool> , StaticGraph::EdgeMap<bool> > >();



More information about the Lemon-commits mailing list