[Lemon-commits] [lemon_svn] deba: r1379 - in hugo/trunk/src: lemon lemon/concept test

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


Author: deba
Date: Sat Nov 13 22:37:54 2004
New Revision: 1379

Modified:
   hugo/trunk/src/lemon/concept/graph.h
   hugo/trunk/src/lemon/concept/graph_component.h
   hugo/trunk/src/lemon/concept/maps.h
   hugo/trunk/src/lemon/concept/undir_graph.h
   hugo/trunk/src/lemon/concept_check.h
   hugo/trunk/src/test/graph_test.cc
   hugo/trunk/src/test/graph_wrapper_test.cc

Log:
XyzConcept moved to Xyz::Constraints
use checkConcept in the next way:

checkConcept<ErasableGraph, ListGraph>();
checkConcept<ReadWriteMap<Node, Node>, PredMap>;



Modified: hugo/trunk/src/lemon/concept/graph.h
==============================================================================
--- hugo/trunk/src/lemon/concept/graph.h	(original)
+++ hugo/trunk/src/lemon/concept/graph.h	Sat Nov 13 22:37:54 2004
@@ -101,14 +101,6 @@
 // 	///
 // 	bool operator!=(Node) const { return true; }
 
-//  	///Comparison operator.
-
-// 	///This is a strict ordering between the nodes.
-// 	///
-// 	///This ordering can be different from the order in which NodeIt
-// 	///goes through the nodes.
-// 	///\todo Possibly we don't need it.
-// 	bool operator<(Node) const { return true; }
 //       };
     
 //       /// This iterator goes through each node.
@@ -188,14 +180,6 @@
 // 	/// \sa operator==(Node n)
 // 	///
 // 	bool operator!=(Edge) const { return true; }
-//  	///Comparison operator.
-
-// 	///This is a strict ordering between the nodes.
-// 	///
-// 	///This ordering can be different from the order in which NodeIt
-// 	///goes through the nodes.
-// 	///\todo Possibly we don't need it.
-//  	bool operator<(Edge) const { return true; }
 //       };
     
 //       /// This iterator goes trough the outgoing edges of a node.
@@ -339,30 +323,6 @@
 // 	/// edge of the corresponding node.
 // 	EdgeIt& operator++() { return *this; }
 //       };
-
-//       /// First node of the graph.
-
-//       /// \retval i the first node.
-//       /// \return the first node.
-//       ///
-//       NodeIt& first(NodeIt& i) const { return i; }
-
-//       /// The first incoming edge.
-
-//       /// The first incoming edge.
-//       ///
-//       InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
-//       /// The first outgoing edge.
-
-//       /// The first outgoing edge.
-//       ///
-//       OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
-//       /// The first edge of the Graph.
-
-//       /// The first edge of the Graph.
-//       ///
-//       EdgeIt& first(EdgeIt& i) const { return i; }
-
 //       ///Gives back the target node of an edge.
 
 //       ///Gives back the target node of an edge.
@@ -373,40 +333,15 @@
 //       ///Gives back the source node of an edge.
 //       ///
 //       Node source(Edge) const { return INVALID; }
-  
-//       ///Gives back the \e id of a node.
-
-//       ///\warning Not all graph structures provide this feature.
-//       ///
-//       ///\todo Should each graph provide \c id?
-//       int id(const Node&) const { return 0; }
-//       ///Gives back the \e id of an edge.
-
-//       ///\warning Not all graph structures provide this feature.
-//       ///
-//       ///\todo Should each graph provide \c id?
-//       int id(const Edge&) const { return 0; }
-
-//       ///\e
-      
-//       ///\todo Should it be in the concept?
-//       ///
-//       int nodeNum() const { return 0; }
-//       ///\e
-
-//       ///\todo Should it be in the concept?
-//       ///
-//       int edgeNum() const { return 0; }
-
-
-//       ///Reference map of the nodes to type \c T.
+//       /// Read write map of the nodes to type \c T.
 
 //       /// \ingroup concept
-//       ///Reference map of the nodes to type \c T.
+//       /// ReadWrite map of the nodes to type \c T.
 //       /// \sa Reference
 //       /// \warning Making maps that can handle bool type (NodeMap<bool>)
 //       /// needs some extra attention!
-//       template<class T> class NodeMap : public ReferenceMap< Node, T >
+//       template<class T> 
+//       class NodeMap : public ReadWriteMap< Node, T >
 //       {
 //       public:
 
@@ -416,21 +351,21 @@
 // 	NodeMap(const StaticGraph&, T) { }
 
 // 	///Copy constructor
-// 	template<typename TT> NodeMap(const NodeMap<TT>&) { }
+// 	NodeMap(const NodeMap&) { }
 // 	///Assignment operator
-// 	template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
-// 	{ return *this; }
+// 	NodeMap& operator=(const NodeMap&) { return *this; }
+// 	// \todo fix this concept
 //       };
 
-//       ///Reference map of the edges to type \c T.
+//       /// Read write map of the edges to type \c T.
 
 //       /// \ingroup concept
 //       ///Reference map of the edges to type \c T.
 //       /// \sa Reference
 //       /// \warning Making maps that can handle bool type (EdgeMap<bool>)
 //       /// needs some extra attention!
-//       template<class T> class EdgeMap
-// 	: public ReferenceMap<Edge,T>
+//       template<class T> 
+//       class EdgeMap : public ReadWriteMap<Edge,T>
 //       {
 //       public:
 
@@ -438,213 +373,14 @@
 // 	EdgeMap(const StaticGraph&) { }
 // 	///\e
 // 	EdgeMap(const StaticGraph&, T) { }
-    
 // 	///Copy constructor
-// 	template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
+// 	EdgeMap(const EdgeMap&) { }
 // 	///Assignment operator
-// 	template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
-// 	{ return *this; }
+// 	EdgeMap& operator=(const EdgeMap&) { return *this; }
+// 	// \todo fix this concept    
 //       };
 //     };
 
