[Lemon-commits] [lemon_svn] deba: r1278 - in hugo/branches/graph_factory/src: lemon lemon/skeletons test

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


Author: deba
Date: Thu Oct  7 02:27:23 2004
New Revision: 1278

Added:
   hugo/branches/graph_factory/src/lemon/clear_graph_extension.h
   hugo/branches/graph_factory/src/lemon/erase_graph_extension.h
   hugo/branches/graph_factory/src/lemon/extend_graph_extension.h
   hugo/branches/graph_factory/src/lemon/id_map_graph_extension.h
   hugo/branches/graph_factory/src/lemon/iterator_graph_extension.h
   hugo/branches/graph_factory/src/lemon/map_graph_extension.h
   hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h
   hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h
   hugo/branches/graph_factory/src/lemon/test_graph.h
   hugo/branches/graph_factory/src/test/base_graph_test.cc
   hugo/branches/graph_factory/src/test/extended_graph_test.cc
Modified:
   hugo/branches/graph_factory/src/lemon/Makefile.am
   hugo/branches/graph_factory/src/lemon/map_registry.h
   hugo/branches/graph_factory/src/lemon/skeletons/graph.h
   hugo/branches/graph_factory/src/lemon/vector_map.h
   hugo/branches/graph_factory/src/test/graph_test.h

Log:
Possible way to implement the factory style graphs.
Modular concept and implementation.
\todo: find proper name for concepts and classes



Modified: hugo/branches/graph_factory/src/lemon/Makefile.am
==============================================================================
--- hugo/branches/graph_factory/src/lemon/Makefile.am	(original)
+++ hugo/branches/graph_factory/src/lemon/Makefile.am	Thu Oct  7 02:27:23 2004
@@ -13,10 +13,8 @@
 	invalid.h							\
 	kruskal.h							\
 	list_graph.h							\
-	map_defines.h                                                   \
 	map_iterator.h                                                  \
 	map_registry.h                                                  \
-	map_bits.h							\
 	maps.h								\
 	min_cost_flow.h                                                 \
 	suurballe.h                                                     \
@@ -24,12 +22,21 @@
 	path.h                                                          \
 	smart_graph.h							\
 	time_measure.h							\
+        test_graph.h							\
 	unionfind.h							\
 	vector_map.h                                                    \
-	xy.h
+	xy.h								\
+	iterator_graph_extension.h					\
+	id_map_graph_extension.h				   	\
+	map_graph_extension.h						\
+	extend_graph_extension.h					\
+	clear_graph_extension.h						\
+	erase_graph_extension.h
 
 noinst_HEADERS =							\
 	skeletons/graph.h						\
+	skeletons/base_graph.h						\
+        skeletons/extended_graph.h					\
 	skeletons/sym_graph.h                                           \
 	skeletons/maps.h                                                \
 	skeletons/path.h

