[Lemon-commits] [lemon_svn] marci: r1273 - hugo/branches/graph_factory/src/lemon

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


Author: marci
Date: Wed Oct  6 16:53:08 2004
New Revision: 1273

Added:
   hugo/branches/graph_factory/src/lemon/graph_factory.h

Log:
GraphFactory class


Added: hugo/branches/graph_factory/src/lemon/graph_factory.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/graph_factory.h	Wed Oct  6 16:53:08 2004
@@ -0,0 +1,129 @@
+// -*- c++ -*-
+#ifndef LEMON_GRAPH_FACTORY_H
+#define LEMON_GRAPH_FACTORY_H
+
+#include <lemon/invalid.h>
+
+namespace lemon {
+  
+  template <typaneme GraphBase>
+  class GraphFactory : public GraphBase {
+//    typedef GraphBase Parent;
+    typedef GraphFactory<GraphBase> Graph;
+  public:
+    GraphFactory() : Parent() { }
+
+//    typedef typename Graph::Node Node;
+    class NodeIt : public Node { 
+      const Graph* g;
+//      friend class GraphWrapper<Graph>;
+    public:
+      NodeIt() { }
+      NodeIt(Invalid i) : Node(i) { }
+      NodeIt(const Graph& _g) : Node() {
+	_g.firstNode(*this);
+      }
+      NodeIt(const Graph& _g, const Node& n) : 
+	Node(n), g(&_g) { }
+      NodeIt& operator++() { 
+	g->nextNode(*this);
+	return *this; 
+      }
+    };
+//    typedef typename Graph::Edge Edge;
+    class EdgeIt : public Edge { 
+      const Graph* g;
+//      friend class GraphWrapper<Graph>;
+    public:
+      EdgeIt() { }
+      EdgeIt(Invalid i) : Edge(i) { }
+      EdgeIt(const Graph& _g) : Edge() {
+	_g.firstEdge(*this);
+      }
+      EdgeIt(const Graph& _g, const Edge& e) : 
+	Edge(e), g(&_g) { }
+      EdgeIt& operator++() { 
+	g->nextEdge(*this);
+	return *this; 
+      }
+    };
+    class OutEdgeIt : public Edge { 
+      const Graph* g;
+//      friend class GraphWrapper<Graph>;
+    public:
+      OutEdgeIt() { }
+      OutEdgeIt(Invalid i) : Edge(i) { }
+      OutEdgeIt(const Graph& _g, const Node& n) : Edge() {
+	_g.firstOutEdge(*this, n);
+      }
+      OutEdgeIt(const Graph& _g, const Edge& e) : 
+	Edge(e), g(&_g) { }
+      OutEdgeIt& operator++() { 
+	g->nextOutEdge(*this);
+	return *this; 
+      }
+    };
+    class InEdgeIt : public Edge { 
+      const Graph* g;
+//      friend class GraphWrapper<Graph>;
+    public:
+      InEdgeIt() { }
+      InEdgeIt(Invalid i) : Edge(i) { }
+      InEdgeIt(const Graph& _g, const Node& n) : Edge() {
+	_g.firstInEdge(*this, n);
+      }
+      InEdgeIt(const Graph& _g, const Edge& e) : 
+	Edge(e), g(&_g) { }
+      InEdgeIt& operator++() { 
+	g->nextInEdge(*this);
+	return *this; 
+      }
+    };
+   
+//     NodeIt& first(NodeIt& i) const { 
+//       i=NodeIt(*this); return i;
+//     }
+//     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;
+//     }
+//     EdgeIt& first(EdgeIt& i) const { 
+//       i=EdgeIt(*this); return i;
+//     }
+
+//     Node tail(const Edge& e) const { 
+//       return Node(graph->tail(static_cast<typename Graph::Edge>(e))); }
+//     Node head(const Edge& e) const { 
+//       return Node(graph->head(static_cast<typename Graph::Edge>(e))); }
+
+//     int nodeNum() const { return graph->nodeNum(); }
+//     int edgeNum() const { return graph->edgeNum(); }
+  
+//     Node addNode() const { return Node(graph->addNode()); }
+//     Edge addEdge(const Node& tail, const Node& head) const { 
+//       return Edge(graph->addEdge(tail, head)); }
+
+//     void erase(const Node& i) const { graph->erase(i); }
+//     void erase(const Edge& i) const { graph->erase(i); }
+  
+//     void clear() const { graph->clear(); }
+    
+//     bool forward(const Edge& e) const { return graph->forward(e); }
+//     bool backward(const Edge& e) const { return graph->backward(e); }
+
+//     int id(const Node& v) const { return graph->id(v); }
+//     int id(const Edge& e) const { return graph->id(e); }
+    
+//     Edge opposite(const Edge& e) const { return Edge(graph->opposite(e)); }
+
+
+//     IMPORT_NODE_MAP(Graph, *(gw.graph), GraphWrapper, gw);    
+//     IMPORT_EDGE_MAP(Graph, *(gw.graph), GraphWrapper, gw);
+    
+  };
+  
+}
+
+#endif LEMON_GRAPH_FACTORY_H



More information about the Lemon-commits mailing list