-//     struct DummyType {
-//       int value;
-//       DummyType() {}
-//       DummyType(int p) : value(p) {}
-//       DummyType& operator=(int p) { value = p; return *this;}
-//     };
-    
-//     ///\brief Checks whether \c G meets the
-//     ///\ref lemon::concept::StaticGraph "StaticGraph" concept
-//     template<class Graph> void checkCompileStaticGraph(Graph &G) 
-//     {
-//       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;
-  
-//       {
-// 	Node i; Node j(i); Node k(INVALID);
-// 	i=j;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	b=(i==j); b=(i!=j); b=(i<j);
-//       }
-//       {
-// 	NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
-// 	i=j;
-// 	j=G.first(i);
-// 	j=++i;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	Node n(i);
-// 	n=i;
-// 	b=(i==j); b=(i!=j); b=(i<j);
-// 	//Node ->NodeIt conversion
-// 	NodeIt ni(G,n);
-//       }
-//       {
-// 	Edge i; Edge j(i); Edge k(INVALID);
-// 	i=j;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	b=(i==j); b=(i!=j); b=(i<j);
-//       }
-//       {
-// 	EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
-// 	i=j;
-// 	j=G.first(i);
-// 	j=++i;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	Edge e(i);
-// 	e=i;
-// 	b=(i==j); b=(i!=j); b=(i<j);
-// 	//Edge ->EdgeIt conversion
-// 	EdgeIt ei(G,e);
-//       }
-//       {
-// 	Node n;
-// 	InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
-// 	i=j;
-// 	j=G.first(i,n);
-// 	j=++i;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	Edge e(i);
-// 	e=i;
-// 	b=(i==j); b=(i!=j); b=(i<j);
-// 	//Edge ->InEdgeIt conversion
-// 	InEdgeIt ei(G,e);
-//       }
-//       {
-// 	Node n;
-// 	OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
-// 	i=j;
-// 	j=G.first(i,n);
-// 	j=++i;
-// 	bool b; b=true;
-// 	b=(i==INVALID); b=(i!=INVALID);
-// 	Edge e(i);
-// 	e=i;
-// 	b=(i==j); b=(i!=j); b=(i<j);
-// 	//Edge ->OutEdgeIt conversion
-// 	OutEdgeIt ei(G,e);
-//       }
-//       {
-// 	Node n,m;
-// 	n=m=INVALID;
-// 	Edge e;
-// 	e=INVALID;
-// 	n=G.source(e);
-// 	n=G.target(e);
-//       }
-//       // id tests
-//       { Node n; int i=G.id(n); i=i; }
-//       { Edge e; int i=G.id(e); i=i; }
-//       //NodeMap tests
-//       {
-// 	Node k;
-// 	typename Graph::template NodeMap<int> m(G);
-// 	//Const map
-// 	typename Graph::template NodeMap<int> const &cm = m;
-// 	//Inicialize with default value
-// 	typename Graph::template NodeMap<int> mdef(G,12);
-// 	//Copy
-// 	typename Graph::template NodeMap<int> mm(cm);
-// 	//Copy from another type
-// 	typename Graph::template NodeMap<double> dm(cm);
-// 	//Copy to more complex type
-// 	typename Graph::template NodeMap<DummyType> em(cm);
-// 	int v;
-// 	v=m[k]; m[k]=v; m.set(k,v);
-// 	v=cm[k];
-    
-// 	m=cm;  
-// 	dm=cm; //Copy from another type  
-// 	em=cm; //Copy to more complex type
-// 	{
-// 	  //Check the typedef's
-// 	  typename Graph::template NodeMap<int>::Value val;
-// 	  val=1;
-// 	  typename Graph::template NodeMap<int>::Key key;
-// 	  key = typename Graph::NodeIt(G);
-// 	}
-//       }  
-//       { //bool NodeMap
-// 	Node k;
-// 	typename Graph::template NodeMap<bool> m(G);
-// 	typename Graph::template NodeMap<bool> const &cm = m;  //Const map
-// 	//Inicialize with default value
-// 	typename Graph::template NodeMap<bool> mdef(G,12);
-// 	typename Graph::template NodeMap<bool> mm(cm);   //Copy
-// 	typename Graph::template NodeMap<int> dm(cm); //Copy from another type
-// 	bool v;
-// 	v=m[k]; m[k]=v; m.set(k,v);
-// 	v=cm[k];
-    
-// 	m=cm;  
-// 	dm=cm; //Copy from another type
-// 	m=dm; //Copy to another type
-
-// 	{
-// 	  //Check the typedef's
-// 	  typename Graph::template NodeMap<bool>::Value val;
-// 	  val=true;
-// 	  typename Graph::template NodeMap<bool>::Key key;
-// 	  key= typename Graph::NodeIt(G);
-// 	}
-//       }
-//       //EdgeMap tests
-//       {
-// 	Edge k;
-// 	typename Graph::template EdgeMap<int> m(G);
-// 	typename Graph::template EdgeMap<int> const &cm = m;  //Const map
-// 	//Inicialize with default value
-// 	typename Graph::template EdgeMap<int> mdef(G,12);
-// 	typename Graph::template EdgeMap<int> mm(cm);   //Copy
-// 	typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
-// 	int v;
-// 	v=m[k]; m[k]=v; m.set(k,v);
-// 	v=cm[k];
-    
-// 	m=cm;  
-// 	dm=cm; //Copy from another type
-// 	{
-// 	  //Check the typedef's
-// 	  typename Graph::template EdgeMap<int>::Value val;
-// 	  val=1;
-// 	  typename Graph::template EdgeMap<int>::Key key;
-// 	  key= typename Graph::EdgeIt(G);
-// 	}
-//       }  
-//       { //bool EdgeMap
-// 	Edge k;
-// 	typename Graph::template EdgeMap<bool> m(G);
-// 	typename Graph::template EdgeMap<bool> const &cm = m;  //Const map
-// 	//Inicialize with default value
-// 	typename Graph::template EdgeMap<bool> mdef(G,12);
-// 	typename Graph::template EdgeMap<bool> mm(cm);   //Copy
-// 	typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
-// 	bool v;
-// 	v=m[k]; m[k]=v; m.set(k,v);
-// 	v=cm[k];
-    
-// 	m=cm;  
-// 	dm=cm; //Copy from another type
-// 	m=dm; //Copy to another type
-// 	{
-// 	  //Check the typedef's
-// 	  typename Graph::template EdgeMap<bool>::Value val;
-// 	  val=true;
-// 	  typename Graph::template EdgeMap<bool>::Key key;
-// 	  key= typename Graph::EdgeIt(G);
-// 	}
-//       }
-//     }
-    
 //     /// An empty non-static graph class.
     
 //     /// This class provides everything that \ref StaticGraph
@@ -665,10 +401,10 @@
 //       Node addNode() { return INVALID; }
 //       ///Add a new edge to the graph.
 
-//       ///Add a new edge to the graph with source node \c t
-//       ///and target node \c h.
+//       ///Add a new edge to the graph with source node \c s
+//       ///and target node \c t.
 //       ///\return the new edge.
-//       Edge addEdge(Node h, Node t) { return INVALID; }
+//       Edge addEdge(Node s, Node t) { return INVALID; }
     
 //       /// Resets the graph.
 
@@ -678,30 +414,6 @@
 //       void clear() { }
 //     };
 
-    
-//     ///\brief Checks whether \c G meets the
-//     ///\ref lemon::concept::ExtendableGraph "ExtendableGraph" concept
-//     template<class Graph> void checkCompileExtendableGraph(Graph &G) 
-//     {
-//       checkCompileStaticGraph(G);
-
-//       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;
-  
-//       Node n,m;
-//       n=G.addNode();
-//       m=G.addNode();
-//       Edge e;
-//       e=G.addEdge(n,m); 
-  
-//       //  G.clear();
-//     }
-
-
 //     /// An empty erasable graph class.
   
 //     /// This class is an extension of \ref ExtendableGraph. It also makes it
@@ -725,43 +437,8 @@
 //       ///
 //       void erase(Edge e) { }
 //     };
-    
-//     template<class Graph> void checkCompileGraphEraseEdge(Graph &G) 
-//     {
-//       typename Graph::Edge e;
-//       G.erase(e);
-//     }
-
-//     template<class Graph> void checkCompileGraphEraseNode(Graph &G) 
-//     {
-//       typename Graph::Node n;
-//       G.erase(n);
-//     }
-
-//     ///\brief Checks whether \c G meets the
-//     ///\ref lemon::concept::EresableGraph "EresableGraph" concept
-//     template<class Graph> void checkCompileErasableGraph(Graph &G) 
-//     {
-//       checkCompileExtendableGraph(G);
-//       checkCompileGraphEraseNode(G);
-//       checkCompileGraphEraseEdge(G);
-//     }
-
-//     ///Checks whether a graph has findEdge() member function.
-    
-//     ///\todo findEdge() might be a global function.
-//     ///
-//     template<class Graph> void checkCompileGraphFindEdge(Graph &G) 
-//     {
-//       typedef typename Graph::NodeIt Node;
-//       typedef typename Graph::NodeIt NodeIt;
-
-//       G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
-//       G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));  
-//     }
-
-
 
+    
     /************* New GraphBase stuff **************/
 
 
@@ -815,10 +492,10 @@
       // a required...)
 
       template<typename T>