Added: hugo/branches/graph_factory/src/lemon/clear_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/clear_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,31 @@
+// -*- c++ -*-
+
+#ifndef LEMON_CLEAR_GRAPH_EXTENSION_H
+#define LEMON_CLEAR_GRAPH_EXTENSION_H
+
+#include <lemon/invalid.h>
+
+
+namespace lemon {
+
+  template <typename Base> 
+  class ClearGraphExtension : public Base {
+  public:
+
+    typedef ClearGraphExtension Graph;
+    typedef Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    void clear() {
+      Parent::edge_maps.clear();
+      Parent::node_maps.clear();
+      Parent::clear();
+    }
+
+  };
+
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/erase_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/erase_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,48 @@
+// -*- c++ -*-
+
+#ifndef LEMON_ERASE_GRAPH_EXTENSION_H
+#define LEMON_ERASE_GRAPH_EXTENSION_H
+
+#include <lemon/invalid.h>
+
+
+namespace lemon {
+
+  template <typename Base> 
+  class EraseGraphExtension : public Base {
+  public:
+
+    typedef EraseGraphExtension Graph;
+    typedef Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    void erase(const Node& node) {
+      Edge edge;
+      Parent::firstOutEdge(edge, node);
+      while (edge != INVALID ) {
+	erase(edge);
+	Parent::firstOutEdge(edge, node);
+      } 
+
+      Parent::firstInEdge(edge, node);
+      while (edge != INVALID ) {
+	erase(edge);
+	Parent::firstInEdge(edge, node);
+      }
+
+      Parent::node_maps.erase(node);
+      Parent::erase(node);
+    }
+    
+    void erase(const Edge& edge) {
+      Parent::edge_maps.erase(edge);
+      Parent::erase(edge);
+    }
+
+  };
+
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/extend_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/extend_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,34 @@
+// -*- c++ -*-
+
+#ifndef LEMON_EXTEND_GRAPH_EXTENSION_H
+#define LEMON_EXTEND_GRAPH_EXTENSION_H
+
+namespace lemon {
+
+  template <typename Base> 
+  class ExtendGraphExtension : public Base {
+  public:
+
+    typedef ExtendGraphExtension Graph;
+    typedef Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    Node addNode() {
+      Node node = Parent::addNode();
+      Parent::node_maps.add(node);
+      return node;
+    }
+    
+    Edge addEdge(const Node& from, const Node& to) {
+      Edge edge = Parent::addEdge(from, to);
+      Parent::edge_maps.add(edge);
+      return edge;
+    }
+
+  };
+
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/id_map_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/id_map_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,51 @@
+// -*- c++ -*-
+
+#ifndef LEMON_ID_MAP_GRAPH_EXTENSION_H
+#define LEMON_ID_MAP_GRAPH_EXTENSION_H
+
+
+namespace lemon {
+
+  template <typename Base> 
+  class IdMapGraphExtension : public Base {
+  public:
+
+    typedef IdMapGraphExtension Graph;
+    typedef Base Parent;
+ 
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+
+    class NodeIdMap {
+    private:
+      const Graph* graph;
+
+    public:
+      NodeIdMap(const Graph& g) : graph(&g) {}
+
+      int operator[](const Node& node) { return graph->id(node); }
+
+      int maxId() const {return graph->maxNodeId(); }
+
+    };
+
+    class EdgeIdMap {
+    private:
+      const Graph* graph;
+
+    public:
+      EdgeIdMap(const Graph& g) : graph(&g) {}
+
+      int operator[](const Edge& edge) const { return graph->id(edge); }
+
+      int maxId() const {return graph->maxEdgeId(); }
+
+    };
+
+  };
+
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/iterator_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/iterator_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,162 @@
+// -*- c++ -*-
+
+#ifndef LEMON_ITERATOR_GRAPH_EXTENSION_H
+#define LEMON_ITERATOR_GRAPH_EXTENSION_H
+
+#include <lemon/invalid.h>
+
+namespace lemon {
+
+  template <typename Base>
+  class IteratorGraphExtension : public Base {
+    public:
+    
+    typedef IteratorGraphExtension Graph;
+    typedef Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    class NodeIt {
+    protected:
+      const Graph* graph;
+      Node node;
+    public:
+      NodeIt() {}
+      NodeIt(Invalid) : node(INVALID) {}
+      NodeIt(const Graph& g) : graph(&g) { graph->first(node); }
+
+      NodeIt& operator++() { graph->next(node); return *this; }
+      const Node& operator*() const { return node; }
+
+      bool operator==(const NodeIt& it) { return node == it.node;}
+      bool operator!=(const NodeIt& it) { return !(*this == it);}
+    };
+
+    class EdgeIt {
+    protected:
+      const Graph* graph;
+      Edge edge;
+    public:
+      EdgeIt() {}
+      EdgeIt(Invalid) : edge(INVALID) {}
+      EdgeIt(const Graph& g) : graph(&g) { graph->first(edge); }
+
+      EdgeIt& operator++() { graph->next(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const EdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const EdgeIt& it) { return !(*this == it);}
+    };
+
+    class InEdgeIt {
+    protected:
+      const Graph* graph;
+      Edge edge;
+    public:
+      InEdgeIt() {}      
+      InEdgeIt(Invalid) : edge(INVALID) {}
+      InEdgeIt(const Graph& g, const Node& n) 
+	: graph(&g) { graph->firstInEdge(edge, n); }
+
+      InEdgeIt& operator++() { graph->nextInEdge(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const InEdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const InEdgeIt& it) { return !(*this == it);}
+    };
+
+    class OutEdgeIt {
+    protected:
+      const Graph* graph;
+      Edge edge;
+    public:
+      OutEdgeIt() {}
+      OutEdgeIt(Invalid) : edge(INVALID) {}
+      OutEdgeIt(const Graph& g, const Node& n) 
+	: graph(&g) { graph->firstOutEdge(edge, n); }
+
+      OutEdgeIt& operator++() { graph->nextOutEdge(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const OutEdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const OutEdgeIt& it) { return !(*this == it);}
+    };
+
+  };
+
+
+
+  template <typename Base>
+  class StaticIteratorGraphExtension : public Base {
+    
+    typedef Base Parent;
+    typedef StaticIteratorGraphExtension Graph;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
+    class NodeIt {
+    protected:
+      Node node;
+    public:
+      NodeIt() {}
+      NodeIt(Invalid) : node(INVALID) {}
+      NodeIt(const Graph& g) { g.first(node); }
+
+      NodeIt& operator++() { Graph::next(node); return *this; }
+      const Node& operator*() const { return node; }
+
+      bool operator==(const NodeIt& it) { return node == it.node;}
+      bool operator!=(const NodeIt& it) { return !(*this == it);}
+    };
+
+    class EdgeIt {
+    protected:
+      Edge edge;
+    public:
+      EdgeIt() {}
+      EdgeIt(Invalid) : edge(INVALID) {}
+      EdgeIt(const Graph& g) { g.first(edge); }
+
+      EdgeIt& operator++() { Graph::next(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const EdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const EdgeIt& it) { return !(*this == it);}
+    };
+
+    class InEdgeIt {
+    protected:
+      Edge edge;
+    public:
+      InEdgeIt() {}
+      InEdgeIt(Invalid) : edge(INVALID) {}
+      InEdgeIt(const Graph& g, const Node& n) { g.firstIn(edge, n); }
+
+      InEdgeIt& operator++() { Graph::nextInEdge(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const InEdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const InEdgeIt& it) { return !(*this == it);}
+    };
+
+    class OutEdgeIt {
+    protected:
+      Edge edge;
+    public:
+      OutEdgeIt() {}
+      OutEdgeIt(Invalid) : edge(INVALID) {}
+      OutEdgeIt(const Graph& g, const Node& n) { g.firstOutEdge(edge, n); }
+
+      OutEdgeIt& operator++() { Graph::nextOutEdge(edge); return *this; }
+      const Edge& operator*() const { return edge; }
+
+      bool operator==(const OutEdgeIt& it) { return edge == it.edge;}
+      bool operator!=(const OutEdgeIt& it) { return !(*this == it);}
+    };
+
+  };
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/map_graph_extension.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/map_graph_extension.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,62 @@
+// -*- c++ -*-
+
+#ifndef LEMON_MAP_GRAPH_EXTENSION_H
+#define LEMON_MAP_GRAPH_EXTENSION_H
+
+#include <lemon/map_registry.h>
+
+namespace lemon {
+
+  template <typename Base, template <typename,typename,typename> class DynMap> 
+  class MapGraphExtension : public Base {
+  public:
+
+    typedef MapGraphExtension Graph;
+    typedef Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::NodeIt NodeIt;
+    typedef typename Parent::NodeIdMap NodeIdMap;
+
+    typedef typename Parent::Edge Edge;
+    typedef typename Parent::EdgeIt EdgeIt;
+    typedef typename Parent::EdgeIdMap EdgeIdMap;
+
+
+  protected:
+
+    typedef MapRegistry<Graph, Edge, EdgeIt> EdgeMapRegistry;
+    mutable EdgeMapRegistry edge_maps;
+
+    typedef MapRegistry<Graph, Node, NodeIt> NodeMapRegistry;
+    mutable NodeMapRegistry node_maps;
+
+  public:
+    
+    template <typename Value>
+    class NodeMap : public DynMap<NodeMapRegistry, NodeIdMap, Value> {
+    public:
+      typedef DynMap<NodeMapRegistry, NodeIdMap, Value> Parent;
+
+      NodeMap(const Graph& g) : Parent(g, g.node_maps) {}
+      NodeMap(const Graph& g, const Value& v) : Parent(g, g.node_maps, v) {}
+
+    };
+
+    template <typename Value>
+    class EdgeMap : public DynMap<EdgeMapRegistry, EdgeIdMap, Value> {
+    public:
+      typedef DynMap<EdgeMapRegistry, EdgeIdMap, Value> Parent;
+
+      EdgeMap(const Graph& g) : Parent(g, g.edge_maps) {}
+      EdgeMap(const Graph& g, const Value& v) : Parent(g, g.edge_maps, v) {}
+
+    };
+
+    
+  };
+
+}
+
+#endif
+

Modified: hugo/branches/graph_factory/src/lemon/map_registry.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/map_registry.h	(original)
+++ hugo/branches/graph_factory/src/lemon/map_registry.h	Thu Oct  7 02:27:23 2004
@@ -160,7 +160,7 @@
 	
       virtual void init() {
 	for (KeyIt it(*graph); it != INVALID; ++it) {
-	  add(it);
+	  add(*it);
 	}
       }
 	
@@ -176,7 +176,7 @@
 	
       virtual void destroy() {
 	for (KeyIt it(*getGraph()); it != INVALID; ++it) {
-	  erase(it);
+	  erase(*it);
 	}
       }
 

Added: hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,214 @@
+// -*- c++ -*-
+
+#ifndef LEMON_SKELETON_BASE_GRAPH_H
+#define LEMON_SKELETON_BASE_GRAPH_H
+
+#include <lemon/invalid.h>
+
+namespace lemon {
+  namespace skeleton {
+
+    class BaseGraph {
+    public:
+
+      typedef BaseGraph Graph;
+      
+      class Node {
+      public:
+	Node() {}
+	Node(const Node&) {}
+	Node(Invalid) {}
+	Node(const Graph&) {}
+
+	Node& operator=(const Node&) { return *this;}
+
+	bool operator==(const Node&) { return true;}
+	bool operator!=(const Node&) { return true;}
+	bool operator<(const Node&) { return true;}
+      };
+
+      class Edge {
+      public:
+	Edge() {}
+	Edge(const Edge&) {}
+	Edge(Invalid) {}
+	Edge(const Graph&) {}
+
+	Edge& operator=(const Edge&) { return *this;}
+
+	bool operator==(const Edge&) { return true;}
+	bool operator!=(const Edge&) { return true;}
+	bool operator<(const Edge&) { return true;}
+      };
+
+      Node head(const Edge&) const { return INVALID;}
+      Node tail(const Edge&) const { return INVALID;}
+    };
+
+    template <typename Graph>
+    void checkBaseGraph(Graph& graph) {
+      typedef typename Graph::Node Node;
+      typedef typename Graph::Edge Edge;
+      {
+	Node ni; 
+	Node nj(ni); 
+	Node nk(INVALID);
+	ni = nj;
+	bool b; b = true;
+	b = (ni == INVALID); b = (ni != INVALID);
+	b = (ni==nj); b = (ni != nj); b=( ni < nj);
+      }
+      {
+	Edge ei; 
+	Edge ej(ei); 
+	Edge ek(INVALID);
+	ei = ej;
+	bool b; b = true;
+	b = (ei == INVALID); b = (ei != INVALID);
+	b = (ei==ej); b = (ei != ej); b=( ei < ej);
+      }
+      {
+	const Graph& cgraph = graph;
+	Node n;
+	Edge e;
+	n = cgraph.tail(e);
+	n = cgraph.head(e);
+      }      
+    } 
+
+    class IterateBaseGraph : public BaseGraph {
+    public:
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+      
+      void first(Node&) const {}
+      void next(Node&) const {}
+
+      void first(Edge&) const {}
+      void next(Edge&) const {}
+
+
+      void firstInEdge(Edge&, const Node&) const {}
+      void nextInEdge(Edge&) const {}
+
+      void firstOutEdge(Edge&, const Node&) const {}
+      void nextOutEdge(Edge&) const {}
+    };
+
+    template <typename Graph>
+    void checkIterateBaseGraph(Graph& graph) {      
+      const Graph& cgraph = graph;
+      typename Graph::Node node;
+      cgraph.first(node);
+      cgraph.next(node);
+      typename Graph::Edge edge;
+      cgraph.first(edge);
+      cgraph.next(edge);
+      cgraph.firstInEdge(edge, node);
+      cgraph.nextInEdge(edge);
+      cgraph.firstOutEdge(edge, node);
+      cgraph.nextOutEdge(edge);
+    }
+
+    class IdBaseGraph : public BaseGraph {
+    public:
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      int id(const Node&) const { return -1;}
+      int id(const Edge&) const { return -1;}
+    };
+
+    template <typename Graph>
+    void checkIdBaseGraph(Graph& graph) {
+      const Graph& cgraph = graph;
+      typename Graph::Node node;
+      int nid = cgraph.id(node);
+      typename Graph::Edge edge;
+      int eid = cgraph.id(edge);
+    }
+
+    class MaxIdBaseGraph : public BaseGraph {
+    public:
+
+      int maxEdgeId() const { return -1;}
+      int maxNodeId() const { return -1;}
+    };
+
+    template <typename Graph>
+    void checkMaxIdBaseGraph(Graph& graph) {
+      const Graph& cgraph = graph;
+      int nid = cgraph.maxEdgeId();
+      int eid = cgraph.maxNodeId();
+    }
+
+    class ExtendBaseGraph : public BaseGraph {
+    public:
+
+      typedef ExtendBaseGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      Node addNode() {
+	return INVALID;
+      }
+    
+      Edge addEdge(const Node& from, const Node& to) {
+	return INVALID;
+      }
+
+    };
+
+    template <typename Graph>
+    void checkExtendBaseGraph(Graph& graph) {
+      typename Graph::Node node_a, node_b;
+      node_a = graph.addNode();
+      typename Graph::Edge edge;
+      edge = graph.addEdge(node_a, node_b);      
+    }
+
+    class EraseBaseGraph : public BaseGraph {
+    public:
+
+      typedef EraseBaseGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      void erase(const Node& node) {}    
+      void erase(const Edge&) {}
+
+    };
+
+    template <typename Graph>
+    void checkEraseBaseGraph(Graph& graph) {
+      typename Graph::Node node;
+      graph.erase(node);
+      typename Graph::Edge edge;
+      graph.erase(edge);      
+    }
+
+    class ClearBaseGraph : public BaseGraph {
+    public:
+
+      typedef ClearBaseGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      void clear() {}    
+
+    };
+
+    template <typename Graph>
+    void checkClearBaseGraph(Graph& graph) {
+      graph.clear();
+    }
+
+  }
+}
+
+#endif

Added: hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,324 @@
+// -*- c++ -*-
+
+#ifndef LEMON_SKELETON_EXTENDED_GRAPH_H
+#define LEMON_SKELETON_EXTENDED_GRAPH_H
+
+#include <lemon/skeletons/base_graph.h>
+#include <lemon/skeletons/maps.h>
+#include <lemon/invalid.h>
+
+namespace lemon {
+
+  namespace skeleton {
+
+    class IteratorExtendedGraph : public BaseGraph {
+
+    public:
+    
+      typedef IteratorExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      class NodeIt {
+      public:
+	NodeIt() {}
+	NodeIt(Invalid) {}
+	NodeIt(const Graph&) {}
+
+	NodeIt& operator++() { return *this; }
+	Node operator*() const { return INVALID; }
+
+	bool operator==(const NodeIt&) { return true;}
+	bool operator!=(const NodeIt&) { return true;}
+      };
+
+      class EdgeIt {
+      public:
+	EdgeIt() {}
+	EdgeIt(Invalid) {}
+	EdgeIt(const Graph&) {}
+
+	EdgeIt& operator++() { return *this; }
+	Edge operator*() const { return INVALID; }
+
+	bool operator==(const EdgeIt&) { return true;}
+	bool operator!=(const EdgeIt&) { return true;}
+      };
+
+      class InEdgeIt {
+      public:
+	InEdgeIt() {}
+	InEdgeIt(Invalid) {}
+	InEdgeIt(const Graph&, const Node&) {}
+
+	InEdgeIt& operator++() { return *this; }
+	Edge operator*() const { return INVALID; }
+
+	bool operator==(const InEdgeIt&) { return true;}
+	bool operator!=(const InEdgeIt&) { return true;}
+      };
+
+      class OutEdgeIt {
+      public:
+	OutEdgeIt() {}
+	OutEdgeIt(Invalid) {}
+	OutEdgeIt(const Graph&, const Node&) {}
+
+	OutEdgeIt& operator++() { return *this; }
+	Edge operator*() const { return INVALID; }
+
+	bool operator==(const OutEdgeIt&) { return true;}
+	bool operator!=(const OutEdgeIt&) { return true;}
+      };
+
+    };
+    
+    template <typename Graph> 
+    void checkIteratorExtendedGraph(Graph& graph) {
+  
+      typedef typename Graph::Node Node;
+      typedef typename Graph::NodeIt NodeIt;
+      typedef typename Graph::Edge Edge;
+      typedef typename Graph::EdgeIt EdgeIt;
+      typedef typename Graph::InEdgeIt InEdgeIt;
+      typedef typename Graph::OutEdgeIt OutEdgeIt;
+  
+      {
+	NodeIt it; 
+	NodeIt jt(it); 
+	NodeIt kt(INVALID); 
+	NodeIt lt(graph);
+	it = jt;
+	jt = ++it;
+	bool b;
+	b = (it == INVALID); 
+	b = (it != INVALID);
+	b = (it == jt); 
+	b = (it != jt);
+	Node node = *it;
+	node = *it;
+      }
+      {
+	EdgeIt it; 
+	EdgeIt jt(it); 
+	EdgeIt kt(INVALID); 
+	EdgeIt lt(graph);
+	it = jt;
+	jt = ++it;
+	bool b;
+	b = (it == INVALID); 
+	b = (it != INVALID);
+	b = (it == jt); 
+	b = (it != jt);
+	Edge edge = *it;
+	edge = *it;
+      }
+      {
+	InEdgeIt it; 
+	InEdgeIt jt(it); 
+	InEdgeIt kt(INVALID); 
+	Node node;
+	InEdgeIt lt(graph, node);
+	it = jt;
+	jt = ++it;
+	bool b;
+	b = (it == INVALID); 
+	b = (it != INVALID);
+	b = (it == jt); 
+	b = (it != jt);
+	Edge edge = *it;
+	edge = *it;
+      }
+      {
+	OutEdgeIt it; 
+	OutEdgeIt jt(it); 
+	OutEdgeIt kt(INVALID); 
+	Node node;
+	OutEdgeIt lt(graph, node);
+	it = jt;
+	jt = ++it;
+	bool b;
+	b = (it == INVALID); 
+	b = (it != INVALID);
+	b = (it == jt); 
+	b = (it != jt);
+	Edge edge = *it;
+	edge = *it;
+      }
+    }
+
+
+    class IdMapExtendedGraph : public BaseGraph {
+
+      typedef IdMapExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+    public:
+
+      class NodeIdMap : public ReadMap<Node, int> {
+      public:
+	NodeIdMap(const Graph&) {}
+	int maxId() const { return -1;}
+      };
+
+      class EdgeIdMap : public ReadMap<Edge, int> {
+      public:
+	EdgeIdMap(const Graph&) {}
+	int maxId() const { return -1;}
+      };
+
+    };
+    
+    template <typename Graph>
+    void checkIdMapExtendedGraph(Graph& graph) {
+      {
+	typename Graph::EdgeIdMap edge_map(graph);
+	// \todo checking read map concept.
+	// checkReadMap(edge_map);
+	int n = edge_map.maxId();
+      }
+      {
+	typename Graph::NodeIdMap node_map(graph);
+	// \todo checking read map concept.
+	// checkNodeMap(edge_map);
+	int n = node_map.maxId();
+      }
+    }
+
+
+    class MapExtendedGraph : public BaseGraph {
+    public:
+
+      typedef MapExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+
+
+      typedef BaseGraph::Edge Edge;
+
+
+    
+      template <typename Value>
+      class NodeMap : public ReferenceMap<Node, Value> {
+      public:
+	NodeMap(const Graph&) {}
+	NodeMap(const Graph&, const Value&) {}
+	NodeMap(const NodeMap&) {}
+
+	NodeMap& operator=(const NodeMap&) { return *this;}
+	
+      };
+
+    
+      template <typename Value>
+      class EdgeMap : public ReferenceMap<Edge, Value> {
+      public:
+	EdgeMap(const Graph&) {}
+	EdgeMap(const Graph&, const Value&) {}
+	EdgeMap(const EdgeMap&) {}
+
+	EdgeMap& operator=(const EdgeMap&) { return *this;}
+	
+      };
+
+    };
+
+    template <typename Graph>
+    void checkMapExtendedGraph(Graph& graph) {
+      {
+	typename Graph::template NodeMap<int> m(graph);
+	const Graph& cgraph = graph;
+	typename Graph::template NodeMap<int> mc(cgraph);
+	typename Graph::template NodeMap<int> const &cm = m;
+	typename Graph::template NodeMap<int> mdef(graph,12);
+	typename Graph::template NodeMap<int> mm(cm);
+	m=cm;  
+	// \todo checking reference map concept.
+	// checkReferenceMap(m);
+      }  
+      {
+	typename Graph::template EdgeMap<int> m(graph);
+	const Graph& cgraph = graph;
+	typename Graph::template EdgeMap<int> mc(cgraph);
+	typename Graph::template EdgeMap<int> const &cm = m;
+	typename Graph::template EdgeMap<int> mdef(graph,12);
+	typename Graph::template EdgeMap<int> mm(cm);
+	m=cm;  
+	// \todo checking reference map concept.
+	// checkReferenceMap(m);
+      }  
+    }
+
+
+    class ExtendExtendedGraph : public BaseGraph {
+    public:
+
+      typedef ExtendExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      Node addNode() {
+	return INVALID;
+      }
+    
+      Edge addEdge(const Node& from, const Node& to) {
+	return INVALID;
+      }
+
+    };
+
+    template <typename Graph>
+    void checkExtendExtendedGraph(Graph& graph) {
+      typename Graph::Node node_a, node_b;
+      node_a = graph.addNode();
+      typename Graph::Edge edge;
+      edge = graph.addEdge(node_a, node_b);      
+    }
+
+    class EraseExtendedGraph : public BaseGraph {
+    public:
+
+      typedef EraseExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      void erase(const Node& node) {}    
+      void erase(const Edge&) {}
+
+    };
+
+    template <typename Graph>
+    void checkEraseExtendedGraph(Graph& graph) {
+      typename Graph::Node node;
+      graph.erase(node);
+      typename Graph::Edge edge;
+      graph.erase(edge);      
+    }
+
+    class ClearExtendedGraph : public BaseGraph {
+    public:
+
+      typedef ClearExtendedGraph Graph;
+
+      typedef BaseGraph::Node Node;
+      typedef BaseGraph::Edge Edge;
+
+      void clear() {}    
+
+    };
+
+    template <typename Graph>
+    void checkClearExtendedGraph(Graph& graph) {
+      graph.clear();
+    }
+
+  }
+
+}
+
+#endif

Modified: hugo/branches/graph_factory/src/lemon/skeletons/graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/skeletons/graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/skeletons/graph.h	Thu Oct  7 02:27:23 2004
@@ -116,7 +116,7 @@
       /// of nodes in graph \c g of type \c Graph like this:
       /// \code
       /// int count=0;
-      /// for (Graph::NodeIt n(g); n!=INVALID; ++n) ++count;
+      /// for (Graph::NodeIt n(g); n!=INVALID ++n) ++count;
       /// \endcode
       class NodeIt : public Node {
       public:

Added: hugo/branches/graph_factory/src/lemon/test_graph.h
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/lemon/test_graph.h	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,275 @@
+// -*- c++ -*-
+
+#ifndef LEMON_TEST_GRAPH_H
+#define LEMON_TEST_GRAPH_H
+
+#include <lemon/erase_graph_extension.h>
+#include <lemon/clear_graph_extension.h>
+#include <lemon/extend_graph_extension.h>
+#include <lemon/map_graph_extension.h>
+#include <lemon/id_map_graph_extension.h>
+#include <lemon/iterator_graph_extension.h>
+
+#include <lemon/vector_map.h>
+
+
+namespace lemon {
+
+  class TestGraphBase {
+
+    struct NodeT {
+      int first_in,first_out;
+      int prev, next;
+    };
+ 
+    struct EdgeT {
+      int head, tail;
+      int prev_in, prev_out;
+      int next_in, next_out;
+    };
+
+    std::vector<NodeT> nodes;
+
+    int first_node;
+
+    int first_free_node;
+
+    std::vector<EdgeT> edges;
+
+    int first_free_edge;
+    
+  public:
+    
+    typedef TestGraphBase Graph;
+    
+    class Node {
+      friend class Graph;
+    protected:
+
+      int id;
+      Node(int pid) { id = pid;}
+
+    public:
+      Node() {}
+      Node (Invalid) { id = -1; }
+      bool operator==(const Node& node) const {return id == node.id;}
+      bool operator!=(const Node& node) const {return id != node.id;}
+      bool operator<(const Node& node) const {return id < node.id;}
+    };
+
+    class Edge {
+      friend class Graph;
+    protected:
+
+      int id;
+      Edge(int pid) { id = pid;}
+
+    public:
+      Edge() {}
+      Edge (Invalid) { id = -1; }
+      bool operator==(const Edge& edge) const {return id == edge.id;}
+      bool operator!=(const Edge& edge) const {return id != edge.id;}
+      bool operator<(const Edge& edge) const {return id < edge.id;}
+    };
+
+
+
+    TestGraphBase()
+      : nodes(), first_node(-1),
+	first_free_node(-1), edges(), first_free_edge(-1) {}
+
+    TestGraphBase(const TestGraphBase &g) 
+      : nodes(g.nodes), first_node(g.first_node),
+	first_free_node(g.first_free_node), edges(g.edges),
+	first_free_edge(g.first_free_edge) {}
+    
+    ///it possible to avoid the superfluous memory allocation.
+    void reserveEdge(int n) { edges.reserve(n); };
+    
+    /// Maximum node ID.
+    
+    /// Maximum node ID.
+    ///\sa id(Node)
+    int maxNodeId() const { return nodes.size()-1; } 
+    /// Maximum edge ID.
+    
+    /// Maximum edge ID.
+    ///\sa id(Edge)
+    int maxEdgeId() const { return edges.size()-1; }
+
+    Node tail(Edge e) const { return edges[e.id].tail; }
+    Node head(Edge e) const { return edges[e.id].head; }
+
+
+
+    void first(Node& node) const { 
+      node.id = first_node;
+    }
+
+    void next(Node& node) const {
+      node.id = nodes[node.id].next;
+    }
+
+
+    void first(Edge& e) const { 
+      int n;
+      for(n = first_node; 
+	  n!=-1 && nodes[n].first_in == -1; 
+	  n = nodes[n].next);
+      e.id = (n == -1) ? -1 : nodes[n].first_in;
+    }
+
+    void next(Edge& edge) const {
+      if (edges[edge.id].next_in != -1) {
+	edge.id = edges[edge.id].next_in;
+      } else {
+	int n;
+	for(n = nodes[edges[edge.id].head].next;
+	  n!=-1 && nodes[n].first_in == -1; 
+	  n = nodes[n].next);
+	edge.id = (n == -1) ? -1 : nodes[n].first_in;
+      }      
+    }
+
+    void firstOutEdge(Edge &e, const Node& v) const {
+      e.id = nodes[v.id].first_out;
+    }
+    void nextOutEdge(Edge &e) const {
+      e.id=edges[e.id].next_out;
+    }
+
+    void firstInEdge(Edge &e, const Node& v) const {
+      e.id = nodes[v.id].first_in;
+    }
+    void nextInEdge(Edge &e) const {
+      e.id=edges[e.id].next_in;
+    }
+
+    
+    static int id(Node v) { return v.id; }
+    static int id(Edge e) { return e.id; }
+
+    /// Adds a new node to the graph.
+
+    /// \warning It adds the new node to the front of the list.
+    /// (i.e. the lastly added node becomes the first.)
+    Node addNode() {     
+      int n;
+      
+      if(first_free_node==-1) {
+	n = nodes.size();
+	nodes.push_back(NodeT());
+      } else {
+	n = first_free_node;
+	first_free_node = nodes[n].next;
+      }
+      
+      nodes[n].next = first_node;
+      if(first_node != -1) nodes[first_node].prev = n;
+      first_node = n;
+      nodes[n].prev = -1;
+      
+      nodes[n].first_in = nodes[n].first_out = -1;
+      
+      return Node(n);
+    }
+    
+    Edge addEdge(Node u, Node v) {
+      int n;      
+
+      if (first_free_edge == -1) {
+	n = edges.size();
+	edges.push_back(EdgeT());
+      } else {
+	n = first_free_edge;
+	first_free_edge = edges[n].next_in;
+      }
+      
+      edges[n].tail = u.id; 
+      edges[n].head = v.id;
+
+      edges[n].next_out = nodes[u.id].first_out;
+      if(nodes[u.id].first_out != -1) {
+	edges[nodes[u.id].first_out].prev_out = n;
+      }
+      
+      edges[n].next_in = nodes[v.id].first_in;
+      if(nodes[v.id].first_in != -1) {
+	edges[nodes[v.id].first_in].prev_in = n;
+      }
+      
+      edges[n].prev_in = edges[n].prev_out = -1;
+	
+      nodes[u.id].first_out = nodes[v.id].first_in = n;
+
+      return Edge(n);
+    }
+    
+    void erase(const Node& node) {
+      int n = node.id;
+      
+      if(nodes[n].next != -1) {
+	nodes[nodes[n].next].prev = nodes[n].prev;
+      }
+      
+      if(nodes[n].prev != -1) {
+	nodes[nodes[n].prev].next = nodes[n].next;
+      } else {
+	first_node = nodes[n].next;
+      }
+      
+      nodes[n].next = first_free_node;
+      first_free_node = n;
+
+    }
+    
+    void erase(const Edge& edge) {
+      int n = edge.id;
+      
+      if(edges[n].next_in!=-1) {
+	edges[edges[n].next_in].prev_in = edges[n].prev_in;
+      }
+
+      if(edges[n].prev_in!=-1) {
+	edges[edges[n].prev_in].next_in = edges[n].next_in;
+      } else {
+	nodes[edges[n].head].first_in = edges[n].next_in;
+      }
+
+      
+      if(edges[n].next_out!=-1) {
+	edges[edges[n].next_out].prev_out = edges[n].prev_out;
+      } 
+
+      if(edges[n].prev_out!=-1) {
+	edges[edges[n].prev_out].next_out = edges[n].next_out;
+      } else {
+	nodes[edges[n].tail].first_out = edges[n].next_out;
+      }
+      
+      edges[n].next_in = first_free_edge;
+      first_free_edge = n;      
+
+    }
+
+    void clear() {
+      edges.clear();
+      nodes.clear();
+      first_node = first_free_node = first_free_edge = -1;
+    }
+
+  };
+
+  typedef EraseGraphExtension<
+    ClearGraphExtension<
+    ExtendGraphExtension<
+    MapGraphExtension<
+    IdMapGraphExtension<
+    IteratorGraphExtension<
+    TestGraphBase> >, VectorMap> > > > TestGraph;
+}
+
+
+  
+
+#endif

Modified: hugo/branches/graph_factory/src/lemon/vector_map.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/vector_map.h	(original)
+++ hugo/branches/graph_factory/src/lemon/vector_map.h	Thu Oct  7 02:27:23 2004
@@ -19,9 +19,6 @@
 
 #include <vector>
 
-#include <lemon/map_iterator.h>
-#include <lemon/map_bits.h>
-
 ///\ingroup graphmaps
 ///\file
 ///\brief Vector based graph maps.
@@ -43,9 +40,8 @@
    *  \author Balazs Dezso
    */
 	
-  template <typename MapRegistry, typename Value>
+  template <typename MapRegistry, typename IdMap, typename Value>
   class VectorMap : public MapRegistry::MapBase {
-    template <typename MR, typename T> friend class VectorMap;
   public:
 		
     /// The graph type of the maps. 
@@ -88,7 +84,7 @@
      *  It adds all the nodes or edges of the graph to the map.
      */
     VectorMap(const Graph& g, MapRegistry& r) 
-      : MapBase(g, r), container(KeyInfo<Graph, KeyIt>::maxId(g)+1) {}
+      : MapBase(g, r), container(IdMap(g).maxId()+1) {}
 
     /// Constructor uses given value to initialize the map. 
 
@@ -96,41 +92,7 @@
      *  It adds all the nodes or edges of the graph to the map.
      */
     VectorMap(const Graph& g, MapRegistry& r, const Value& v) 
-      : MapBase(g, r), container(KeyInfo<Graph, KeyIt>::maxId(g)+1, v) {}
-
-    /// Assign operator to copy a map of an other map type.
-
-    /** Assign operator to copy a map of an other map type.
-     *  This map's value type must be assignable by the other
-     *  map type's value type.
-     */
-    template <typename TT>
-    VectorMap(const VectorMap<MapRegistry, TT>& c) 
-      : MapBase(c), container(c.container.size()) {
-      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
-	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
-	container[id] = c.container[id];
-      }
-    }
-
-    /// Assign operator to copy a map of an other map type.
-
-    /** Assign operator to copy a map of an other map type.
-     *  This map's value type must be assignable by the other
-     *  map type's value type.
-     */
-    template <typename TT>
-    VectorMap& operator=(const VectorMap<MapRegistry, TT>& c) {
-      if (MapBase::getGraph() != c.getGraph()) {
-	MapBase::operator=(c);
-	container.resize(c.container.size());
-      }
-      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
-	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
-	container[id] = c.container[id];
-      }
-      return *this;
-    }
+      : MapBase(g, r), container(IdMap(g).maxId()+1) {}
 
     /// The subcript operator.
 
@@ -139,8 +101,7 @@
      * actual keys of the graph. 
      */
     ReferenceType operator[](const KeyType& key) {
-      int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), key);
-      return container[id];
+      return container[IdMap(*MapBase::getGraph())[key]];
     } 
 		
     /// The const subcript operator.
@@ -150,19 +111,9 @@
      * actual keys of the graph. 
      */
     ConstReferenceType operator[](const KeyType& key) const {
-      int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), key);
-      return container[id];
+      return container[IdMap(*MapBase::getGraph())[key]];
     }
 
-    ///Setter function of the map.
-
-    /** Setter function of the map. Equivalent with map[key] = val.
-     *  This is a compatibility feature with the not dereferable maps.
-     */
-    void set(const KeyType& key, const ValueType& val) {
-      int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), key);
-      container[id] = val;
-    }
     /// Adds a new key to the map.
 		
     /** Adds a new key to the map. It called by the map registry
@@ -170,7 +121,7 @@
      *  add() member function.
      */
     void add(const KeyType& key) {
-      int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), key);
+      int id =  IdMap(*MapBase::getGraph())[key];
       if (id >= (int)container.size()) {
 	container.resize(id + 1);
       }
@@ -195,76 +146,10 @@
       container.clear();
     }
 
-    /// The stl compatible pair iterator of the map.
-    typedef MapIterator<VectorMap> Iterator;
-    /// The stl compatible const pair iterator of the map.
-    typedef MapConstIterator<VectorMap> ConstIterator;
-
-    /** Returns the begin iterator of the map.
-     */
-    Iterator begin() {
-      return Iterator(*this, KeyIt(*MapBase::getGraph()));
-    }
-
-    /** Returns the end iterator of the map.
-     */
-    Iterator end() {
-      return Iterator(*this, INVALID);
-    }
-
-    /** Returns the begin ConstIterator of the map.
-     */
-    ConstIterator begin() const {
-      return ConstIterator(*this, KeyIt(*MapBase::getGraph()));
-    }
-
-    /** Returns the end const_iterator of the map.
-     */
-    ConstIterator end() const {
-      return ConstIterator(*this, INVALID);
-    }
-
-    /// The KeySet of the Map.
-    typedef MapConstKeySet<VectorMap> ConstKeySet;
-
-    /// KeySet getter function.
-    ConstKeySet keySet() const {
-      return ConstKeySet(*this); 
-    }
-
-    /// The ConstValueSet of the Map.
-    typedef MapConstValueSet<VectorMap> ConstValueSet;
-
-    /// ConstValueSet getter function.
-    ConstValueSet valueSet() const {
-      return ConstValueSet(*this);
-    }
-
-    /// The ValueSet of the Map.
-    typedef MapValueSet<VectorMap> ValueSet;
-
-    /// ValueSet getter function.
-    ValueSet valueSet() {
-      return ValueSet(*this);
-    }
-
-
   private:
 		
     Container container;
 
-  public:
-    // STL  compatibility typedefs.
-    typedef Iterator iterator;
-    typedef ConstIterator const_iterator;
-    typedef typename Iterator::PairValueType value_type;
-    typedef typename Iterator::KeyType key_type;
-    typedef typename Iterator::ValueType data_type;
-    typedef typename Iterator::PairReferenceType reference;
-    typedef typename Iterator::PairPointerType pointer;
-    typedef typename ConstIterator::PairReferenceType const_reference;
-    typedef typename ConstIterator::PairPointerType const_pointer;
-    typedef int difference_type;		
   };
   
   /// @}

Added: hugo/branches/graph_factory/src/test/base_graph_test.cc
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/test/base_graph_test.cc	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,64 @@
+// -*- c++ -*-
+
+#include <iostream>
+
+#include <lemon/skeletons/base_graph.h>
+
+#include <lemon/test_graph.h>
+
+using namespace lemon;
+
+template void lemon::skeleton::checkBaseGraph
+<skeleton::BaseGraph>(skeleton::BaseGraph &);
+
+template void lemon::skeleton::checkIterateBaseGraph
+<skeleton::IterateBaseGraph>(skeleton::IterateBaseGraph &);
+
+template void lemon::skeleton::checkIdBaseGraph
+<skeleton::IdBaseGraph>(skeleton::IdBaseGraph &);
+
+template void lemon::skeleton::checkMaxIdBaseGraph
+<skeleton::MaxIdBaseGraph>(skeleton::MaxIdBaseGraph &);
+
+template void lemon::skeleton::checkExtendBaseGraph
+<skeleton::ExtendBaseGraph>(skeleton::ExtendBaseGraph &);
+
+template void lemon::skeleton::checkClearBaseGraph
+<skeleton::ClearBaseGraph>(skeleton::ClearBaseGraph &);
+
+template void lemon::skeleton::checkEraseBaseGraph
+<skeleton::EraseBaseGraph>(skeleton::EraseBaseGraph &);
+
+
+
+template void lemon::skeleton::checkBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkIterateBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkIdBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkMaxIdBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkExtendBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkClearBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+template void lemon::skeleton::checkEraseBaseGraph
+<TestGraphBase>(TestGraphBase &);
+
+
+int main() {
+  ///\file
+  ///\todo map tests.
+  ///\todo copy constr tests.
+
+  std::cout << __FILE__ ": All tests passed.\n";
+
+  return 0;
+}

Added: hugo/branches/graph_factory/src/test/extended_graph_test.cc
==============================================================================
--- (empty file)
+++ hugo/branches/graph_factory/src/test/extended_graph_test.cc	Thu Oct  7 02:27:23 2004
@@ -0,0 +1,99 @@
+// -*- c++ -*-
+
+#include <iostream>
+#include <vector>
+
+#include <lemon/skeletons/extended_graph.h>
+#include <lemon/test_graph.h>
+
+#include "test_tools.h"
+#include "graph_test.h"
+
+
+using namespace lemon;
+
+template void lemon::skeleton::checkIteratorExtendedGraph
+<skeleton::IteratorExtendedGraph>(skeleton::IteratorExtendedGraph &);
+
+template void lemon::skeleton::checkIdMapExtendedGraph
+<skeleton::IdMapExtendedGraph>(skeleton::IdMapExtendedGraph &);
+
+template void lemon::skeleton::checkMapExtendedGraph
+<skeleton::MapExtendedGraph>(skeleton::MapExtendedGraph &);
+
+template void lemon::skeleton::checkExtendExtendedGraph
+<skeleton::ExtendExtendedGraph>(skeleton::ExtendExtendedGraph &);
+
+template void lemon::skeleton::checkEraseExtendedGraph
+<skeleton::EraseExtendedGraph>(skeleton::EraseExtendedGraph &);
+
+template void lemon::skeleton::checkClearExtendedGraph
+<skeleton::ClearExtendedGraph>(skeleton::ClearExtendedGraph &);
+
+
+
+template void lemon::skeleton::checkIteratorExtendedGraph
+<TestGraph>(TestGraph &);
+
+template void lemon::skeleton::checkIdMapExtendedGraph
+<TestGraph>(TestGraph &);
+
+template void lemon::skeleton::checkMapExtendedGraph
+<TestGraph>(TestGraph &);
+
+template void lemon::skeleton::checkExtendExtendedGraph
+<TestGraph>(TestGraph &);
+
+template void lemon::skeleton::checkEraseExtendedGraph
+<TestGraph>(TestGraph &);
+
+template void lemon::skeleton::checkClearExtendedGraph
+<TestGraph>(TestGraph &);
+
+
+
+template<class Graph> void bidirPetersen(Graph &G)
+{
+  typedef typename Graph::Edge Edge;
+  typedef typename Graph::EdgeIt EdgeIt;
+  
+  checkGraphEdgeList(G,15);
+  
+  std::vector<Edge> ee;
+  
+  for(EdgeIt e(G);e!=INVALID;++e) ee.push_back(*e);
+
+  for(typename std::vector<Edge>::iterator p=ee.begin();p!=ee.end();p++)
+    G.addEdge(G.head(*p),G.tail(*p));
+}
+
+template<class Graph> void checkPetersen(Graph &G)
+{
+  typedef typename Graph::Node Node;
+
+  typedef typename Graph::EdgeIt EdgeIt;
+  typedef typename Graph::NodeIt NodeIt;
+
+  checkGraphNodeList(G,10);
+  checkGraphEdgeList(G,30);
+
+  for(NodeIt n(G);n!=INVALID;++n) {
+    checkGraphInEdgeList(G,*n,3);
+    checkGraphOutEdgeList(G,*n,3);
+  }  
+}
+
+
+int main() {
+  ///\file
+  {
+    TestGraph G;
+    addPetersen(G);
+    bidirPetersen(G);
+    checkPetersen(G);
+  }
+
+  std::cout << __FILE__ ": All tests passed.\n";
+
+  return 0;
+}

Modified: hugo/branches/graph_factory/src/test/graph_test.h
==============================================================================
--- hugo/branches/graph_factory/src/test/graph_test.h	(original)
+++ hugo/branches/graph_factory/src/test/graph_test.h	Thu Oct  7 02:27:23 2004
@@ -53,7 +53,7 @@
       typename Graph::OutEdgeIt e(G,n);
       for(int i=0;i<nn;i++) {
 	check(e!=INVALID,"Wrong OutEdge list linking.");
-	check(n==G.tail(e), "Wrong OutEdge list linking.");
+	check(n==G.tail(*e), "Wrong OutEdge list linking.");
 	++e;
       }
       check(e==INVALID,"Wrong OutEdge list linking.");
@@ -66,7 +66,7 @@
       typename Graph::InEdgeIt e(G,n);
       for(int i=0;i<nn;i++) {
 	check(e!=INVALID,"Wrong InEdge list linking.");
-	check(n==G.head(e), "Wrong InEdge list linking.");
+	check(n==G.head(*e), "Wrong InEdge list linking.");
 	++e;
       }
       check(e==INVALID,"Wrong InEdge list linking.");



More information about the Lemon-commits mailing list