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

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


Author: deba
Date: Thu Oct 21 15:06:50 2004
New Revision: 1298

Modified:
   hugo/branches/graph_factory/src/lemon/array_map.h
   hugo/branches/graph_factory/src/lemon/full_graph.h
   hugo/branches/graph_factory/src/lemon/iterable_graph_extender.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/vector_map.h
   hugo/branches/graph_factory/src/test/extended_graph_test.cc

Log:
under construction commit


Modified: hugo/branches/graph_factory/src/lemon/array_map.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/array_map.h	(original)
+++ hugo/branches/graph_factory/src/lemon/array_map.h	Thu Oct 21 15:06:50 2004
@@ -42,22 +42,30 @@
    *  will belong to and the ValueType.
    */
 
-  template <typename MapRegistry, typename Value> 
-  class ArrayMap : public MapRegistry::MapBase {
+  template <typename _Graph, 
+	    typename _Item,
+	    typename _ItemIt,
+	    typename _IdMap,
+	    typename _Value>
+  class ArrayMap : public AlterationObserverRegistry<_Item>::ObserverBase {
 
-    template <typename MR, typename V> friend class ArrayMap;
-		
   public:
 		
     /// The graph type of the maps. 
-    typedef typename MapRegistry::Graph Graph;
+    typedef _Graph Graph;
     /// The key type of the maps.
-    typedef typename MapRegistry::KeyType KeyType;
+    typedef _Item Key;
     /// The iterator to iterate on the keys.
-    typedef typename MapRegistry::KeyIt KeyIt;
+    typedef _ItemIt KeyIt;
+
+    typedef _IdMap IdMap;
+
+    typedef _Value Value;
+
+    typedef AlterationObserverRegistry<_Item> Registry;
 
     /// The MapBase of the Map which imlements the core regisitry function.
-    typedef typename MapRegistry::MapBase MapBase;
+    typedef typename Registry::ObserverBase Parent;
 		
     
   public:
@@ -82,21 +90,20 @@
 	
     /** Graph and Registry initialized map constructor.
      */
-    ArrayMap(const Graph& g, MapRegistry& r) : MapBase(g, r) {
-      allocate_memory();
-      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
-	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
-	allocator.construct(&(values[id]), Value());
-      }								
+    ArrayMap(const Graph& _g, Registry& _r) : graph(&_g) {
+      attach(_r);
+      build();
     }
 
-    /** Constructor to use default value to initialize the map. 
-     */
-    ArrayMap(const Graph& g, MapRegistry& r, const Value& v) 
-      : MapBase(g, r) {
+    /// Constructor to use default value to initialize the map. 
+
+    /// It constrates a map and initialize all of the the map. 
+
+    ArrayMap(const Graph& _g, MapRegistry& _r, const Value& _v) 
+      : graph(&_g) {
       allocate_memory();
-      for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
-	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
+      for (KeyIt it(*graph); it != INVALID; ++it) {
+	int id = IdMap(*graph)[it];
 	allocator.construct(&(values[id]), v);
       }								
     }
@@ -108,7 +115,7 @@
       if (capacity == 0) return;
       values = allocator.allocate(capacity);
       for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
-	int id = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
+	int id = IdMap(*graph)[it];
 	allocator.construct(&(values[id]), copy.values[id]);
       }
     }
@@ -223,7 +230,7 @@
 	while (new_capacity <= id) {
 	  new_capacity <<= 1;
 	}
-	Value* new_values = allocator.allocate(new_capacity);;
+	Value* new_values = allocator.allocate(new_capacity);
 	for (KeyIt it(*MapBase::getGraph()); it != INVALID; ++it) {
 	  int jd = KeyInfo<Graph, KeyIt>::id(*MapBase::getGraph(), it);
 	  if (id != jd) {
@@ -245,11 +252,20 @@
       allocator.destroy(&(values[id]));
     }
 
-    /** Clear the data structure.
-     */
+    void build() {
+      allocate_memory();
+      for (KeyIt it(*graph); it != INVALID; ++it) {
+	int id = IdMap(*graph)[it];
+	allocator.construct(&(values[id]), Value());
+      }								
+    }
+
     void clear() {	
       if (capacity != 0) {
-	MapBase::destroy();
+	for (KeyIt it(*graph); it != INVALID; ++it) {
+	  int id = IdMap(*graph)[it];
+	  allocator.destroy(&(values[id]), Value());
+	}								
 	allocator.deallocate(values, capacity);
 	capacity = 0;
       }
@@ -311,7 +327,7 @@
   private:
       
     void allocate_memory() {
-      int max_id = KeyInfo<Graph, KeyIt>::maxId(*MapBase::getGraph());
+      int max_id = IdMap(*graph).maxId();
       if (max_id == -1) {
 	capacity = 0;
 	values = 0;
@@ -324,6 +340,7 @@
       values = allocator.allocate(capacity);	
     }      
 
+    const Graph* graph;
     int capacity;
     Value* values;
     Allocator allocator;

Modified: hugo/branches/graph_factory/src/lemon/full_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/full_graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/full_graph.h	Thu Oct 21 15:06:50 2004
@@ -17,20 +17,21 @@
 #ifndef LEMON_FULL_GRAPH_H
 #define LEMON_FULL_GRAPH_H
 
+
+#include <lemon/idmappable_graph_extender.h>
+
+#include <lemon/iterable_graph_extender.h>
+
+#include <lemon/alteration_observer_registry.h>
+#include <lemon/vector_map.h>
+
 ///\ingroup graphs
 ///\file
 ///\brief FullGraph and SymFullGraph classes.
 
-#include <vector>
-#include <climits>
 
 #include <lemon/invalid.h>
 
-#include <lemon/map_registry.h>
-#include <lemon/array_map.h>
-
-#include <lemon/map_defines.h>
-
 namespace lemon {
 
 /// \addtogroup graphs
@@ -48,34 +49,26 @@
   ///\todo Don't we need SymEdgeMap?
   ///
   ///\author Alpar Juttner
-  class FullGraph {
+  class FullGraphBase {
     int NodeNum;
     int EdgeNum;
   public:
 
-    typedef FullGraph Graph;
+    typedef FullGraphBase Graph;
 
     class Node;
     class Edge;
 
-    class NodeIt;
-    class EdgeIt;
-    class OutEdgeIt;
-    class InEdgeIt;
-    
-
-    // Create map registries.
-    CREATE_MAP_REGISTRIES;
-    // Create node and edge maps.
-    CREATE_MAPS(ArrayMap);
-    
   public:
 
+    FullGraphBase() {}
+
+
     ///Creates a full graph with \c n nodes.
-    FullGraph(int n) : NodeNum(n), EdgeNum(NodeNum*NodeNum) { }
+    void construct(int n) { NodeNum = n; EdgeNum = n * n; }
     ///
-    FullGraph(const FullGraph &_g)
-      : NodeNum(_g.nodeNum()), EdgeNum(NodeNum*NodeNum) { }
+    //    FullGraphBase(const FullGraphBase &_g)
+    //      : NodeNum(_g.nodeNum()), EdgeNum(NodeNum*NodeNum) { }
     
     ///Number of nodes.
     int nodeNum() const { return NodeNum; }
@@ -93,17 +86,9 @@
     ///\sa id(Edge)
     int maxEdgeId() const { return EdgeNum-1; }
 
-    Node tail(Edge e) const { return e.n%NodeNum; }
-    Node head(Edge e) const { return e.n/NodeNum; }
+    Node tail(Edge e) const { return e.id % NodeNum; }
+    Node head(Edge e) const { return e.id / NodeNum; }
 
-    NodeIt& first(NodeIt& v) const {
-      v=NodeIt(*this); return v; }
-    EdgeIt& first(EdgeIt& e) const { 
-      e=EdgeIt(*this); return e; }
-    OutEdgeIt& first(OutEdgeIt& e, const Node v) const { 
-      e=OutEdgeIt(*this,v); return e; }
-    InEdgeIt& first(InEdgeIt& e, const Node v) const { 
-      e=InEdgeIt(*this,v); return e; }
 
     /// Node ID.
     
@@ -113,7 +98,8 @@
     ///
     /// The ID of the \ref INVALID node is -1.
     ///\return The ID of the node \c v. 
-    static int id(Node v) { return v.n; }
+
+    static int id(Node v) { return v.id; }
     /// Edge ID.
     
     /// The ID of a valid Edge is a nonnegative integer not greater than
@@ -122,7 +108,7 @@
     ///
     /// The ID of the \ref INVALID edge is -1.
     ///\return The ID of the edge \c e. 
-    static int id(Edge e) { return e.n; }
+    static int id(Edge e) { return e.id; }
 
     /// Finds an edge between two nodes.
     
@@ -134,110 +120,91 @@
     /// \return The found edge or INVALID if there is no such an edge.
     Edge findEdge(Node u,Node v, Edge prev = INVALID) 
     {
-      return prev.n == -1 ? Edge(*this, u.n, v.n) : INVALID;
+      return prev.id == -1 ? Edge(*this, u.id, v.id) : INVALID;
     }
     
       
     class Node {
-      friend class FullGraph;
-      template <typename T> friend class NodeMap;
-
-      friend class Edge;
-      friend class OutEdgeIt;
-      friend class InEdgeIt;
-      friend class SymEdge;
+      friend class FullGraphBase;
 
     protected:
-      int n;
-      friend int FullGraph::id(Node v); 
-      Node(int nn) {n=nn;}
+      int id;
+      Node(int _id) { id = _id;}
     public:
       Node() {}
-      Node (Invalid) { n=-1; }
-      bool operator==(const Node i) const {return n==i.n;}
-      bool operator!=(const Node i) const {return n!=i.n;}
-      bool operator<(const Node i) const {return n<i.n;}
+      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 NodeIt : public Node {
-      const FullGraph *G;
-      friend class FullGraph;
-    public:
-      NodeIt() : Node() { }
-      NodeIt(const FullGraph& _G,Node n) : Node(n), G(&_G) { }
-      NodeIt(Invalid i) : Node(i) { }
-      NodeIt(const FullGraph& _G) : Node(_G.NodeNum?0:-1), G(&_G) { }
-      ///\todo Undocumented conversion Node -\> NodeIt.
-      NodeIt& operator++() { n=(n+2)%(G->NodeNum+1)-1;return *this; }
-    };
+
 
     class Edge {
-      friend class FullGraph;
-      template <typename T> friend class EdgeMap;
+      friend class FullGraphBase;
       
-      friend class Node;
-      friend class NodeIt;
     protected:
-      int n; //NodeNum*head+tail;
-      friend int FullGraph::id(Edge e);
+      int id;  // NodeNum * head + tail;
 
-      Edge(int nn) : n(nn) {}
-      Edge(const FullGraph &G, int tail, int head) : n(G.NodeNum*head+tail) {}
+      Edge(int _id) : id(_id) {}
+
+      Edge(const FullGraphBase& _graph, int tail, int head) 
+	: id(_graph.NodeNum * head+tail) {}
     public:
       Edge() { }
-      Edge (Invalid) { n=-1; }
-      bool operator==(const Edge i) const {return n==i.n;}
-      bool operator!=(const Edge i) const {return n!=i.n;}
-      bool operator<(const Edge i) const {return n<i.n;}
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymFullGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
-      const int &idref() const {return n;}
+      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;}
     };
-    
-    class EdgeIt : public Edge {
-      friend class FullGraph;
-    public:
-      EdgeIt(const FullGraph& _G) : Edge(_G.EdgeNum-1) { }
-      EdgeIt(const FullGraph&, Edge e) : Edge(e) { }
-      EdgeIt (Invalid i) : Edge(i) { }
-      EdgeIt() : Edge() { }
-      EdgeIt& operator++() { --n; return *this; }
-
-      ///\bug This is a workaround until somebody tells me how to
-      ///make class \c SymFullGraph::SymEdgeMap friend of Edge
-      int &idref() {return n;}
-    };
-    
-    class OutEdgeIt : public Edge {
-      const FullGraph *G;
-      friend class FullGraph;
-    public: 
-      OutEdgeIt() : Edge() { }
-      OutEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { }
-      OutEdgeIt (Invalid i) : Edge(i) { }
 
-      OutEdgeIt(const FullGraph& _G,const Node v) : Edge(v.n), G(&_G) {}
-      
-      OutEdgeIt& operator++()
-      { n+=G->NodeNum; if(n>=G->EdgeNum) n=-1; return *this; }
+    void first(Node& node) const {
+      node.id = NodeNum-1;
+    }
 
-    };
+    static void next(Node& node) {
+      --node.id;
+    }
+
+    void first(Edge& edge) const {
+      edge.id = EdgeNum-1;
+    }
+
+    static void next(Edge& edge) {
+      --edge.id;
+    }
+
+    void firstOut(Edge& edge, const Node& node) const {
+      edge.id = EdgeNum + node.id - NodeNum;
+    }
+
+    void nextOut(Edge& edge) const {
+      edge.id -= NodeNum;
+      if (edge.id < 0) edge.id = -1;
+    }
+
+    void firstIn(Edge& edge, const Node& node) const {
+      edge.id = node.id * NodeNum;
+    }
     
-    class InEdgeIt : public Edge {
-      const FullGraph *G;
-      friend class FullGraph;
-    public: 
-      InEdgeIt() : Edge() { }
-      InEdgeIt(const FullGraph& _G, Edge e) : Edge(e), G(&_G) { }
-      InEdgeIt (Invalid i) : Edge(i) { }
-      InEdgeIt(const FullGraph& _G,Node v) : Edge(v.n*_G.NodeNum), G(&_G) {}
-      InEdgeIt& operator++()
-      { if(!((++n)%G->NodeNum)) n=-1; return *this; }
-    };
+    void nextIn(Edge& edge) const {
+      ++edge.id;
+      if (edge.id % NodeNum == 0) edge.id = -1;
+    }
 
   };
 
+
+  typedef AlterableGraphExtender<FullGraphBase> AlterableFullGraphBase;
+  typedef IterableGraphExtender<AlterableFullGraphBase> IterableFullGraphBase;
+  typedef IdMappableGraphExtender<IterableFullGraphBase> IdMappableFullGraphBase;
+  typedef VectorMappableGraphExtender<IdMappableFullGraphBase> MappableFullGraphBase;
+
+  class FullGraph : public MappableFullGraphBase {
+  public:
+
+    FullGraph(int n) { construct(n); }
+  };
   /// @}  
 
 } //namespace lemon

Modified: hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h	(original)
+++ hugo/branches/graph_factory/src/lemon/iterable_graph_extender.h	Thu Oct 21 15:06:50 2004
@@ -6,80 +6,114 @@
 
 namespace lemon {
   
-  template <typename GraphBase>
-  class IterableGraphExtender : public GraphBase {
-    typedef GraphBase Parent;
-    typedef IterableGraphExtender<GraphBase> Graph;
+  template <typename _Base>
+  class IterableGraphExtender : public _Base {
+
+    typedef _Base Parent;
+    typedef IterableGraphExtender<_Base> Graph;
+
   public:
-    IterableGraphExtender() : Parent() { }
 
-    typedef typename GraphBase::Node Node;
+    IterableGraphExtender() {}
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::Edge Edge;
+
 
     class NodeIt : public Node { 
-      const Graph* g;
-//      friend class GraphWrapper<Graph>;
+      const Graph* graph;
     public:
-      NodeIt() { }
+
+      NodeIt() {}
+
       NodeIt(Invalid i) : Node(i) { }
-      NodeIt(const Graph& _g) : Node(), g(&_g) {
-	_g.first(*this);
+
+      NodeIt(const Graph& _graph) : Node(), graph(&_graph) {
+	graph->first(*this);
       }
-      NodeIt(const Graph& _g, const Node& n) : 
-	Node(n), g(&_g) { }
+
+      NodeIt(const Graph& _graph, const Node& node) 
+	: Node(node), graph(&_graph) {}
+
       NodeIt& operator++() { 
-	g->next(*this);
+	graph->next(*this);
 	return *this; 
       }
+
     };
 
-    typedef typename GraphBase::Edge Edge;
     class EdgeIt : public Edge { 
-      const Graph* g;
-//      friend class GraphWrapper<Graph>;
+
+      const Graph* graph;
+
     public:
+
       EdgeIt() { }
+
       EdgeIt(Invalid i) : Edge(i) { }
-      EdgeIt(const Graph& _g) : Edge(), g(&_g) {
-	_g.first(*this);
+
+      EdgeIt(const Graph& _graph) : Edge(), graph(&_graph) {
+	graph->first(*this);
       }
-      EdgeIt(const Graph& _g, const Edge& e) : 
-	Edge(e), g(&_g) { }
+
+      EdgeIt(const Graph& _graph, const Edge& e) : 
+	Edge(e), graph(&_graph) { }
+
       EdgeIt& operator++() { 
-	g->next(*this);
+	graph->next(*this);
 	return *this; 
       }
+
     };
+
     class OutEdgeIt : public Edge { 
-      const Graph* g;
-//      friend class GraphWrapper<Graph>;
+
+      const Graph* graph;
+
     public:
+
       OutEdgeIt() { }
+
       OutEdgeIt(Invalid i) : Edge(i) { }
-      OutEdgeIt(const Graph& _g, const Node& n) : Edge(), g(&_g) {
-	_g.firstOut(*this, n);
+
+      OutEdgeIt(const Graph& _graph, const Node& node) 
+	: Edge(), graph(&_graph) {
+	graph->firstOut(*this, node);
       }
-      OutEdgeIt(const Graph& _g, const Edge& e) : 
-	Edge(e), g(&_g) { }
+
+      OutEdgeIt(const Graph& _graph, const Edge& edge) 
+	: Edge(edge), graph(&_graph) {}
+
       OutEdgeIt& operator++() { 
-	g->nextOut(*this);
+	graph->nextOut(*this);
 	return *this; 
       }
+
     };
+
     class InEdgeIt : public Edge { 
-      const Graph* g;
-//      friend class GraphWrapper<Graph>;
+
+      const Graph* graph;
+
     public:
+
       InEdgeIt() { }
+
       InEdgeIt(Invalid i) : Edge(i) { }
-      InEdgeIt(const Graph& _g, const Node& n) : Edge(), g(&_g) {
-	_g.firstIn(*this, n);
+
+      InEdgeIt(const Graph& _graph, const Node& node) 
+	: Edge(), graph(&_graph) {
+	graph->firstIn(*this, node);
       }
-      InEdgeIt(const Graph& _g, const Edge& e) : 
-	Edge(e), g(&_g) { }
+
+      InEdgeIt(const Graph& _g, const Edge& edge) : 
+	Edge(edge), graph(&_graph) {}
+
       InEdgeIt& operator++() { 
-	g->nextIn(*this);
+	graph->nextIn(*this);
 	return *this; 
       }
+
     };
    
     

Modified: hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/skeletons/base_graph.h	Thu Oct 21 15:06:50 2004
@@ -34,12 +34,11 @@
     /// This class provides the most minimal features of a graph structure.
     /// All the graph concepts have to be conform to this base graph.
 
-    class BaseGraph {
+    class BaseGraphComponent {
     public:
 
-      typedef BaseGraph Graph;
+      typedef BaseGraphComponent Graph;
       
-
       /// Node class of the graph.
 
       /// This class represents the Nodes of the graph. 
@@ -159,7 +158,7 @@
     ///
 
     template <typename Graph>
-    struct BaseGraphConcept {
+    struct BaseGraphComponentConcept {
       typedef typename Graph::Node Node;
       typedef typename Graph::Edge Edge;
       
@@ -191,7 +190,7 @@
 	}      
       }
       
-      Graph graph;
+      Graph& graph;
     };
 
     /// An empty iterable base graph class.
@@ -200,7 +199,7 @@
     /// core iterable interface for the graph structure.
     /// The most of the base graphs should be conform to this concept.
 
-    class IterableBaseGraph : public BaseGraph {
+    class BaseIterableGraphComponent : public BaseGraphComponent {
     public:
 
       typedef BaseGraph::Node Node;
@@ -262,7 +261,7 @@
     /// Concept check structure for IterableBaseGraph.
     ///
     template <typename Graph>
-    struct IterableBaseGraphConcept {
+    struct BaseIterableGraphComponentConcept {
       
       void constraints() { 
 	const Graph& const_graph = graph;
@@ -296,7 +295,7 @@
     /// The most of the base graphs should be conform to this concept.
     /// The id's are unique and immutable.
 
-    class IdableBaseGraph : public BaseGraph {
+    class IDableGraphComponent : public BaseGraphComponent {
     public:
 
       typedef BaseGraph::Node Node;
@@ -321,7 +320,7 @@
     /// Concept check structure for IdableBaseGraph.
     ///
     template <typename Graph>
-    struct IdableBaseGraphConcept {
+    struct IDableGraphComponentConcept {
 
       void constraints() {
 	const Graph& const_graph = graph;
@@ -341,7 +340,7 @@
     /// core max id functions for the graph structure.
     /// The most of the base graphs should be conform to this concept.
     /// The id's are unique and immutable.
-    class MaxIdableBaseGraph : public BaseGraph {
+    class MaxIDableGraphComponent : public BaseGraphComponent {
     public:
 
       /// Gives back an integer greater or equal to the maximum Node id. 
@@ -362,7 +361,7 @@
     /// Concept check structure for MaxIdableBaseGraph.
     ///
     template <typename Graph>
-    struct MaxIdableBaseGraphConcept {
+    struct MaxIDableGraphComponentConcept {
 
       void constraints() {
 	const Graph& const_graph = graph;
@@ -378,7 +377,7 @@
     /// This class provides beside the core graph features
     /// core graph extend interface for the graph structure.
     /// The most of the base graphs should be conform to this concept.
-    class ExtendableBaseGraph : public BaseGraph {
+    class BaseExtendableGraphComponent : public BaseGraphComponent {
     public:
 
       typedef BaseGraph::Node Node;
@@ -407,7 +406,7 @@
     /// Concept check structure for ExtendableBaseGraph.
     ///
     template <typename Graph>
-    struct ExtendableBaseGraphConcept {
+    struct BaseExtendableGraphComponentConcept {
       void constraints() {
 	typename Graph::Node node_a, node_b;
 	node_a = graph.addNode();
@@ -423,7 +422,7 @@
     /// This class provides beside the core graph features
     /// core erase functions for the graph structure.
     /// The most of the base graphs should be conform to this concept.
-    class ErasableBaseGraph : public BaseGraph {
+    class BaseErasableGraphComponent : public BaseGraphComponent {
     public:
 
       typedef BaseGraph::Node Node;
@@ -448,7 +447,7 @@
     /// Concept check structure for ErasableBaseGraph.
     ///
     template <typename Graph>
-    struct ErasableBaseGraphConcept {
+    struct BaseErasableGraphComponentConcept {
       void constraints() {
 	typename Graph::Node node;
 	graph.erase(node);
@@ -464,7 +463,7 @@
     /// This class provides beside the core graph features
     /// core clear functions for the graph structure.
     /// The most of the base graphs should be conform to this concept.
-    class ClearableBaseGraph : public BaseGraph {
+    class BaseClearableGraphComponent : public BaseGraphComponent {
     public:
 
       /// Erase all the Nodes and Edges from the graph.
@@ -479,7 +478,7 @@
     /// Concept check function for ErasableBaseGraph.
     ///
     template <typename Graph>
-    struct ClearableBaseGraphConcept {
+    struct BaseClearableGraphComponentConcept {
       void constraints() {
 	graph.clear();
       }

Modified: hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h
==============================================================================
--- hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h	(original)
+++ hugo/branches/graph_factory/src/lemon/skeletons/extended_graph.h	Thu Oct 21 15:06:50 2004
@@ -11,11 +11,11 @@
 
   namespace skeleton {
 
-    class IterableExtendedGraph : public BaseGraph {
+    class IterableGraphComponent : public BaseGraphComponent {
 
     public:
     
-      typedef IterableExtendedGraph Graph;
+      typedef IterableGraphComponent Graph;
 
       typedef BaseGraph::Node Node;
       typedef BaseGraph::Edge Edge;
@@ -75,83 +75,87 @@
     };
     
     template <typename Graph> 
-    void checkIterableExtendedGraph(Graph& graph) {
+    struct IterableGraphComponentConcept {
+
+      void constraints() {
   
-      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;
+	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;
+	{
+	  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;
+	}
       }
-    }
+      Graph graph;
+    };
 
 
-    class IdMappableExtendedGraph : public BaseGraph {
+    class IdMappableGraphComponent : public BaseGraphComponent {
 
-      typedef IdMappableExtendedGraph Graph;
+      typedef IdMappableGraphComponent Graph;
 
       typedef BaseGraph::Node Node;
       typedef BaseGraph::Edge Edge;
@@ -173,34 +177,33 @@
     };
     
     template <typename Graph>
-    void checkIdMappableExtendedGraph(Graph& graph) {
-      {
-	typename Graph::EdgeIdMap edge_map(graph);
-	// \todo checking read map concept.
-	// checkReadMap(edge_map);
-	int n = edge_map.maxId();
+    struct IdMappableGraphComponentConcept {
+      void constraints() {	
+	{
+	  typedef typename Graph::EdgeIdMap EdgeIdMap;
+	  function_requires<ReadMapConcept<EdgeIdMap> >();
+	  EdgeIdMap edge_map(graph);
+	  int n = edge_map.maxId();
+	}
+	{
+	  typedef typename Graph::NodeIdMap NodeIdMap;
+	  function_requires<ReadMapConcept<NodeIdMap> >();
+	  NodeIdMap node_map(graph);
+	  int n = node_map.maxId();
+	}
       }
-      {
-	typename Graph::NodeIdMap node_map(graph);
-	// \todo checking read map concept.
-	// checkNodeMap(edge_map);
-	int n = node_map.maxId();
-      }
-    }
+      Graph graph;
+    };
 
 
-    class MappableExtendedGraph : public BaseGraph {
+    class MappableGraphComponent : public BaseGraphComponent {
     public:
 
-      typedef MappableExtendedGraph Graph;
+      typedef MappableGraphComponent Graph;
 
       typedef BaseGraph::Node Node;
-
-
       typedef BaseGraph::Edge Edge;
 
-
-    
       template <typename Value>
       class NodeMap : public ReferenceMap<Node, Value> {
       public:
@@ -212,7 +215,6 @@
 	
       };
 
-    
       template <typename Value>
       class EdgeMap : public ReferenceMap<Edge, Value> {
       public:
@@ -227,33 +229,79 @@
     };
 
     template <typename Graph>
-    void checkMappableExtendedGraph(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);
-      }  
-    }
+    struct MappableGraphComponentConcept {
 
+      struct Type {
+	int value;
+	Type() : value(0) {}
+	Type(int _v) : value(_v) {}
+      };
+
+      void constraints() {
+	{ // int map test
+	  typedef typename Graph::template NodeMap<int> IntNodeMap;
+	  function_requires<ReferenceMap<IntNodeMap> >();
+	  const Graph& cgraph = graph;
+	  IntNodeMap igm(cgraph);
+	  IntNodeMap const &ccigm = igm;
+	  IntNodeMap igvm(graph,12);
+	  IntNodeMap cigm(igm);
+	  cigm=igm;  
+	} { // bool map test
+	  typedef typename Graph::template NodeMap<bool> BoolNodeMap;
+	  function_requires<ReferenceMap<BoolNodeMap> >();
+	  const Graph& cgraph = graph;
+	  BoolNodeMap igm(cgraph);
+	  BoolNodeMap const &ccigm = igm;
+	  BoolNodeMap igvm(graph, false);
+	  BoolNodeMap cigm(igm);
+	  cigm=igm;  
+	} { // Type map test
+	  typedef typename Graph::template NodeMap<Type> TypeNodeMap;
+	  function_requires<ReferenceMap<TypeNodeMap> >();
+	  const Graph& cgraph = graph;
+	  TypeNodeMap igm(cgraph);
+	  TypeNodeMap const &ccigm = igm;
+	  TypeNodeMap igvm(graph,12);
+	  TypeNodeMap cigm(igm);
+	  cigm=igm;  
+	} 
+
+	{ // int map test
+	  typedef typename Graph::template EdgeMap<int> IntEdgeMap;
+	  function_requires<ReferenceMap<IntEdgeMap> >();
+	  const Graph& cgraph = graph;
+	  IntEdgeMap igm(cgraph);
+	  IntEdgeMap const &ccigm = igm;
+	  IntEdgeMap igvm(graph,12);
+	  IntEdgeMap cigm(igm);
+	  cigm=igm;  
+	} { // bool map test
+	  typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;
+	  function_requires<ReferenceMap<BoolEdgeMap> >();
+	  const Graph& cgraph = graph;
+	  BoolEdgeMap igm(cgraph);
+	  BoolEdgeMap const &ccigm = igm;
+	  BoolEdgeMap igvm(graph, false);
+	  BoolEdgeMap cigm(igm);
+	  cigm=igm;  
+	} { // Type map test
+	  typedef typename Graph::template EdgeMap<Type> TypeEdgeMap;
+	  function_requires<ReferenceMap<TypeEdgeMap> >();
+	  const Graph& cgraph = graph;
+	  TypeEdgeMap igm(cgraph);
+	  TypeEdgeMap const &ccigm = igm;
+	  TypeEdgeMap igvm(graph,12);
+	  TypeEdgeMap cigm(igm);
+	  cigm=igm;  
+	} 
+      }
 
-    class ExtendableExtendedGraph : public BaseGraph {
+      Graph graph;
+    };
+
+
+    class ExtendableGraphComponent : public BaseGraphComponent {
     public:
 
       typedef ExtendableExtendedGraph Graph;
@@ -272,38 +320,45 @@
     };
 
     template <typename Graph>
-    void checkExtendableExtendedGraph(Graph& graph) {
-      typename Graph::Node node_a, node_b;
-      node_a = graph.addNode();
-      typename Graph::Edge edge;
-      edge = graph.addEdge(node_a, node_b);      
-    }
+    struct ExtendableGraphComponentConcept {
+      void constraints() {
+	typename Graph::Node node_a, node_b;
+	node_a = graph.addNode();
+	typename Graph::Edge edge;
+	edge = graph.addEdge(node_a, node_b);      
+      }
+      Graph graph;
+    };
 
-    class ErasableExtendedGraph : public BaseGraph {
+    class ErasableGraphComponent : public BaseGraphComponent {
     public:
 
-      typedef ErasableExtendedGraph Graph;
+      typedef ErasableGraphComponent Graph;
 
       typedef BaseGraph::Node Node;
       typedef BaseGraph::Edge Edge;
 
-      void erase(const Node& node) {}    
+      void erase(const Node&) {}    
       void erase(const Edge&) {}
 
     };
 
     template <typename Graph>
-    void checkErasableExtendedGraph(Graph& graph) {
-      typename Graph::Node node;
-      graph.erase(node);
-      typename Graph::Edge edge;
-      graph.erase(edge);      
+    struct ErasableGraphComponentConcept {
+      void constraints() {
+	typename Graph::Node node;
+	graph.erase(node);
+	typename Graph::Edge edge;
+	graph.erase(edge);      
+      }
+
+      Graph graph;
     }
 
-    class ClearableExtendedGraph : public BaseGraph {
+    class ClearableGraphComponent : public BaseGraphComponent {
     public:
 
-      typedef ClearableExtendedGraph Graph;
+      typedef ClearableGraphComponent Graph;
 
       typedef BaseGraph::Node Node;
       typedef BaseGraph::Edge Edge;
@@ -313,9 +368,12 @@
     };
 
     template <typename Graph>
-    void checkClearableExtendedGraph(Graph& graph) {
-      graph.clear();
-    }
+    struct ClearableGraphComponentConcept {
+      void constraints() {
+	graph.clear();
+      }
+      Graph graph;
+    };
 
   }
 

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 21 15:06:50 2004
@@ -93,8 +93,8 @@
     /// It construates a map and attachs it into the registry.
     /// It adds all the items of the graph to the map.
      
-    VectorMap(const Graph& g, Registry& r) : graph(&g) {
-      attach(r);
+    VectorMap(const Graph& _g, Registry& _r) : graph(&_g) {
+      attach(_r);
       build();
     }
 
@@ -105,8 +105,7 @@
      
     VectorMap(const Graph& g, Registry& r, const Value& v) : graph(&g) { 
       attach(r);
-      build();
-      std::fill(container.begin(), container.end(), v);
+      container.resize(IdMap(*graph).maxId() + 1, v);
     }
 
     VectorMap(const VectorMap& copy) : graph(copy.getGraph()) {

Modified: hugo/branches/graph_factory/src/test/extended_graph_test.cc
==============================================================================
--- hugo/branches/graph_factory/src/test/extended_graph_test.cc	(original)
+++ hugo/branches/graph_factory/src/test/extended_graph_test.cc	Thu Oct 21 15:06:50 2004
@@ -6,6 +6,7 @@
 #include <lemon/skeletons/extended_graph.h>
 #include <lemon/list_graph.h>
 #include <lemon/smart_graph.h>
+#include <lemon/full_graph.h>
 
 #include "test_tools.h"
 #include "graph_test.h"
@@ -71,6 +72,16 @@
 
 
 
+template void lemon::skeleton::checkIterableExtendedGraph
+<FullGraph>(FullGraph &);
+
+template void lemon::skeleton::checkIdMappableExtendedGraph
+<FullGraph>(FullGraph &);
+
+template void lemon::skeleton::checkMappableExtendedGraph
+<FullGraph>(FullGraph &);
+
+
 template<class Graph> void bidirPetersen(Graph &G)
 {
   typedef typename Graph::Edge Edge;



More information about the Lemon-commits mailing list