-      class NodeMap : public GraphMap<Node, T, GraphBase> {};
+      class NodeMap : public GraphMap<GraphBase, Node, T> {};
 
       template<typename T>
-      class EdgeMap : public GraphMap<Edge, T, GraphBase> {};
+      class EdgeMap : public GraphMap<GraphBase, Node, T> {};
     };
 
 
@@ -833,14 +510,14 @@
     public:
       typedef BaseGraphComponent::Node Node;
       typedef BaseGraphComponent::Edge Edge;
-    };
 
-    template <typename Graph>
-    struct StaticGraphConcept {
-      void constraints() {
-	function_requires<IterableGraphComponentConcept<Graph> >();
-	function_requires<MappableGraphComponentConcept<Graph> >();
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<IterableGraphComponent, _Graph>();
+	  checkConcept<MappableGraphComponent, _Graph>();
+	}
+      };
     };
 
     class ExtendableGraph 
@@ -849,15 +526,15 @@
     public:
       typedef BaseGraphComponent::Node Node;
       typedef BaseGraphComponent::Edge Edge;
-    };
 
-    template <typename Graph>
-    struct ExtendableGraphConcept {
-      void constraints() {
-	function_requires<StaticGraphConcept<Graph> >();
-	function_requires<ExtendableGraphComponentConcept<Graph> >();
-	function_requires<ClearableGraphComponentConcept<Graph> >();
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<StaticGraph, _Graph >();
+	  checkConcept<ExtendableGraphComponent, _Graph >();
+	  checkConcept<ClearableGraphComponent, _Graph >();
+	}
+      };
     };
 
     class ErasableGraph 
@@ -866,14 +543,14 @@
     public:
       typedef BaseGraphComponent::Node Node;
       typedef BaseGraphComponent::Edge Edge;
-    };
 
-    template <typename Graph>
-    struct ErasableGraphConcept {
-      void constraints() {
-	function_requires<ExtendableGraphConcept<Graph> >();
-	function_requires<ErasableGraphComponentConcept<Graph> >();
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<ExtendableGraph, _Graph >();
+	  checkConcept<ErasableGraphComponent, _Graph >();
+	}
+      };
     };
 
     // @}

Modified: hugo/trunk/src/lemon/concept/graph_component.h
==============================================================================
--- hugo/trunk/src/lemon/concept/graph_component.h	(original)
+++ hugo/trunk/src/lemon/concept/graph_component.h	Sat Nov 13 22:37:54 2004
@@ -37,90 +37,64 @@
     /// base class, this is a template. For Node you should instantiate it
     /// with character 'n' and for Edge with 'e'.
 
-    template<char Ch>
+    template<char _selector>
     class GraphItem {
     public:
+      /// Default constructor.
+      
+      /// @warning The default constructor sets the item
+      /// to an undefined value.
       GraphItem() {}
+      /// Copy constructor.
+      
+      /// Copy constructor.
+      ///
+      GraphItem(GraphItem const&) {}
+      /// Invalid constructor \& conversion.
+
+      /// This constructor initializes the item to be invalid.
+      /// \sa Invalid for more details.
       GraphItem(Invalid) {}
+      /// Assign operator for nodes.
 
-      // We explicitely list these:
-      GraphItem(GraphItem const&) {}
+      /// The nodes are assignable. 
+      ///
       GraphItem& operator=(GraphItem const&) { return *this; }
-
+      /// Equality operator.
+      
+      /// Two iterators are equal if and only if they represents the
+      /// same node in the graph or both are invalid.
       bool operator==(GraphItem) const { return false; }
+      /// Inequality operator.
+	
+      /// \sa operator==(const Node& n)
+      ///
       bool operator!=(GraphItem) const { return false; }
 
       // Technical requirement. Do we really need this?
-      bool operator<(GraphItem) const { return false; }
-    };
+      //      bool operator<(GraphItem) const { return false; }
 
 
-    template<typename GI>
-    struct GraphItemConcept {
-      void constraints() {
-	GI i1;
-	GI i2 = i1;
-	GI i3 = INVALID;
-	
-	i1 = i2 = i3;
-
-	bool b;
-	b = (ia == ib) && (ia != ib) && (ia < ib);
-	b = (ia == INVALID) && (ib != INVALID);
-      }
-
-      const GI &ia;
-      const GI &ib;
-    };
-
-
-    template<typename Iter, typename Graph, typename BaseItem>
-    struct GraphIteratorConcept {
-      void constraints() {
-	function_requires< GraphItemConcept<Iter> >();
-	Iter it1(g);
-
-	/// \todo Do we need NodeIt(Node) kind of constructor?
-	//	Iter it2(bj);
-	Iter it2;
-
-	it2 = ++it1;
-	++it2 = it1;
-	++(++it1);
-	/// \bug This should be: is_base_and_derived<BaseItem, Iter>
-	BaseItem bi = it1;
-	bi = it2;
-      }
-
-      BaseItem bj;
-      Graph g;
-    };
-
-    template<typename Iter, typename Graph>
-    struct GraphIncIteratorConcept {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Edge Edge;
-      void constraints() {
-	function_requires< GraphItemConcept<Iter> >();
-	Iter it1(graph, node);
-	/// \todo Do we need OutEdgeIt(Edge) kind of constructor?
-	//	Iter it2(edge);
-	Iter it2;
-
-	it2 = ++it1;
-	++it2 = it1;
-	++(++it1);
-	Edge e = it1;
-	e = it2;
-      }
+      template<typename _GraphItem>
+      struct Constraints {
+	void constraints() {
+	  _GraphItem i1;
+	  _GraphItem i2 = i1;
+	  _GraphItem i3 = INVALID;
+	  
+	  i1 = i2 = i3;
+
+	  bool b;
+	  //	  b = (ia == ib) && (ia != ib) && (ia < ib);
+	  b = (ia == ib) && (ia != ib);
+	  b = (ia == INVALID) && (ib != INVALID);
+	}
 
-      Edge edge;
-      Node node;
-      Graph graph;
+	const _GraphItem &ia;
+	const _GraphItem &ib;
+      };
     };
 
-
-
     /// An empty base graph class.
   
     /// This class provides the minimal set of features needed for a graph
@@ -139,108 +113,13 @@
 
       /// This class represents the Nodes of the graph. 
       ///
-      class Node {
-      public:
-
-	/// Default constructor.
-
-	/// @warning The default constructor sets the iterator
-	/// to an undefined value.
-
-	Node() {}
-	/// Copy constructor.
-
-	/// Copy constructor.
-	///
-	Node(const Node&) {}
-
-	/// Invalid constructor \& conversion.
-
-	/// This constructor initializes the iterator to be invalid.
-	/// \sa Invalid for more details.
-	Node(Invalid) {}
-
-
-	/// Assign operator for nodes.
-
-	/// The nodes are assignable. 
-	///
-	Node& operator=(const Node&) { return *this;}
-
-	/// Equality operator.
-
-	/// Two iterators are equal if and only if they represents the
-	/// same node in the graph or both are invalid.
-	bool operator==(const Node&) const { return true;}
-
-
-	/// Inequality operator.
-	
-	/// \sa operator==(const Node& n)
-	///
-	bool operator!=(const Node&) const { return true;}
-
- 	/// Comparison operator.
-
-	/// This is a strict ordering between the nodes.
-	///
-	/// This ordering can be different from the iterating order of nodes.
-	/// \todo Possibly we don't need it.
-	bool operator<(const Node&) const { return true;}
-      };
+      typedef GraphItem<'n'> Node;
 
       /// Edge class of the graph.
 
       /// This class represents the Edges of the graph. 
       ///
-      class Edge {
-      public:
-
-	/// Default constructor.
-
-	/// @warning The default constructor sets the iterator
-	/// to an undefined value.
-
-	Edge() {}
-	/// Copy constructor.
-
-	/// Copy constructor.
-	///
-	Edge(const Edge&) {}
-
-	/// Invalid constructor \& conversion.
-
-	/// This constructor initializes the iterator to be invalid.
-	/// \sa Invalid for more details.
-	Edge(Invalid) {}
-
-	/// Assign operator for edges.
-
-	/// The edges are assignable. 
-	///
-	Edge& operator=(const Edge&) { return *this;}
-
-	/// Equality operator.
-
-	/// Two iterators are equal if and only if they represents the
-	/// same edge in the graph or both are invalid.
-	bool operator==(const Edge&) const { return true;}
-
-
-	/// Inequality operator.
-	
-	/// \sa operator==(const Edge& n)
-	///
-	bool operator!=(const Edge&) const { return true;}
-
- 	/// Comparison operator.
-
-	/// This is a strict ordering between the edges.
-	///
-	/// This ordering can be different from the iterating order of edges.
-	/// \todo Possibly we don't need it.
-	bool operator<(const Edge&) const { return true;}
-      };
+      typedef GraphItem<'e'> Edge;
 
       ///Gives back the target node of an edge.
 
@@ -253,31 +132,26 @@
       ///Gives back the source node of an edge.
       ///
       Node source(const Edge&) const { return INVALID;}
-    };
-
 
-    /// Concept check structure for BaseGraph.
 
-    /// Concept check structure for BaseGraph.
-    ///
-
-    template <typename Graph>
-    struct BaseGraphComponentConcept {
-      typedef typename Graph::Node Node;
-      typedef typename Graph::Edge Edge;
-      
-      void constraints() {
-	function_requires< GraphItemConcept<Node> >();
-	function_requires< GraphItemConcept<Edge> >();
-	{
-	  Node n;
-	  Edge e;
-	  n = graph.source(e);
-	  n = graph.target(e);
-	}      
-      }
+      template <typename _Graph>
+      struct Constraints {
+	typedef typename _Graph::Node Node;
+	typedef typename _Graph::Edge Edge;
+      
+	void constraints() {
+	  checkConcept<GraphItem<'n'>, Node>();
+	  checkConcept<GraphItem<'e'>, Edge>();
+	  {
+	    Node n;
+	    Edge e;
+	    n = graph.source(e);
+	    n = graph.target(e);
+	  }      
+	}
       
-      const Graph& graph;
+	const _Graph& graph;
+      };
     };
 
     /// An empty iterable base graph class.
@@ -340,39 +214,35 @@
       /// Gives back the next of the Edges start from the given Node.
       ///     
       void nextOut(Edge&) const {}
-    };
-
 
-    /// Concept check structure for IterableBaseGraph.
 
-    /// Concept check structure for IterableBaseGraph.
-    ///
-    template <typename Graph>
-    struct BaseIterableGraphComponentConcept {
+      template <typename _Graph>
+      struct Constraints {
       
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	typename Graph::Node node;      
-	typename Graph::Edge edge;
-	{
-	  graph.first(node);
-	  graph.next(node);
-	}
-	{
-	  graph.first(edge);
-	  graph.next(edge);
-	}
-	{
-	  graph.firstIn(edge, node);
-	  graph.nextIn(edge);
-	}
-	{
-	  graph.firstOut(edge, node);
-	  graph.nextOut(edge);
+	void constraints() {
+	  checkConcept< BaseGraphComponent, _Graph >();
+	  typename _Graph::Node node;      
+	  typename _Graph::Edge edge;
+	  {
+	    graph.first(node);
+	    graph.next(node);
+	  }
+	  {
+	    graph.first(edge);
+	    graph.next(edge);
+	  }
+	  {
+	    graph.firstIn(edge, node);
+	    graph.nextIn(edge);
+	  }
+	  {
+	    graph.firstOut(edge, node);
+	    graph.nextOut(edge);
+	  }
 	}
-      }
 
-      const Graph& graph;
+	const _Graph& graph;
+      };
     };
 
     /// An empty idable base graph class.
@@ -381,7 +251,6 @@
     /// core 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 IDableGraphComponent : virtual public BaseGraphComponent {
     public:
 
@@ -399,27 +268,22 @@
       /// Gives back an unique integer id for the Edge. 
       ///
       int id(const Edge&) const { return -1;}
-    };
-
 
-    /// Concept check structure for IdableBaseGraph.
+      template <typename _Graph>
+      struct Constraints {
 
-    /// Concept check structure for IdableBaseGraph.
-    ///
-    template <typename Graph>
-    struct IDableGraphComponentConcept {
-
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	typename Graph::Node node;
-	int nid = graph.id(node);
-	nid = graph.id(node);
-	typename Graph::Edge edge;
-	int eid = graph.id(edge);
-	eid = graph.id(edge);
-      }
+	void constraints() {
+	  checkConcept< BaseGraphComponent, _Graph >();
+	  typename _Graph::Node node;
+	  int nid = graph.id(node);
+	  nid = graph.id(node);
+	  typename _Graph::Edge edge;
+	  int eid = graph.id(edge);
+	  eid = graph.id(edge);
+	}
 
-      const Graph& graph;
+	const _Graph& graph;
+      };
     };
 
 
@@ -443,24 +307,20 @@
       /// Gives back an integer greater or equal to the maximum Edge id. 
       ///
       int maxId(Edge = INVALID) const { return -1;}
-    };
 
-    /// Concept check structure for MaxIdableBaseGraph.
+      template <typename _Graph>
+      struct Constraints {
 
-    /// Concept check structure for MaxIdableBaseGraph.
-    ///
-    template <typename Graph>
-    struct MaxIDableGraphComponentConcept {
-
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	int nid = graph.maxId(typename Graph::Node());
-	ignore_unused_variable_warning(nid);
-	int eid = graph.maxId(typename Graph::Edge());
-	ignore_unused_variable_warning(eid);
-      }
-
-      const Graph& graph;
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph>();
+	  int nid = graph.maxId(typename _Graph::Node());
+	  ignore_unused_variable_warning(nid);
+	  int eid = graph.maxId(typename _Graph::Edge());
+	  ignore_unused_variable_warning(eid);
+	}
+      
+	const _Graph& graph;
+      };
     };
 
     /// An empty extendable base graph class.
@@ -490,23 +350,18 @@
 	return INVALID;
       }
 
-    };
-
-    /// Concept check structure for ExtendableBaseGraph.
-
-    /// Concept check structure for ExtendableBaseGraph.
-    ///
-    template <typename Graph>
-    struct BaseExtendableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	typename Graph::Node node_a, node_b;
-	node_a = graph.addNode();
-	typename Graph::Edge edge;
-	edge = graph.addEdge(node_a, node_b);
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph >();
+	  typename _Graph::Node node_a, node_b;
+	  node_a = graph.addNode();
+	  typename _Graph::Edge edge;
+	  edge = graph.addEdge(node_a, node_b);
+	}
 
-      Graph& graph;
+	_Graph& graph;
+      };
     };
 
     /// An empty erasable base graph class.
@@ -532,23 +387,18 @@
       ///
       void erase(const Edge&) {}
 
-    };
-
-    /// Concept check structure for ErasableBaseGraph.
-
-    /// Concept check structure for ErasableBaseGraph.
-    ///
-    template <typename Graph>
-    struct BaseErasableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	typename Graph::Node node;
-	graph.erase(node);
-	typename Graph::Edge edge;
-	graph.erase(edge);
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph>();
+	  typename _Graph::Node node;
+	  graph.erase(node);
+	  typename _Graph::Edge edge;
+	  graph.erase(edge);
+	}
 
-      Graph& graph;
+	_Graph& graph;
+      };
     };
 
     /// An empty clearable base graph class.
@@ -564,111 +414,254 @@
       /// Erase all the Nodes and Edges from the graph.
       ///
       void clear() {}    
-    };
-
-    /// Concept check function for ErasableBaseGraph.
 
-    /// Concept check function for ErasableBaseGraph.
-    ///
-    template <typename Graph>
-    struct BaseClearableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	graph.clear();
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept< BaseGraphComponent, _Graph>();
+	  graph.clear();
+	}
 
-      Graph& graph;
+	_Graph& graph;
+      };
     };
 
 
-    class IterableGraphComponent :
-      virtual public BaseIterableGraphComponent {
+    /// Skeleton class for graph NodeIt and EdgeIt
 
+    /// Skeleton class for graph NodeIt and EdgeIt.
+    ///
+    template <typename _Graph, typename _Item>
+    class GraphIterator : public _Item {
     public:
-    
-      typedef IterableGraphComponent Graph;
+      /// \todo Don't we need the Item type as typedef?
 
-      typedef BaseGraphComponent::Node Node;
-      typedef BaseGraphComponent::Edge Edge;
+      /// Default constructor.
+      
+      /// @warning The default constructor sets the iterator
+      /// to an undefined value.
+      GraphIterator() {}
+      /// Copy constructor.
+      
+      /// Copy constructor.
+      ///
+      GraphIterator(GraphIterator const&) {}
+      /// Sets the iterator to the first item.
+      
+      /// Sets the iterator to the first item of \c the graph.
+      ///
+      explicit GraphIterator(const _Graph&) {}
+      /// Invalid constructor \& conversion.
 
-      class NodeIt : public Node {
-      public:
-	NodeIt() {}
-	NodeIt(Invalid) {}
-	// explicit NodeIt(Node) {}
-	explicit NodeIt(const Graph&) {}
+      /// This constructor initializes the item to be invalid.
+      /// \sa Invalid for more details.
+      GraphIterator(Invalid) {}
+      /// Assign operator for items.
+
+      /// The items are assignable. 
+      ///
+      GraphIterator& operator=(GraphIterator const&) { return *this; }      
+      /// Next item.
 
-	NodeIt& operator++() { return *this; }
-	//	Node operator*() const { return INVALID; }
+      /// Assign the iterator to the next item.
+      ///
+      GraphIterator& operator++() { return *this; }
+      //	Node operator*() const { return INVALID; }
+      /// Equality operator
 
-	bool operator==(const NodeIt&) const { return true;}
-	bool operator!=(const NodeIt&) const { return true;}
+      /// Two iterators are equal if and only if they point to the
+      /// same object or both are invalid.
+      bool operator==(const GraphIterator&) const { return true;}
+      /// Inequality operator
+	
+      /// \sa operator==(Node n)
+      ///
+      bool operator!=(const GraphIterator&) const { return true;}
+      
+      template<typename _GraphIterator>
+      struct Constraints {
+	void constraints() {
+	  //	  checkConcept< Item, _GraphIterator >();
+	  _GraphIterator it1(g);
+	
+	  /// \todo Do we need NodeIt(Node) kind of constructor?
+	  //	_GraphIterator it2(bj);
+	  _GraphIterator it2;
+
+	  it2 = ++it1;
+	  ++it2 = it1;
+	  ++(++it1);
+	  /// \bug This should be: is_base_and_derived<BaseItem, _GraphIterator>
+	  _Item bi = it1;
+	  bi = it2;
+	}
+	_Graph& g;
       };
+    };
 
-      class EdgeIt : public Edge {
-      public:
-	EdgeIt() {}
-	EdgeIt(Invalid) {}
-	// explicit EdgeIt(Edge) {}
-	explicit EdgeIt(const Graph&) {}
+    /// Skeleton class for graph InEdgeIt and OutEdgeIt
 
-	EdgeIt& operator++() { return *this; }
-	//	Edge operator*() const { return INVALID; }
+    /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
+    /// base class, the _selector is a additional template parameter. For 
+    /// InEdgeIt you should instantiate it with character 'i' and for 
+    /// OutEdgeIt with 'o'.
+    /// \todo check the name of the concept GraphIncEdgeIterator
+    template <typename _Graph, char _selector>
+    class GraphIncEdgeIterator : public _Graph::Edge {
+    public:
+      /// Default constructor.
+      
+      /// @warning The default constructor sets the iterator
+      /// to an undefined value.
+      GraphIncEdgeIterator() {}
+      /// Copy constructor.
+      
+      /// Copy constructor.
+      ///
+      GraphIncEdgeIterator(GraphIncEdgeIterator const&) {}
+      /// Sets the iterator to the first edge incoming into or outgoing from the node.
+      
+      /// Sets the iterator to the first edge incoming into or outgoing from the node.
+      ///
+      explicit GraphIncEdgeIterator(const _Graph&, const typename _Graph::Node&) {}
+      /// Invalid constructor \& conversion.
 
-	bool operator==(const EdgeIt&) const { return true;}
-	bool operator!=(const EdgeIt&) const { return true;}
-      };
+      /// This constructor initializes the item to be invalid.
+      /// \sa Invalid for more details.
+      GraphIncEdgeIterator(Invalid) {}
+      /// Assign operator for nodes.
 
-      class InEdgeIt : public Edge {
-      public:
-	InEdgeIt() {}
-	InEdgeIt(Invalid) {}
-	// explicit InEdgeIt(Edge) {}
-	explicit InEdgeIt(const Graph&, const Node&) {}
+      /// The nodes are assignable. 
+      ///
+      GraphIncEdgeIterator& operator=(GraphIncEdgeIterator const&) { return *this; }      
+      /// Next edge.
 
-	InEdgeIt& operator++() { return *this; }
-	//	Edge operator*() const { return INVALID; }
+      /// Assign the iterator to the next node.
+      ///
+      GraphIncEdgeIterator& operator++() { return *this; }
+      //	Node operator*() const { return INVALID; }
+      /// Equality operator
+
+      /// Two iterators are equal if and only if they point to the
+      /// same object or both are invalid.
+      bool operator==(const GraphIncEdgeIterator&) const { return true;}
+      /// Inequality operator
+	
+      /// \sa operator==(Node n)
+      ///
+      bool operator!=(const GraphIncEdgeIterator&) const { return true;}
 
-	bool operator==(const InEdgeIt&) const { return true;}
-	bool operator!=(const InEdgeIt&) const { return true;}
+      template <typename _GraphIncEdgeIterator>
+      struct Constraints {
+	typedef typename _Graph::Node Node;
+	typedef typename _Graph::Edge Edge;
+	void constraints() {
+	  checkConcept<GraphItem<'e'>, _GraphIncEdgeIterator>();
+	  _GraphIncEdgeIterator it1(graph, node);
+	  /// \todo Do we need OutEdgeIt(Edge) kind of constructor?
+	  //	_GraphIncEdgeIterator it2(edge);
+	  _GraphIncEdgeIterator it2;
+
+	  it2 = ++it1;
+	  ++it2 = it1;
+	  ++(++it1);
+	  Edge e = it1;
+	  e = it2;
+	}
+
+	Edge& edge;
+	Node& node;
+	_Graph& graph;
       };
+    };
+    /// An empty iterable base graph class.
+  
+    /// This class provides beside the core graph features
+    /// iterator based iterable interface for the graph structure.
+    /// This concept is part of the StaticGraphConcept.
+    class IterableGraphComponent : virtual public BaseGraphComponent {
 
-      class OutEdgeIt : public Edge {
-      public:
-	OutEdgeIt() {}
-	OutEdgeIt(Invalid) {}
-	// explicit OutEdgeIt(Edge) {}
-	explicit OutEdgeIt(const Graph&, const Node&) {}
+    public:
+    
+      typedef IterableGraphComponent Graph;
 
-	OutEdgeIt& operator++() { return *this; }
-	//	Edge operator*() const { return INVALID; }
+      typedef BaseGraphComponent::Node Node;
+      typedef BaseGraphComponent::Edge Edge;
 
-	bool operator==(const OutEdgeIt&) const { return true;}
-	bool operator!=(const OutEdgeIt&) const { return true;}
-      };
+      /// This iterator goes through each node.
+
+      /// This iterator goes through each node.
+      ///
+      typedef GraphIterator<Graph, Node> NodeIt;
+      /// This iterator goes through each node.
+
+      /// This iterator goes through each node.
+      ///
+      typedef GraphIterator<Graph, Edge> EdgeIt;
+      /// This iterator goes trough the incoming edges of a node.
+
+      /// This iterator goes trough the \e inccoming edges of a certain node
+      /// of a graph.
+      typedef GraphIncEdgeIterator<Graph, 'i'> InEdgeIt;
+      /// This iterator goes trough the outgoing edges of a node.
 
+      /// This iterator goes trough the \e outgoing edges of a certain node
+      /// of a graph.
+      typedef GraphIncEdgeIterator<Graph, 'o'> OutEdgeIt;
     };
     
-    template <typename Graph> 
-    struct IterableGraphComponentConcept {
+    template <typename _Graph> 
+    struct Constraints {
       void constraints() {
-  	function_requires< BaseIterableGraphComponentConcept<Graph> >();
+  	checkConcept< BaseGraphComponent, _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;
-  
-	function_requires< GraphIteratorConcept<NodeIt, Graph, Node> >();
-	function_requires< GraphIteratorConcept<EdgeIt, Graph, Edge> >();
-	function_requires< GraphIncIteratorConcept<OutEdgeIt, Graph> >();
-	function_requires< GraphIncIteratorConcept<InEdgeIt, Graph> >();
+	checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >();
+	checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >();
+	checkConcept<GraphIncEdgeIterator<_Graph, 'i'>, typename _Graph::InEdgeIt >();
+	checkConcept<GraphIncEdgeIterator<_Graph, 'o'>, typename _Graph::OutEdgeIt >();
       }
     };
 
 
+    template <typename Graph, typename Item, typename _Value>
+    class GraphMap : public ReadWriteMap<Item, _Value> {
+    protected:      
+      GraphMap() {}
+    public:
+      explicit GraphMap(const Graph&) {}
+      GraphMap(const Graph&, const _Value&) {}
+      GraphMap(const GraphMap&) {}
+      
+      GraphMap& operator=(const GraphMap&) { return *this;}
+
+      template<typename _Map>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<ReadWriteMap<Item, _Value>, _Map >();
+	  // Construction with a graph parameter
+	  _Map a(g);
+	  // Constructor with a graph and a default value parameter
+	  _Map a2(g,t);
+	  // Copy constructor. Do we need it?
+	  _Map b=c;
+	  // Copy operator. Do we need it?
+	  a=b;
+
+	  ignore_unused_variable_warning(a2);
+	}
+
+	const _Map &c;
+	const Graph &g;
+	const typename GraphMap::Value &t;
+      };
+
+    };
+
+    /// An empty mappable base graph class.
+  
+    /// This class provides beside the core graph features
+    /// map interface for the graph structure.
+    /// This concept is part of the StaticGraphConcept.
     class MappableGraphComponent : virtual public BaseGraphComponent {
     public:
 
@@ -677,65 +670,78 @@
       typedef BaseGraphComponent::Node Node;
       typedef BaseGraphComponent::Edge Edge;
 
+      /// ReadWrite map of the nodes.
+    
+      /// ReadWrite map of the nodes.
+      ///
       template <typename _Value>
-      class NodeMap : public ReferenceMap<Node, _Value> {
+      class NodeMap : public GraphMap<Graph, Node, _Value> {
+      private:
+	NodeMap();
       public:
-	NodeMap(const Graph&) {}
+	// \todo call the right parent class constructor
+	explicit NodeMap(const Graph&) {}
 	NodeMap(const Graph&, const _Value&) {}
 	NodeMap(const NodeMap&) {}
 
 	NodeMap& operator=(const NodeMap&) { return *this;}
-	
+
       };
 
+      /// ReadWrite map of the edges.
+    
+      /// ReadWrite map of the edges.
+      ///
       template <typename _Value>
-      class EdgeMap : public ReferenceMap<Edge, _Value> {
+      class EdgeMap : public GraphMap<Graph, Edge, _Value> {
+      private:
+	EdgeMap();
       public:
-	EdgeMap(const Graph&) {}
+	// \todo call the right parent class constructor
+	explicit EdgeMap(const Graph&) {}
 	EdgeMap(const Graph&, const _Value&) {}
 	EdgeMap(const EdgeMap&) {}
 
 	EdgeMap& operator=(const EdgeMap&) { return *this;}
-	
+
       };
 
-    };
+      template <typename _Graph>
+      struct Constraints {
 
-    template <typename Graph>
-    struct MappableGraphComponentConcept {
+	struct Type {
+	  int value;
+	  Type() : value(0) {}
+	  Type(int _v) : value(_v) {}
+	};
+
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph>();
+	  { // int map test
+	    typedef typename _Graph::template NodeMap<int> IntNodeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, IntNodeMap >();
+	  } { // bool map test
+	    typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>, BoolNodeMap >();
+	  } { // Type map test
+	    typedef typename _Graph::template NodeMap<Type> TypeNodeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>, TypeNodeMap >();
+	  } 
+
+	  { // int map test
+	    typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, IntEdgeMap >();
+	  } { // bool map test
+	    typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, BoolEdgeMap >();
+	  } { // Type map test
+	    typedef typename _Graph::template EdgeMap<Type> TypeEdgeMap;
+	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>, TypeEdgeMap >();
+	  } 
+	}
 
-      struct Type {
-	int value;
-	Type() : value(0) {}
-	Type(int _v) : value(_v) {}
+	_Graph& graph;
       };
-
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	{ // int map test
-	  typedef typename Graph::template NodeMap<int> IntNodeMap;
-	  function_requires<GraphMapConcept<IntNodeMap,Graph> >();
-	} { // bool map test
-	  typedef typename Graph::template NodeMap<bool> BoolNodeMap;
-	  function_requires<GraphMapConcept<BoolNodeMap,Graph> >();
-	} { // Type map test
-	  typedef typename Graph::template NodeMap<Type> TypeNodeMap;
-	  function_requires<GraphMapConcept<TypeNodeMap,Graph> >();
-	} 
-
-	{ // int map test
-	  typedef typename Graph::template EdgeMap<int> IntEdgeMap;
-	  function_requires<GraphMapConcept<IntEdgeMap,Graph> >();
-	} { // bool map test
-	  typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;
-	  function_requires<GraphMapConcept<BoolEdgeMap,Graph> >();
-	} { // Type map test
-	  typedef typename Graph::template EdgeMap<Type> TypeEdgeMap;
-	  function_requires<GraphMapConcept<TypeEdgeMap,Graph> >();
-	} 
-      }
-
-      Graph& graph;
     };
 
 
@@ -755,20 +761,18 @@
 	return INVALID;
       }
 
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph >();
+	  typename _Graph::Node node_a, node_b;
+	  node_a = graph.addNode();
+	  typename _Graph::Edge edge;
+	  edge = graph.addEdge(node_a, node_b);      
+	}
+	_Graph& graph;
+      };
     };
-
-    template <typename Graph>
-    struct ExtendableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	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 ErasableGraphComponent : virtual public BaseGraphComponent {
     public:
 
@@ -780,19 +784,18 @@
       void erase(const Node&) {}    
       void erase(const Edge&) {}
 
-    };
-
-    template <typename Graph>
-    struct ErasableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	typename Graph::Node node;
-	graph.erase(node);
-	typename Graph::Edge edge;
-	graph.erase(edge);      
-      }
+      template <typename _Graph>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<BaseGraphComponent, _Graph >();
+	  typename _Graph::Node node;
+	  graph.erase(node);
+	  typename _Graph::Edge edge;
+	  graph.erase(edge);      
+	}
 
-      Graph& graph;
+	_Graph& graph;
+      };
     };
 
     class ClearableGraphComponent : virtual public BaseGraphComponent {
@@ -805,15 +808,15 @@
 
       void clear() {}    
 
-    };
 
-    template <typename Graph>
-    struct ClearableGraphComponentConcept {
-      void constraints() {
-	function_requires< BaseGraphComponentConcept<Graph> >();
-	graph.clear();
-      }
-      Graph& graph;
+      template <typename _Graph>
+      struct ClearableGraphComponentConcept {
+	void constraints() {
+	  checkConcept< BaseGraphComponent, _Graph >();
+	  graph.clear();
+	}
+	_Graph& graph;
+      };
     };
 
   }

Modified: hugo/trunk/src/lemon/concept/maps.h
==============================================================================
--- hugo/trunk/src/lemon/concept/maps.h	(original)
+++ hugo/trunk/src/lemon/concept/maps.h	Sat Nov 13 22:37:54 2004
@@ -40,11 +40,28 @@
       /// Map's value type. (The type of objects associated with the keys).
       typedef T Value;
 
+      // \bug Value don't need to be default constructible.
       /// Returns the value associated with a key.
-      Value operator[](const Key &k) const {return Value();}
+      Value operator[](const Key &) const {return Value();}
 
-      ///Default constructor
-      ReadMap() {}
+      template<typename _ReadMap>
+      struct Constraints {
+
+	void constraints() {
+	  Value val = m[key];
+	  val = m[key];
+	  typename _ReadMap::Value own_val = m[own_key]; 
+	  own_val = m[own_key]; 
+
+	  ignore_unused_variable_warning(val);
+	  ignore_unused_variable_warning(own_val);
+	  ignore_unused_variable_warning(key);
+	}
+	Key& key;
+	typename _ReadMap::Key& own_key;
+	_ReadMap& m;
+      };
+      
     };
 
 
@@ -63,6 +80,26 @@
 
       ///Default constructor
       WriteMap() {}
+
+      template <typename _WriteMap>
+      struct Constraints {
+	void constraints() {
+	  // No constraints for constructor.
+	  m.set(key, val);
+	  m.set(own_key, own_val);
+	  ignore_unused_variable(key);
+	  ignore_unused_variable(val);
+	  ignore_unused_variable(own_key);
+	  ignore_unused_variable(own_val);
+	}
+
+	Value& val;
+	typename _WriteMap::Value own_val;
+	Key& key;
+	typename _WriteMap::Key& own_key;
+	WriteMap& m;
+
+      };
     };
 
     ///Read/Writable map concept
@@ -81,13 +118,18 @@
       /// Sets the value associated with a key.
       void set(const Key &k,const Value &t) {}
 
-      ///Default constructor
-      ReadWriteMap() {}
+      template<typename _ReadWriteMap>
+      struct Constraints {
+	void constraints() {
+	  checkConcept<ReadMap<K, T>, _ReadWriteMap >();
+	  checkConcept<ReadMap<K, T>, _ReadWriteMap >();
+	}
+      };
     };
   
   
     ///Dereferable map concept
-    template<typename K, typename T>
+    template<typename K, typename T, typename R, typename CR>
     class ReferenceMap : public ReadWriteMap<K,T>
     {
     public:
@@ -95,13 +137,14 @@
       typedef K Key;    
       /// Map's value type. (The type of objects associated with the keys).
       typedef T Value;
+      /// Map's reference type.
+      typedef R Reference;
+      /// Map's const reference type.
+      typedef CR ConstReference;
 
     protected:
       Value tmp;
     public:
-      typedef Value& Reference;
-      /// Map's const reference type.
-      typedef const Value& ConstReference;
 
       ///Returns a reference to the value associated to a key.
       Reference operator[](const Key &i) { return tmp; }
@@ -111,133 +154,31 @@
       /// Sets the value associated with a key.
       void set(const Key &k,const Value &t) { operator[](k)=t; }
 
-      ///Default constructor
-      ReferenceMap() {}
-    };
-
-
-    template<typename Item, typename T, typename Graph>
-    class GraphMap : public ReadWriteMap<Item, T> {
-      // I really, really don't like the idea that every graph should have
-      // reference maps! --klao
-
-    private:
-      // We state explicitly that graph maps have no default constructor?
-      GraphMap();
-
-    public:
-      explicit GraphMap(Graph const&) {}
-      // value for initializing
-      GraphMap(Graph const&, T) {}
-
-      // this probably should be required:
-      GraphMap(GraphMap const&) {}
-      GraphMap& operator=(GraphMap const&) { return *this; }
-
-      // but this is a absolute no-op! We should provide a more generic
-      // graph-map-copy operation.
-      //
-      // template<typename TT>
-      // GraphMap(GraphMap<TT> const&);
-      //
-      // template<typename TT>
-      // GraphMap& operator=(const GraphMap<TT>&);
-    };
-
-
-    /****************  Concept-checking classes  ****************/
-
-    template<typename ReadMap>
-    struct ReadMapConcept {
-      typedef typename ReadMap::Key Key;
-      typedef typename ReadMap::Value Value;
-
-      void constraints() {
-	// No constraints for constructor.
-
-	// What are the requirement for the Value?
-	// CopyConstructible? Assignable? None of these?
-	Value v = m[k];
-	v = m[k];
-
-	// FIXME:
-	ignore_unused_variable_warning(v);
-      }
-
-      ReadMap m;
-      Key k;
-    };
-
-    template<typename WriteMap>
-    struct WriteMapConcept {
-      typedef typename WriteMap::Key Key;
-      typedef typename WriteMap::Value Value;
-
-      void constraints() {
-	// No constraints for constructor.
-
-	m.set(k, v);
-      }
-
-      WriteMap m;
-      Key k;
-      Value v;
-    };
-
-    template<typename ReadWriteMap>
-    struct ReadWriteMapConcept {
-      void constraints() {
-	function_requires< ReadMapConcept<ReadWriteMap> >();
-	function_requires< WriteMapConcept<ReadWriteMap> >();
-      }
-    };
-
-    template<typename ReferenceMap>
-    struct ReferenceMapConcept {
-      typedef typename ReferenceMap::Key Key;
-      typedef typename ReferenceMap::Value Value;
-      typedef typename ReferenceMap::Reference Reference;
-
-      // What for is this?
-      typedef typename ReferenceMap::ConstReference ConstReference;
-
-      void constraints() {
-	function_requires< ReadWriteMapConcept<ReferenceMap> >();
-
-	m[k] = v;
-	// Or should we require real reference?
-	// Like this:
-	// Value &vv = m[k];
-	// ignore_unused_variable_warning(vv);
-      }
-
-      ReferenceMap m;
-      Key k;
-      Value v;
-    };
-
-    /// \todo GraphMapConceptCheck
-
-    template<typename GraphMap, typename Graph>
-    struct GraphMapConcept {
-      void constraints() {
-	function_requires< ReadWriteMapConcept<GraphMap> >();
-	// Construction with a graph parameter
-	GraphMap a(g);
-	// Ctor with a graph and a default value parameter
-	GraphMap a2(g,t);
-	// Copy ctor. Do we need it?
-	GraphMap b=c;
-	// Copy operator. Do we need it?
-	a=b;
-
-	ignore_unused_variable_warning(a2);
-      }
-      const GraphMap &c;
-      const Graph &g;
-      const typename GraphMap::Value &t;
+      // \todo rethink this concept
+      template<typename _ReferenceMap>
+      struct ReferenceMapConcept {
+
+	void constraints() {
+	  checkConcept<ReadWriteMap, _ReferenceMap >();
+	  m[key] = val;
+	  val  = m[key];
+	  m[key] = ref;
+	  ref = m[key];
+	  m[own_key] = own_val;
+	  own_val  = m[own_key];
+	  m[own_key] = own_ref;
+	  own_ref = m[own_key];	  	  
+	}
+
+	typename _ReferenceMap::Key& own_key;
+	typename _ReferenceMap::Value& own_val;
+	typename _ReferenceMap::Reference& own_ref;
+	Key& key;
+	Value& val;
+	Reference& ref;
+	ReferenceMap& m;
+      };
     };
-    
 
     // @}
 

Modified: hugo/trunk/src/lemon/concept/undir_graph.h
==============================================================================
--- hugo/trunk/src/lemon/concept/undir_graph.h	(original)
+++ hugo/trunk/src/lemon/concept/undir_graph.h	Sat Nov 13 22:37:54 2004
@@ -38,9 +38,10 @@
       typedef typename Graph::UndirEdge UndirEdge;
       typedef typename Graph::Edge Edge;
       typedef typename Graph::Node Node;
+
       void constraints() {
-	function_requires< BaseIterableGraphComponentConcept<Graph> >();
-	function_requires< GraphItemConcept<UndirEdge> >();
+	checkConcept<BaseIterableGraphComponent, Graph>();
+	checkConcept<GraphItem<'u'>, UndirEdge >();
 
 	/// \bug this should be base_and_derived:
 	UndirEdge ue = e;
@@ -60,14 +61,14 @@
     template <typename Graph>
     struct IterableUndirGraphConcept {
       void constraints() {
-	function_requires< BaseIterableUndirGraphConcept<Graph> > ();
-	function_requires< IterableGraphComponentConcept<Graph> > ();
+	/// \todo we don't need the iterable component should base iterable	
+	//	checkConcept< BaseIterableUndirGraph, Graph > ();
+	checkConcept< IterableGraphComponent, Graph > ();
 
 	typedef typename Graph::UndirEdge UndirEdge;
 	typedef typename Graph::UndirEdgeIt UndirEdgeIt;
 
-	function_requires<
-	  GraphIteratorConcept<UndirEdgeIt, Graph, UndirEdge> >();
+	checkConcept< GraphIterator<Graph, UndirEdge>, UndirEdgeIt >();
       }
     };
 

Modified: hugo/trunk/src/lemon/concept_check.h
==============================================================================
--- hugo/trunk/src/lemon/concept_check.h	(original)
+++ hugo/trunk/src/lemon/concept_check.h	Sat Nov 13 22:37:54 2004
@@ -39,6 +39,11 @@
 #endif
   }
 
+  template <typename Concept, typename Type>
+  inline void checkConcept() {
+    function_requires<typename Concept::template Constraints<Type> >();
+  }
+
 #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
   typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
   template <func##type_var##concept Tp1_> \

Modified: hugo/trunk/src/test/graph_test.cc
==============================================================================
--- hugo/trunk/src/test/graph_test.cc	(original)
+++ hugo/trunk/src/test/graph_test.cc	Sat Nov 13 22:37:54 2004
@@ -20,46 +20,46 @@
 int main() {
   ///\file
   { // checking graph components
-    function_requires<BaseGraphComponentConcept<BaseGraphComponent> >();
+    checkConcept<BaseGraphComponent, BaseGraphComponent >();
 
-    function_requires<BaseIterableGraphComponentConcept<BaseIterableGraphComponent> >();
+    checkConcept<BaseIterableGraphComponent, BaseIterableGraphComponent >();
 
-    function_requires<IDableGraphComponentConcept<IDableGraphComponent> >();
-    function_requires<MaxIDableGraphComponentConcept<MaxIDableGraphComponent> >();
+    checkConcept<IDableGraphComponent, IDableGraphComponent >();
+    checkConcept<MaxIDableGraphComponent, MaxIDableGraphComponent >();
 
-    function_requires<BaseExtendableGraphComponentConcept<BaseExtendableGraphComponent> >();
-    function_requires<BaseErasableGraphComponentConcept<BaseErasableGraphComponent> >();
-    function_requires<BaseClearableGraphComponentConcept<BaseClearableGraphComponent> >();
+    checkConcept<BaseExtendableGraphComponent, BaseExtendableGraphComponent >();
+    checkConcept<BaseErasableGraphComponent, BaseErasableGraphComponent >();
+    checkConcept<BaseClearableGraphComponent, BaseClearableGraphComponent >();
 
-    function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
+    checkConcept<IterableGraphComponent, IterableGraphComponent >();
 
-    function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
+    checkConcept<MappableGraphComponent, MappableGraphComponent >();
 
-    function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >();
-    function_requires<ErasableGraphComponentConcept<ErasableGraphComponent> >();
-    function_requires<ClearableGraphComponentConcept<ClearableGraphComponent> >();
+    checkConcept<ExtendableGraphComponent, ExtendableGraphComponent >();
+    checkConcept<ErasableGraphComponent, ErasableGraphComponent >();
+    checkConcept<ClearableGraphComponent, ClearableGraphComponent >();
   }
   { // checking skeleton graphs
-    function_requires<StaticGraphConcept<StaticGraph> >();
-    function_requires<ExtendableGraphConcept<ExtendableGraph> >();
-    function_requires<ErasableGraphConcept<ErasableGraph> >();
+    checkConcept<StaticGraph, StaticGraph >();
+    checkConcept<ExtendableGraph, ExtendableGraph >();
+    checkConcept<ErasableGraph, ErasableGraph >();
   }
   { // checking list graph
-    function_requires<ErasableGraphConcept<ListGraph> >();
+    checkConcept<ErasableGraph, ListGraph >();
 
     checkGraph<ListGraph>();
     checkGraphNodeMap<ListGraph>();
     checkGraphEdgeMap<ListGraph>();
   }
   { // checking smart graph
-    function_requires<ExtendableGraphConcept<SmartGraph> >();
+    checkConcept<ExtendableGraph, SmartGraph >();
 
     checkGraph<SmartGraph>();
     checkGraphNodeMap<SmartGraph>();
     checkGraphEdgeMap<SmartGraph>();
   }
   { // checking full graph
-    function_requires<StaticGraphConcept<FullGraph> >();
+    checkConcept<StaticGraph, FullGraph >();
   }
 
   std::cout << __FILE__ ": All tests passed.\n";

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	Sat Nov 13 22:37:54 2004
@@ -38,13 +38,11 @@
 using namespace lemon::concept;
 
 
-typedef SmartGraph Graph;
-
 
 int main() 
 {
   {
-    function_requires<StaticGraphConcept<GraphWrapper<Graph> > >();
+    checkConcept<StaticGraph, GraphWrapper<StaticGraph> >();
 
 //     function_requires<StaticGraphConcept<RevGraphWrapper<Graph> > >();
 



More information about the Lemon-commits mailing list