XyzConcept moved to Xyz::Constraints
authordeba
Sat, 13 Nov 2004 21:37:54 +0000
changeset 989ca95f8b5c931
parent 988 aa19ca32d9b0
child 990 407e4d47fdd3
XyzConcept moved to Xyz::Constraints
use checkConcept in the next way:

checkConcept<ErasableGraph, ListGraph>();
checkConcept<ReadWriteMap<Node, Node>, PredMap>;
src/lemon/concept/graph.h
src/lemon/concept/graph_component.h
src/lemon/concept/maps.h
src/lemon/concept/undir_graph.h
src/lemon/concept_check.h
src/test/graph_test.cc
src/test/graph_wrapper_test.cc
     1.1 --- a/src/lemon/concept/graph.h	Sat Nov 13 17:47:44 2004 +0000
     1.2 +++ b/src/lemon/concept/graph.h	Sat Nov 13 21:37:54 2004 +0000
     1.3 @@ -101,14 +101,6 @@
     1.4  // 	///
     1.5  // 	bool operator!=(Node) const { return true; }
     1.6  
     1.7 -//  	///Comparison operator.
     1.8 -
     1.9 -// 	///This is a strict ordering between the nodes.
    1.10 -// 	///
    1.11 -// 	///This ordering can be different from the order in which NodeIt
    1.12 -// 	///goes through the nodes.
    1.13 -// 	///\todo Possibly we don't need it.
    1.14 -// 	bool operator<(Node) const { return true; }
    1.15  //       };
    1.16      
    1.17  //       /// This iterator goes through each node.
    1.18 @@ -188,14 +180,6 @@
    1.19  // 	/// \sa operator==(Node n)
    1.20  // 	///
    1.21  // 	bool operator!=(Edge) const { return true; }
    1.22 -//  	///Comparison operator.
    1.23 -
    1.24 -// 	///This is a strict ordering between the nodes.
    1.25 -// 	///
    1.26 -// 	///This ordering can be different from the order in which NodeIt
    1.27 -// 	///goes through the nodes.
    1.28 -// 	///\todo Possibly we don't need it.
    1.29 -//  	bool operator<(Edge) const { return true; }
    1.30  //       };
    1.31      
    1.32  //       /// This iterator goes trough the outgoing edges of a node.
    1.33 @@ -339,30 +323,6 @@
    1.34  // 	/// edge of the corresponding node.
    1.35  // 	EdgeIt& operator++() { return *this; }
    1.36  //       };
    1.37 -
    1.38 -//       /// First node of the graph.
    1.39 -
    1.40 -//       /// \retval i the first node.
    1.41 -//       /// \return the first node.
    1.42 -//       ///
    1.43 -//       NodeIt& first(NodeIt& i) const { return i; }
    1.44 -
    1.45 -//       /// The first incoming edge.
    1.46 -
    1.47 -//       /// The first incoming edge.
    1.48 -//       ///
    1.49 -//       InEdgeIt& first(InEdgeIt &i, Node) const { return i; }
    1.50 -//       /// The first outgoing edge.
    1.51 -
    1.52 -//       /// The first outgoing edge.
    1.53 -//       ///
    1.54 -//       OutEdgeIt& first(OutEdgeIt& i, Node) const { return i; }
    1.55 -//       /// The first edge of the Graph.
    1.56 -
    1.57 -//       /// The first edge of the Graph.
    1.58 -//       ///
    1.59 -//       EdgeIt& first(EdgeIt& i) const { return i; }
    1.60 -
    1.61  //       ///Gives back the target node of an edge.
    1.62  
    1.63  //       ///Gives back the target node of an edge.
    1.64 @@ -373,40 +333,15 @@
    1.65  //       ///Gives back the source node of an edge.
    1.66  //       ///
    1.67  //       Node source(Edge) const { return INVALID; }
    1.68 -  
    1.69 -//       ///Gives back the \e id of a node.
    1.70 -
    1.71 -//       ///\warning Not all graph structures provide this feature.
    1.72 -//       ///
    1.73 -//       ///\todo Should each graph provide \c id?
    1.74 -//       int id(const Node&) const { return 0; }
    1.75 -//       ///Gives back the \e id of an edge.
    1.76 -
    1.77 -//       ///\warning Not all graph structures provide this feature.
    1.78 -//       ///
    1.79 -//       ///\todo Should each graph provide \c id?
    1.80 -//       int id(const Edge&) const { return 0; }
    1.81 -
    1.82 -//       ///\e
    1.83 -      
    1.84 -//       ///\todo Should it be in the concept?
    1.85 -//       ///
    1.86 -//       int nodeNum() const { return 0; }
    1.87 -//       ///\e
    1.88 -
    1.89 -//       ///\todo Should it be in the concept?
    1.90 -//       ///
    1.91 -//       int edgeNum() const { return 0; }
    1.92 -
    1.93 -
    1.94 -//       ///Reference map of the nodes to type \c T.
    1.95 +//       /// Read write map of the nodes to type \c T.
    1.96  
    1.97  //       /// \ingroup concept
    1.98 -//       ///Reference map of the nodes to type \c T.
    1.99 +//       /// ReadWrite map of the nodes to type \c T.
   1.100  //       /// \sa Reference
   1.101  //       /// \warning Making maps that can handle bool type (NodeMap<bool>)
   1.102  //       /// needs some extra attention!
   1.103 -//       template<class T> class NodeMap : public ReferenceMap< Node, T >
   1.104 +//       template<class T> 
   1.105 +//       class NodeMap : public ReadWriteMap< Node, T >
   1.106  //       {
   1.107  //       public:
   1.108  
   1.109 @@ -416,21 +351,21 @@
   1.110  // 	NodeMap(const StaticGraph&, T) { }
   1.111  
   1.112  // 	///Copy constructor
   1.113 -// 	template<typename TT> NodeMap(const NodeMap<TT>&) { }
   1.114 +// 	NodeMap(const NodeMap&) { }
   1.115  // 	///Assignment operator
   1.116 -// 	template<typename TT> NodeMap& operator=(const NodeMap<TT>&)
   1.117 -// 	{ return *this; }
   1.118 +// 	NodeMap& operator=(const NodeMap&) { return *this; }
   1.119 +// 	// \todo fix this concept
   1.120  //       };
   1.121  
   1.122 -//       ///Reference map of the edges to type \c T.
   1.123 +//       /// Read write map of the edges to type \c T.
   1.124  
   1.125  //       /// \ingroup concept
   1.126  //       ///Reference map of the edges to type \c T.
   1.127  //       /// \sa Reference
   1.128  //       /// \warning Making maps that can handle bool type (EdgeMap<bool>)
   1.129  //       /// needs some extra attention!
   1.130 -//       template<class T> class EdgeMap
   1.131 -// 	: public ReferenceMap<Edge,T>
   1.132 +//       template<class T> 
   1.133 +//       class EdgeMap : public ReadWriteMap<Edge,T>
   1.134  //       {
   1.135  //       public:
   1.136  
   1.137 @@ -438,213 +373,14 @@
   1.138  // 	EdgeMap(const StaticGraph&) { }
   1.139  // 	///\e
   1.140  // 	EdgeMap(const StaticGraph&, T) { }
   1.141 -    
   1.142  // 	///Copy constructor
   1.143 -// 	template<typename TT> EdgeMap(const EdgeMap<TT>&) { }
   1.144 +// 	EdgeMap(const EdgeMap&) { }
   1.145  // 	///Assignment operator
   1.146 -// 	template<typename TT> EdgeMap &operator=(const EdgeMap<TT>&)
   1.147 -// 	{ return *this; }
   1.148 +// 	EdgeMap& operator=(const EdgeMap&) { return *this; }
   1.149 +// 	// \todo fix this concept    
   1.150  //       };
   1.151  //     };
   1.152  
   1.153 -//     struct DummyType {
   1.154 -//       int value;
   1.155 -//       DummyType() {}
   1.156 -//       DummyType(int p) : value(p) {}
   1.157 -//       DummyType& operator=(int p) { value = p; return *this;}
   1.158 -//     };
   1.159 -    
   1.160 -//     ///\brief Checks whether \c G meets the
   1.161 -//     ///\ref lemon::concept::StaticGraph "StaticGraph" concept
   1.162 -//     template<class Graph> void checkCompileStaticGraph(Graph &G) 
   1.163 -//     {
   1.164 -//       typedef typename Graph::Node Node;
   1.165 -//       typedef typename Graph::NodeIt NodeIt;
   1.166 -//       typedef typename Graph::Edge Edge;
   1.167 -//       typedef typename Graph::EdgeIt EdgeIt;
   1.168 -//       typedef typename Graph::InEdgeIt InEdgeIt;
   1.169 -//       typedef typename Graph::OutEdgeIt OutEdgeIt;
   1.170 -  
   1.171 -//       {
   1.172 -// 	Node i; Node j(i); Node k(INVALID);
   1.173 -// 	i=j;
   1.174 -// 	bool b; b=true;
   1.175 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.176 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.177 -//       }
   1.178 -//       {
   1.179 -// 	NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G);
   1.180 -// 	i=j;
   1.181 -// 	j=G.first(i);
   1.182 -// 	j=++i;
   1.183 -// 	bool b; b=true;
   1.184 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.185 -// 	Node n(i);
   1.186 -// 	n=i;
   1.187 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.188 -// 	//Node ->NodeIt conversion
   1.189 -// 	NodeIt ni(G,n);
   1.190 -//       }
   1.191 -//       {
   1.192 -// 	Edge i; Edge j(i); Edge k(INVALID);
   1.193 -// 	i=j;
   1.194 -// 	bool b; b=true;
   1.195 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.196 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.197 -//       }
   1.198 -//       {
   1.199 -// 	EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G);
   1.200 -// 	i=j;
   1.201 -// 	j=G.first(i);
   1.202 -// 	j=++i;
   1.203 -// 	bool b; b=true;
   1.204 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.205 -// 	Edge e(i);
   1.206 -// 	e=i;
   1.207 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.208 -// 	//Edge ->EdgeIt conversion
   1.209 -// 	EdgeIt ei(G,e);
   1.210 -//       }
   1.211 -//       {
   1.212 -// 	Node n;
   1.213 -// 	InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n);
   1.214 -// 	i=j;
   1.215 -// 	j=G.first(i,n);
   1.216 -// 	j=++i;
   1.217 -// 	bool b; b=true;
   1.218 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.219 -// 	Edge e(i);
   1.220 -// 	e=i;
   1.221 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.222 -// 	//Edge ->InEdgeIt conversion
   1.223 -// 	InEdgeIt ei(G,e);
   1.224 -//       }
   1.225 -//       {
   1.226 -// 	Node n;
   1.227 -// 	OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n);
   1.228 -// 	i=j;
   1.229 -// 	j=G.first(i,n);
   1.230 -// 	j=++i;
   1.231 -// 	bool b; b=true;
   1.232 -// 	b=(i==INVALID); b=(i!=INVALID);
   1.233 -// 	Edge e(i);
   1.234 -// 	e=i;
   1.235 -// 	b=(i==j); b=(i!=j); b=(i<j);
   1.236 -// 	//Edge ->OutEdgeIt conversion
   1.237 -// 	OutEdgeIt ei(G,e);
   1.238 -//       }
   1.239 -//       {
   1.240 -// 	Node n,m;
   1.241 -// 	n=m=INVALID;
   1.242 -// 	Edge e;
   1.243 -// 	e=INVALID;
   1.244 -// 	n=G.source(e);
   1.245 -// 	n=G.target(e);
   1.246 -//       }
   1.247 -//       // id tests
   1.248 -//       { Node n; int i=G.id(n); i=i; }
   1.249 -//       { Edge e; int i=G.id(e); i=i; }
   1.250 -//       //NodeMap tests
   1.251 -//       {
   1.252 -// 	Node k;
   1.253 -// 	typename Graph::template NodeMap<int> m(G);
   1.254 -// 	//Const map
   1.255 -// 	typename Graph::template NodeMap<int> const &cm = m;
   1.256 -// 	//Inicialize with default value
   1.257 -// 	typename Graph::template NodeMap<int> mdef(G,12);
   1.258 -// 	//Copy
   1.259 -// 	typename Graph::template NodeMap<int> mm(cm);
   1.260 -// 	//Copy from another type
   1.261 -// 	typename Graph::template NodeMap<double> dm(cm);
   1.262 -// 	//Copy to more complex type
   1.263 -// 	typename Graph::template NodeMap<DummyType> em(cm);
   1.264 -// 	int v;
   1.265 -// 	v=m[k]; m[k]=v; m.set(k,v);
   1.266 -// 	v=cm[k];
   1.267 -    
   1.268 -// 	m=cm;  
   1.269 -// 	dm=cm; //Copy from another type  
   1.270 -// 	em=cm; //Copy to more complex type
   1.271 -// 	{
   1.272 -// 	  //Check the typedef's
   1.273 -// 	  typename Graph::template NodeMap<int>::Value val;
   1.274 -// 	  val=1;
   1.275 -// 	  typename Graph::template NodeMap<int>::Key key;
   1.276 -// 	  key = typename Graph::NodeIt(G);
   1.277 -// 	}
   1.278 -//       }  
   1.279 -//       { //bool NodeMap
   1.280 -// 	Node k;
   1.281 -// 	typename Graph::template NodeMap<bool> m(G);
   1.282 -// 	typename Graph::template NodeMap<bool> const &cm = m;  //Const map
   1.283 -// 	//Inicialize with default value
   1.284 -// 	typename Graph::template NodeMap<bool> mdef(G,12);
   1.285 -// 	typename Graph::template NodeMap<bool> mm(cm);   //Copy
   1.286 -// 	typename Graph::template NodeMap<int> dm(cm); //Copy from another type
   1.287 -// 	bool v;
   1.288 -// 	v=m[k]; m[k]=v; m.set(k,v);
   1.289 -// 	v=cm[k];
   1.290 -    
   1.291 -// 	m=cm;  
   1.292 -// 	dm=cm; //Copy from another type
   1.293 -// 	m=dm; //Copy to another type
   1.294 -
   1.295 -// 	{
   1.296 -// 	  //Check the typedef's
   1.297 -// 	  typename Graph::template NodeMap<bool>::Value val;
   1.298 -// 	  val=true;
   1.299 -// 	  typename Graph::template NodeMap<bool>::Key key;
   1.300 -// 	  key= typename Graph::NodeIt(G);
   1.301 -// 	}
   1.302 -//       }
   1.303 -//       //EdgeMap tests
   1.304 -//       {
   1.305 -// 	Edge k;
   1.306 -// 	typename Graph::template EdgeMap<int> m(G);
   1.307 -// 	typename Graph::template EdgeMap<int> const &cm = m;  //Const map
   1.308 -// 	//Inicialize with default value
   1.309 -// 	typename Graph::template EdgeMap<int> mdef(G,12);
   1.310 -// 	typename Graph::template EdgeMap<int> mm(cm);   //Copy
   1.311 -// 	typename Graph::template EdgeMap<double> dm(cm);//Copy from another type
   1.312 -// 	int v;
   1.313 -// 	v=m[k]; m[k]=v; m.set(k,v);
   1.314 -// 	v=cm[k];
   1.315 -    
   1.316 -// 	m=cm;  
   1.317 -// 	dm=cm; //Copy from another type
   1.318 -// 	{
   1.319 -// 	  //Check the typedef's
   1.320 -// 	  typename Graph::template EdgeMap<int>::Value val;
   1.321 -// 	  val=1;
   1.322 -// 	  typename Graph::template EdgeMap<int>::Key key;
   1.323 -// 	  key= typename Graph::EdgeIt(G);
   1.324 -// 	}
   1.325 -//       }  
   1.326 -//       { //bool EdgeMap
   1.327 -// 	Edge k;
   1.328 -// 	typename Graph::template EdgeMap<bool> m(G);
   1.329 -// 	typename Graph::template EdgeMap<bool> const &cm = m;  //Const map
   1.330 -// 	//Inicialize with default value
   1.331 -// 	typename Graph::template EdgeMap<bool> mdef(G,12);
   1.332 -// 	typename Graph::template EdgeMap<bool> mm(cm);   //Copy
   1.333 -// 	typename Graph::template EdgeMap<int> dm(cm); //Copy from another type
   1.334 -// 	bool v;
   1.335 -// 	v=m[k]; m[k]=v; m.set(k,v);
   1.336 -// 	v=cm[k];
   1.337 -    
   1.338 -// 	m=cm;  
   1.339 -// 	dm=cm; //Copy from another type
   1.340 -// 	m=dm; //Copy to another type
   1.341 -// 	{
   1.342 -// 	  //Check the typedef's
   1.343 -// 	  typename Graph::template EdgeMap<bool>::Value val;
   1.344 -// 	  val=true;
   1.345 -// 	  typename Graph::template EdgeMap<bool>::Key key;
   1.346 -// 	  key= typename Graph::EdgeIt(G);
   1.347 -// 	}
   1.348 -//       }
   1.349 -//     }
   1.350 -    
   1.351  //     /// An empty non-static graph class.
   1.352      
   1.353  //     /// This class provides everything that \ref StaticGraph
   1.354 @@ -665,10 +401,10 @@
   1.355  //       Node addNode() { return INVALID; }
   1.356  //       ///Add a new edge to the graph.
   1.357  
   1.358 -//       ///Add a new edge to the graph with source node \c t
   1.359 -//       ///and target node \c h.
   1.360 +//       ///Add a new edge to the graph with source node \c s
   1.361 +//       ///and target node \c t.
   1.362  //       ///\return the new edge.
   1.363 -//       Edge addEdge(Node h, Node t) { return INVALID; }
   1.364 +//       Edge addEdge(Node s, Node t) { return INVALID; }
   1.365      
   1.366  //       /// Resets the graph.
   1.367  
   1.368 @@ -678,30 +414,6 @@
   1.369  //       void clear() { }
   1.370  //     };
   1.371  
   1.372 -    
   1.373 -//     ///\brief Checks whether \c G meets the
   1.374 -//     ///\ref lemon::concept::ExtendableGraph "ExtendableGraph" concept
   1.375 -//     template<class Graph> void checkCompileExtendableGraph(Graph &G) 
   1.376 -//     {
   1.377 -//       checkCompileStaticGraph(G);
   1.378 -
   1.379 -//       typedef typename Graph::Node Node;
   1.380 -//       typedef typename Graph::NodeIt NodeIt;
   1.381 -//       typedef typename Graph::Edge Edge;
   1.382 -//       typedef typename Graph::EdgeIt EdgeIt;
   1.383 -//       typedef typename Graph::InEdgeIt InEdgeIt;
   1.384 -//       typedef typename Graph::OutEdgeIt OutEdgeIt;
   1.385 -  
   1.386 -//       Node n,m;
   1.387 -//       n=G.addNode();
   1.388 -//       m=G.addNode();
   1.389 -//       Edge e;
   1.390 -//       e=G.addEdge(n,m); 
   1.391 -  
   1.392 -//       //  G.clear();
   1.393 -//     }
   1.394 -
   1.395 -
   1.396  //     /// An empty erasable graph class.
   1.397    
   1.398  //     /// This class is an extension of \ref ExtendableGraph. It also makes it
   1.399 @@ -725,43 +437,8 @@
   1.400  //       ///
   1.401  //       void erase(Edge e) { }
   1.402  //     };
   1.403 +
   1.404      
   1.405 -//     template<class Graph> void checkCompileGraphEraseEdge(Graph &G) 
   1.406 -//     {
   1.407 -//       typename Graph::Edge e;
   1.408 -//       G.erase(e);
   1.409 -//     }
   1.410 -
   1.411 -//     template<class Graph> void checkCompileGraphEraseNode(Graph &G) 
   1.412 -//     {
   1.413 -//       typename Graph::Node n;
   1.414 -//       G.erase(n);
   1.415 -//     }
   1.416 -
   1.417 -//     ///\brief Checks whether \c G meets the
   1.418 -//     ///\ref lemon::concept::EresableGraph "EresableGraph" concept
   1.419 -//     template<class Graph> void checkCompileErasableGraph(Graph &G) 
   1.420 -//     {
   1.421 -//       checkCompileExtendableGraph(G);
   1.422 -//       checkCompileGraphEraseNode(G);
   1.423 -//       checkCompileGraphEraseEdge(G);
   1.424 -//     }
   1.425 -
   1.426 -//     ///Checks whether a graph has findEdge() member function.
   1.427 -    
   1.428 -//     ///\todo findEdge() might be a global function.
   1.429 -//     ///
   1.430 -//     template<class Graph> void checkCompileGraphFindEdge(Graph &G) 
   1.431 -//     {
   1.432 -//       typedef typename Graph::NodeIt Node;
   1.433 -//       typedef typename Graph::NodeIt NodeIt;
   1.434 -
   1.435 -//       G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G)));
   1.436 -//       G.findEdge(Node(),Node(),G.findEdge(Node(),Node()));  
   1.437 -//     }
   1.438 -
   1.439 -
   1.440 -
   1.441      /************* New GraphBase stuff **************/
   1.442  
   1.443  
   1.444 @@ -815,10 +492,10 @@
   1.445        // a required...)
   1.446  
   1.447        template<typename T>
   1.448 -      class NodeMap : public GraphMap<Node, T, GraphBase> {};
   1.449 +      class NodeMap : public GraphMap<GraphBase, Node, T> {};
   1.450  
   1.451        template<typename T>
   1.452 -      class EdgeMap : public GraphMap<Edge, T, GraphBase> {};
   1.453 +      class EdgeMap : public GraphMap<GraphBase, Node, T> {};
   1.454      };
   1.455  
   1.456  
   1.457 @@ -833,14 +510,14 @@
   1.458      public:
   1.459        typedef BaseGraphComponent::Node Node;
   1.460        typedef BaseGraphComponent::Edge Edge;
   1.461 -    };
   1.462  
   1.463 -    template <typename Graph>
   1.464 -    struct StaticGraphConcept {
   1.465 -      void constraints() {
   1.466 -	function_requires<IterableGraphComponentConcept<Graph> >();
   1.467 -	function_requires<MappableGraphComponentConcept<Graph> >();
   1.468 -      }
   1.469 +      template <typename _Graph>
   1.470 +      struct Constraints {
   1.471 +	void constraints() {
   1.472 +	  checkConcept<IterableGraphComponent, _Graph>();
   1.473 +	  checkConcept<MappableGraphComponent, _Graph>();
   1.474 +	}
   1.475 +      };
   1.476      };
   1.477  
   1.478      class ExtendableGraph 
   1.479 @@ -849,15 +526,15 @@
   1.480      public:
   1.481        typedef BaseGraphComponent::Node Node;
   1.482        typedef BaseGraphComponent::Edge Edge;
   1.483 -    };
   1.484  
   1.485 -    template <typename Graph>
   1.486 -    struct ExtendableGraphConcept {
   1.487 -      void constraints() {
   1.488 -	function_requires<StaticGraphConcept<Graph> >();
   1.489 -	function_requires<ExtendableGraphComponentConcept<Graph> >();
   1.490 -	function_requires<ClearableGraphComponentConcept<Graph> >();
   1.491 -      }
   1.492 +      template <typename _Graph>
   1.493 +      struct Constraints {
   1.494 +	void constraints() {
   1.495 +	  checkConcept<StaticGraph, _Graph >();
   1.496 +	  checkConcept<ExtendableGraphComponent, _Graph >();
   1.497 +	  checkConcept<ClearableGraphComponent, _Graph >();
   1.498 +	}
   1.499 +      };
   1.500      };
   1.501  
   1.502      class ErasableGraph 
   1.503 @@ -866,14 +543,14 @@
   1.504      public:
   1.505        typedef BaseGraphComponent::Node Node;
   1.506        typedef BaseGraphComponent::Edge Edge;
   1.507 -    };
   1.508  
   1.509 -    template <typename Graph>
   1.510 -    struct ErasableGraphConcept {
   1.511 -      void constraints() {
   1.512 -	function_requires<ExtendableGraphConcept<Graph> >();
   1.513 -	function_requires<ErasableGraphComponentConcept<Graph> >();
   1.514 -      }
   1.515 +      template <typename _Graph>
   1.516 +      struct Constraints {
   1.517 +	void constraints() {
   1.518 +	  checkConcept<ExtendableGraph, _Graph >();
   1.519 +	  checkConcept<ErasableGraphComponent, _Graph >();
   1.520 +	}
   1.521 +      };
   1.522      };
   1.523  
   1.524      // @}
     2.1 --- a/src/lemon/concept/graph_component.h	Sat Nov 13 17:47:44 2004 +0000
     2.2 +++ b/src/lemon/concept/graph_component.h	Sat Nov 13 21:37:54 2004 +0000
     2.3 @@ -37,90 +37,64 @@
     2.4      /// base class, this is a template. For Node you should instantiate it
     2.5      /// with character 'n' and for Edge with 'e'.
     2.6  
     2.7 -    template<char Ch>
     2.8 +    template<char _selector>
     2.9      class GraphItem {
    2.10      public:
    2.11 +      /// Default constructor.
    2.12 +      
    2.13 +      /// @warning The default constructor sets the item
    2.14 +      /// to an undefined value.
    2.15        GraphItem() {}
    2.16 +      /// Copy constructor.
    2.17 +      
    2.18 +      /// Copy constructor.
    2.19 +      ///
    2.20 +      GraphItem(GraphItem const&) {}
    2.21 +      /// Invalid constructor \& conversion.
    2.22 +
    2.23 +      /// This constructor initializes the item to be invalid.
    2.24 +      /// \sa Invalid for more details.
    2.25        GraphItem(Invalid) {}
    2.26 +      /// Assign operator for nodes.
    2.27  
    2.28 -      // We explicitely list these:
    2.29 -      GraphItem(GraphItem const&) {}
    2.30 +      /// The nodes are assignable. 
    2.31 +      ///
    2.32        GraphItem& operator=(GraphItem const&) { return *this; }
    2.33 -
    2.34 +      /// Equality operator.
    2.35 +      
    2.36 +      /// Two iterators are equal if and only if they represents the
    2.37 +      /// same node in the graph or both are invalid.
    2.38        bool operator==(GraphItem) const { return false; }
    2.39 +      /// Inequality operator.
    2.40 +	
    2.41 +      /// \sa operator==(const Node& n)
    2.42 +      ///
    2.43        bool operator!=(GraphItem) const { return false; }
    2.44  
    2.45        // Technical requirement. Do we really need this?
    2.46 -      bool operator<(GraphItem) const { return false; }
    2.47 +      //      bool operator<(GraphItem) const { return false; }
    2.48 +
    2.49 +
    2.50 +      template<typename _GraphItem>
    2.51 +      struct Constraints {
    2.52 +	void constraints() {
    2.53 +	  _GraphItem i1;
    2.54 +	  _GraphItem i2 = i1;
    2.55 +	  _GraphItem i3 = INVALID;
    2.56 +	  
    2.57 +	  i1 = i2 = i3;
    2.58 +
    2.59 +	  bool b;
    2.60 +	  //	  b = (ia == ib) && (ia != ib) && (ia < ib);
    2.61 +	  b = (ia == ib) && (ia != ib);
    2.62 +	  b = (ia == INVALID) && (ib != INVALID);
    2.63 +	}
    2.64 +
    2.65 +	const _GraphItem &ia;
    2.66 +	const _GraphItem &ib;
    2.67 +      };
    2.68      };
    2.69  
    2.70 -
    2.71 -    template<typename GI>
    2.72 -    struct GraphItemConcept {
    2.73 -      void constraints() {
    2.74 -	GI i1;
    2.75 -	GI i2 = i1;
    2.76 -	GI i3 = INVALID;
    2.77 -	
    2.78 -	i1 = i2 = i3;
    2.79 -
    2.80 -	bool b;
    2.81 -	b = (ia == ib) && (ia != ib) && (ia < ib);
    2.82 -	b = (ia == INVALID) && (ib != INVALID);
    2.83 -      }
    2.84 -
    2.85 -      const GI &ia;
    2.86 -      const GI &ib;
    2.87 -    };
    2.88 -
    2.89 -
    2.90 -    template<typename Iter, typename Graph, typename BaseItem>
    2.91 -    struct GraphIteratorConcept {
    2.92 -      void constraints() {
    2.93 -	function_requires< GraphItemConcept<Iter> >();
    2.94 -	Iter it1(g);
    2.95 -
    2.96 -	/// \todo Do we need NodeIt(Node) kind of constructor?
    2.97 -	//	Iter it2(bj);
    2.98 -	Iter it2;
    2.99 -
   2.100 -	it2 = ++it1;
   2.101 -	++it2 = it1;
   2.102 -	++(++it1);
   2.103 -	/// \bug This should be: is_base_and_derived<BaseItem, Iter>
   2.104 -	BaseItem bi = it1;
   2.105 -	bi = it2;
   2.106 -      }
   2.107 -
   2.108 -      BaseItem bj;
   2.109 -      Graph g;
   2.110 -    };
   2.111 -
   2.112 -    template<typename Iter, typename Graph>
   2.113 -    struct GraphIncIteratorConcept {
   2.114 -      typedef typename Graph::Node Node;
   2.115 -      typedef typename Graph::Edge Edge;
   2.116 -      void constraints() {
   2.117 -	function_requires< GraphItemConcept<Iter> >();
   2.118 -	Iter it1(graph, node);
   2.119 -	/// \todo Do we need OutEdgeIt(Edge) kind of constructor?
   2.120 -	//	Iter it2(edge);
   2.121 -	Iter it2;
   2.122 -
   2.123 -	it2 = ++it1;
   2.124 -	++it2 = it1;
   2.125 -	++(++it1);
   2.126 -	Edge e = it1;
   2.127 -	e = it2;
   2.128 -      }
   2.129 -
   2.130 -      Edge edge;
   2.131 -      Node node;
   2.132 -      Graph graph;
   2.133 -    };
   2.134 -
   2.135 -
   2.136 -
   2.137      /// An empty base graph class.
   2.138    
   2.139      /// This class provides the minimal set of features needed for a graph
   2.140 @@ -139,108 +113,13 @@
   2.141  
   2.142        /// This class represents the Nodes of the graph. 
   2.143        ///
   2.144 -      class Node {
   2.145 -      public:
   2.146 -
   2.147 -	/// Default constructor.
   2.148 -
   2.149 -	/// @warning The default constructor sets the iterator
   2.150 -	/// to an undefined value.
   2.151 -
   2.152 -	Node() {}
   2.153 -	/// Copy constructor.
   2.154 -
   2.155 -	/// Copy constructor.
   2.156 -	///
   2.157 -	Node(const Node&) {}
   2.158 -
   2.159 -	/// Invalid constructor \& conversion.
   2.160 -
   2.161 -	/// This constructor initializes the iterator to be invalid.
   2.162 -	/// \sa Invalid for more details.
   2.163 -	Node(Invalid) {}
   2.164 -
   2.165 -
   2.166 -	/// Assign operator for nodes.
   2.167 -
   2.168 -	/// The nodes are assignable. 
   2.169 -	///
   2.170 -	Node& operator=(const Node&) { return *this;}
   2.171 -
   2.172 -	/// Equality operator.
   2.173 -
   2.174 -	/// Two iterators are equal if and only if they represents the
   2.175 -	/// same node in the graph or both are invalid.
   2.176 -	bool operator==(const Node&) const { return true;}
   2.177 -
   2.178 -
   2.179 -	/// Inequality operator.
   2.180 -	
   2.181 -	/// \sa operator==(const Node& n)
   2.182 -	///
   2.183 -	bool operator!=(const Node&) const { return true;}
   2.184 -
   2.185 - 	/// Comparison operator.
   2.186 -
   2.187 -	/// This is a strict ordering between the nodes.
   2.188 -	///
   2.189 -	/// This ordering can be different from the iterating order of nodes.
   2.190 -	/// \todo Possibly we don't need it.
   2.191 -	bool operator<(const Node&) const { return true;}
   2.192 -      };
   2.193 +      typedef GraphItem<'n'> Node;
   2.194  
   2.195        /// Edge class of the graph.
   2.196  
   2.197        /// This class represents the Edges of the graph. 
   2.198        ///
   2.199 -      class Edge {
   2.200 -      public:
   2.201 -
   2.202 -	/// Default constructor.
   2.203 -
   2.204 -	/// @warning The default constructor sets the iterator
   2.205 -	/// to an undefined value.
   2.206 -
   2.207 -	Edge() {}
   2.208 -	/// Copy constructor.
   2.209 -
   2.210 -	/// Copy constructor.
   2.211 -	///
   2.212 -	Edge(const Edge&) {}
   2.213 -
   2.214 -	/// Invalid constructor \& conversion.
   2.215 -
   2.216 -	/// This constructor initializes the iterator to be invalid.
   2.217 -	/// \sa Invalid for more details.
   2.218 -	Edge(Invalid) {}
   2.219 -
   2.220 -	/// Assign operator for edges.
   2.221 -
   2.222 -	/// The edges are assignable. 
   2.223 -	///
   2.224 -	Edge& operator=(const Edge&) { return *this;}
   2.225 -
   2.226 -	/// Equality operator.
   2.227 -
   2.228 -	/// Two iterators are equal if and only if they represents the
   2.229 -	/// same edge in the graph or both are invalid.
   2.230 -	bool operator==(const Edge&) const { return true;}
   2.231 -
   2.232 -
   2.233 -	/// Inequality operator.
   2.234 -	
   2.235 -	/// \sa operator==(const Edge& n)
   2.236 -	///
   2.237 -	bool operator!=(const Edge&) const { return true;}
   2.238 -
   2.239 - 	/// Comparison operator.
   2.240 -
   2.241 -	/// This is a strict ordering between the edges.
   2.242 -	///
   2.243 -	/// This ordering can be different from the iterating order of edges.
   2.244 -	/// \todo Possibly we don't need it.
   2.245 -	bool operator<(const Edge&) const { return true;}
   2.246 -      };
   2.247 +      typedef GraphItem<'e'> Edge;
   2.248  
   2.249        ///Gives back the target node of an edge.
   2.250  
   2.251 @@ -253,31 +132,26 @@
   2.252        ///Gives back the source node of an edge.
   2.253        ///
   2.254        Node source(const Edge&) const { return INVALID;}
   2.255 -    };
   2.256  
   2.257  
   2.258 -    /// Concept check structure for BaseGraph.
   2.259 -
   2.260 -    /// Concept check structure for BaseGraph.
   2.261 -    ///
   2.262 -
   2.263 -    template <typename Graph>
   2.264 -    struct BaseGraphComponentConcept {
   2.265 -      typedef typename Graph::Node Node;
   2.266 -      typedef typename Graph::Edge Edge;
   2.267 +      template <typename _Graph>
   2.268 +      struct Constraints {
   2.269 +	typedef typename _Graph::Node Node;
   2.270 +	typedef typename _Graph::Edge Edge;
   2.271        
   2.272 -      void constraints() {
   2.273 -	function_requires< GraphItemConcept<Node> >();
   2.274 -	function_requires< GraphItemConcept<Edge> >();
   2.275 -	{
   2.276 -	  Node n;
   2.277 -	  Edge e;
   2.278 -	  n = graph.source(e);
   2.279 -	  n = graph.target(e);
   2.280 -	}      
   2.281 -      }
   2.282 +	void constraints() {
   2.283 +	  checkConcept<GraphItem<'n'>, Node>();
   2.284 +	  checkConcept<GraphItem<'e'>, Edge>();
   2.285 +	  {
   2.286 +	    Node n;
   2.287 +	    Edge e;
   2.288 +	    n = graph.source(e);
   2.289 +	    n = graph.target(e);
   2.290 +	  }      
   2.291 +	}
   2.292        
   2.293 -      const Graph& graph;
   2.294 +	const _Graph& graph;
   2.295 +      };
   2.296      };
   2.297  
   2.298      /// An empty iterable base graph class.
   2.299 @@ -340,39 +214,35 @@
   2.300        /// Gives back the next of the Edges start from the given Node.
   2.301        ///     
   2.302        void nextOut(Edge&) const {}
   2.303 -    };
   2.304  
   2.305  
   2.306 -    /// Concept check structure for IterableBaseGraph.
   2.307 +      template <typename _Graph>
   2.308 +      struct Constraints {
   2.309 +      
   2.310 +	void constraints() {
   2.311 +	  checkConcept< BaseGraphComponent, _Graph >();
   2.312 +	  typename _Graph::Node node;      
   2.313 +	  typename _Graph::Edge edge;
   2.314 +	  {
   2.315 +	    graph.first(node);
   2.316 +	    graph.next(node);
   2.317 +	  }
   2.318 +	  {
   2.319 +	    graph.first(edge);
   2.320 +	    graph.next(edge);
   2.321 +	  }
   2.322 +	  {
   2.323 +	    graph.firstIn(edge, node);
   2.324 +	    graph.nextIn(edge);
   2.325 +	  }
   2.326 +	  {
   2.327 +	    graph.firstOut(edge, node);
   2.328 +	    graph.nextOut(edge);
   2.329 +	  }
   2.330 +	}
   2.331  
   2.332 -    /// Concept check structure for IterableBaseGraph.
   2.333 -    ///
   2.334 -    template <typename Graph>
   2.335 -    struct BaseIterableGraphComponentConcept {
   2.336 -      
   2.337 -      void constraints() {
   2.338 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.339 -	typename Graph::Node node;      
   2.340 -	typename Graph::Edge edge;
   2.341 -	{
   2.342 -	  graph.first(node);
   2.343 -	  graph.next(node);
   2.344 -	}
   2.345 -	{
   2.346 -	  graph.first(edge);
   2.347 -	  graph.next(edge);
   2.348 -	}
   2.349 -	{
   2.350 -	  graph.firstIn(edge, node);
   2.351 -	  graph.nextIn(edge);
   2.352 -	}
   2.353 -	{
   2.354 -	  graph.firstOut(edge, node);
   2.355 -	  graph.nextOut(edge);
   2.356 -	}
   2.357 -      }
   2.358 -
   2.359 -      const Graph& graph;
   2.360 +	const _Graph& graph;
   2.361 +      };
   2.362      };
   2.363  
   2.364      /// An empty idable base graph class.
   2.365 @@ -381,7 +251,6 @@
   2.366      /// core id functions for the graph structure.
   2.367      /// The most of the base graphs should be conform to this concept.
   2.368      /// The id's are unique and immutable.
   2.369 -
   2.370      class IDableGraphComponent : virtual public BaseGraphComponent {
   2.371      public:
   2.372  
   2.373 @@ -399,27 +268,22 @@
   2.374        /// Gives back an unique integer id for the Edge. 
   2.375        ///
   2.376        int id(const Edge&) const { return -1;}
   2.377 -    };
   2.378  
   2.379 +      template <typename _Graph>
   2.380 +      struct Constraints {
   2.381  
   2.382 -    /// Concept check structure for IdableBaseGraph.
   2.383 +	void constraints() {
   2.384 +	  checkConcept< BaseGraphComponent, _Graph >();
   2.385 +	  typename _Graph::Node node;
   2.386 +	  int nid = graph.id(node);
   2.387 +	  nid = graph.id(node);
   2.388 +	  typename _Graph::Edge edge;
   2.389 +	  int eid = graph.id(edge);
   2.390 +	  eid = graph.id(edge);
   2.391 +	}
   2.392  
   2.393 -    /// Concept check structure for IdableBaseGraph.
   2.394 -    ///
   2.395 -    template <typename Graph>
   2.396 -    struct IDableGraphComponentConcept {
   2.397 -
   2.398 -      void constraints() {
   2.399 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.400 -	typename Graph::Node node;
   2.401 -	int nid = graph.id(node);
   2.402 -	nid = graph.id(node);
   2.403 -	typename Graph::Edge edge;
   2.404 -	int eid = graph.id(edge);
   2.405 -	eid = graph.id(edge);
   2.406 -      }
   2.407 -
   2.408 -      const Graph& graph;
   2.409 +	const _Graph& graph;
   2.410 +      };
   2.411      };
   2.412  
   2.413  
   2.414 @@ -443,24 +307,20 @@
   2.415        /// Gives back an integer greater or equal to the maximum Edge id. 
   2.416        ///
   2.417        int maxId(Edge = INVALID) const { return -1;}
   2.418 -    };
   2.419  
   2.420 -    /// Concept check structure for MaxIdableBaseGraph.
   2.421 +      template <typename _Graph>
   2.422 +      struct Constraints {
   2.423  
   2.424 -    /// Concept check structure for MaxIdableBaseGraph.
   2.425 -    ///
   2.426 -    template <typename Graph>
   2.427 -    struct MaxIDableGraphComponentConcept {
   2.428 -
   2.429 -      void constraints() {
   2.430 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.431 -	int nid = graph.maxId(typename Graph::Node());
   2.432 -	ignore_unused_variable_warning(nid);
   2.433 -	int eid = graph.maxId(typename Graph::Edge());
   2.434 -	ignore_unused_variable_warning(eid);
   2.435 -      }
   2.436 -
   2.437 -      const Graph& graph;
   2.438 +	void constraints() {
   2.439 +	  checkConcept<BaseGraphComponent, _Graph>();
   2.440 +	  int nid = graph.maxId(typename _Graph::Node());
   2.441 +	  ignore_unused_variable_warning(nid);
   2.442 +	  int eid = graph.maxId(typename _Graph::Edge());
   2.443 +	  ignore_unused_variable_warning(eid);
   2.444 +	}
   2.445 +      
   2.446 +	const _Graph& graph;
   2.447 +      };
   2.448      };
   2.449  
   2.450      /// An empty extendable base graph class.
   2.451 @@ -490,23 +350,18 @@
   2.452  	return INVALID;
   2.453        }
   2.454  
   2.455 -    };
   2.456 +      template <typename _Graph>
   2.457 +      struct Constraints {
   2.458 +	void constraints() {
   2.459 +	  checkConcept<BaseGraphComponent, _Graph >();
   2.460 +	  typename _Graph::Node node_a, node_b;
   2.461 +	  node_a = graph.addNode();
   2.462 +	  typename _Graph::Edge edge;
   2.463 +	  edge = graph.addEdge(node_a, node_b);
   2.464 +	}
   2.465  
   2.466 -    /// Concept check structure for ExtendableBaseGraph.
   2.467 -
   2.468 -    /// Concept check structure for ExtendableBaseGraph.
   2.469 -    ///
   2.470 -    template <typename Graph>
   2.471 -    struct BaseExtendableGraphComponentConcept {
   2.472 -      void constraints() {
   2.473 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.474 -	typename Graph::Node node_a, node_b;
   2.475 -	node_a = graph.addNode();
   2.476 -	typename Graph::Edge edge;
   2.477 -	edge = graph.addEdge(node_a, node_b);
   2.478 -      }
   2.479 -
   2.480 -      Graph& graph;
   2.481 +	_Graph& graph;
   2.482 +      };
   2.483      };
   2.484  
   2.485      /// An empty erasable base graph class.
   2.486 @@ -532,23 +387,18 @@
   2.487        ///
   2.488        void erase(const Edge&) {}
   2.489  
   2.490 -    };
   2.491 +      template <typename _Graph>
   2.492 +      struct Constraints {
   2.493 +	void constraints() {
   2.494 +	  checkConcept<BaseGraphComponent, _Graph>();
   2.495 +	  typename _Graph::Node node;
   2.496 +	  graph.erase(node);
   2.497 +	  typename _Graph::Edge edge;
   2.498 +	  graph.erase(edge);
   2.499 +	}
   2.500  
   2.501 -    /// Concept check structure for ErasableBaseGraph.
   2.502 -
   2.503 -    /// Concept check structure for ErasableBaseGraph.
   2.504 -    ///
   2.505 -    template <typename Graph>
   2.506 -    struct BaseErasableGraphComponentConcept {
   2.507 -      void constraints() {
   2.508 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.509 -	typename Graph::Node node;
   2.510 -	graph.erase(node);
   2.511 -	typename Graph::Edge edge;
   2.512 -	graph.erase(edge);
   2.513 -      }
   2.514 -
   2.515 -      Graph& graph;
   2.516 +	_Graph& graph;
   2.517 +      };
   2.518      };
   2.519  
   2.520      /// An empty clearable base graph class.
   2.521 @@ -564,25 +414,172 @@
   2.522        /// Erase all the Nodes and Edges from the graph.
   2.523        ///
   2.524        void clear() {}    
   2.525 +
   2.526 +      template <typename _Graph>
   2.527 +      struct Constraints {
   2.528 +	void constraints() {
   2.529 +	  checkConcept< BaseGraphComponent, _Graph>();
   2.530 +	  graph.clear();
   2.531 +	}
   2.532 +
   2.533 +	_Graph& graph;
   2.534 +      };
   2.535      };
   2.536  
   2.537 -    /// Concept check function for ErasableBaseGraph.
   2.538  
   2.539 -    /// Concept check function for ErasableBaseGraph.
   2.540 +    /// Skeleton class for graph NodeIt and EdgeIt
   2.541 +
   2.542 +    /// Skeleton class for graph NodeIt and EdgeIt.
   2.543      ///
   2.544 -    template <typename Graph>
   2.545 -    struct BaseClearableGraphComponentConcept {
   2.546 -      void constraints() {
   2.547 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.548 -	graph.clear();
   2.549 -      }
   2.550 +    template <typename _Graph, typename _Item>
   2.551 +    class GraphIterator : public _Item {
   2.552 +    public:
   2.553 +      /// \todo Don't we need the Item type as typedef?
   2.554  
   2.555 -      Graph& graph;
   2.556 +      /// Default constructor.
   2.557 +      
   2.558 +      /// @warning The default constructor sets the iterator
   2.559 +      /// to an undefined value.
   2.560 +      GraphIterator() {}
   2.561 +      /// Copy constructor.
   2.562 +      
   2.563 +      /// Copy constructor.
   2.564 +      ///
   2.565 +      GraphIterator(GraphIterator const&) {}
   2.566 +      /// Sets the iterator to the first item.
   2.567 +      
   2.568 +      /// Sets the iterator to the first item of \c the graph.
   2.569 +      ///
   2.570 +      explicit GraphIterator(const _Graph&) {}
   2.571 +      /// Invalid constructor \& conversion.
   2.572 +
   2.573 +      /// This constructor initializes the item to be invalid.
   2.574 +      /// \sa Invalid for more details.
   2.575 +      GraphIterator(Invalid) {}
   2.576 +      /// Assign operator for items.
   2.577 +
   2.578 +      /// The items are assignable. 
   2.579 +      ///
   2.580 +      GraphIterator& operator=(GraphIterator const&) { return *this; }      
   2.581 +      /// Next item.
   2.582 +
   2.583 +      /// Assign the iterator to the next item.
   2.584 +      ///
   2.585 +      GraphIterator& operator++() { return *this; }
   2.586 +      //	Node operator*() const { return INVALID; }
   2.587 +      /// Equality operator
   2.588 +
   2.589 +      /// Two iterators are equal if and only if they point to the
   2.590 +      /// same object or both are invalid.
   2.591 +      bool operator==(const GraphIterator&) const { return true;}
   2.592 +      /// Inequality operator
   2.593 +	
   2.594 +      /// \sa operator==(Node n)
   2.595 +      ///
   2.596 +      bool operator!=(const GraphIterator&) const { return true;}
   2.597 +      
   2.598 +      template<typename _GraphIterator>
   2.599 +      struct Constraints {
   2.600 +	void constraints() {
   2.601 +	  //	  checkConcept< Item, _GraphIterator >();
   2.602 +	  _GraphIterator it1(g);
   2.603 +	
   2.604 +	  /// \todo Do we need NodeIt(Node) kind of constructor?
   2.605 +	  //	_GraphIterator it2(bj);
   2.606 +	  _GraphIterator it2;
   2.607 +
   2.608 +	  it2 = ++it1;
   2.609 +	  ++it2 = it1;
   2.610 +	  ++(++it1);
   2.611 +	  /// \bug This should be: is_base_and_derived<BaseItem, _GraphIterator>
   2.612 +	  _Item bi = it1;
   2.613 +	  bi = it2;
   2.614 +	}
   2.615 +	_Graph& g;
   2.616 +      };
   2.617      };
   2.618  
   2.619 +    /// Skeleton class for graph InEdgeIt and OutEdgeIt
   2.620  
   2.621 -    class IterableGraphComponent :
   2.622 -      virtual public BaseIterableGraphComponent {
   2.623 +    /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
   2.624 +    /// base class, the _selector is a additional template parameter. For 
   2.625 +    /// InEdgeIt you should instantiate it with character 'i' and for 
   2.626 +    /// OutEdgeIt with 'o'.
   2.627 +    /// \todo check the name of the concept GraphIncEdgeIterator
   2.628 +    template <typename _Graph, char _selector>
   2.629 +    class GraphIncEdgeIterator : public _Graph::Edge {
   2.630 +    public:
   2.631 +      /// Default constructor.
   2.632 +      
   2.633 +      /// @warning The default constructor sets the iterator
   2.634 +      /// to an undefined value.
   2.635 +      GraphIncEdgeIterator() {}
   2.636 +      /// Copy constructor.
   2.637 +      
   2.638 +      /// Copy constructor.
   2.639 +      ///
   2.640 +      GraphIncEdgeIterator(GraphIncEdgeIterator const&) {}
   2.641 +      /// Sets the iterator to the first edge incoming into or outgoing from the node.
   2.642 +      
   2.643 +      /// Sets the iterator to the first edge incoming into or outgoing from the node.
   2.644 +      ///
   2.645 +      explicit GraphIncEdgeIterator(const _Graph&, const typename _Graph::Node&) {}
   2.646 +      /// Invalid constructor \& conversion.
   2.647 +
   2.648 +      /// This constructor initializes the item to be invalid.
   2.649 +      /// \sa Invalid for more details.
   2.650 +      GraphIncEdgeIterator(Invalid) {}
   2.651 +      /// Assign operator for nodes.
   2.652 +
   2.653 +      /// The nodes are assignable. 
   2.654 +      ///
   2.655 +      GraphIncEdgeIterator& operator=(GraphIncEdgeIterator const&) { return *this; }      
   2.656 +      /// Next edge.
   2.657 +
   2.658 +      /// Assign the iterator to the next node.
   2.659 +      ///
   2.660 +      GraphIncEdgeIterator& operator++() { return *this; }
   2.661 +      //	Node operator*() const { return INVALID; }
   2.662 +      /// Equality operator
   2.663 +
   2.664 +      /// Two iterators are equal if and only if they point to the
   2.665 +      /// same object or both are invalid.
   2.666 +      bool operator==(const GraphIncEdgeIterator&) const { return true;}
   2.667 +      /// Inequality operator
   2.668 +	
   2.669 +      /// \sa operator==(Node n)
   2.670 +      ///
   2.671 +      bool operator!=(const GraphIncEdgeIterator&) const { return true;}
   2.672 +
   2.673 +      template <typename _GraphIncEdgeIterator>
   2.674 +      struct Constraints {
   2.675 +	typedef typename _Graph::Node Node;
   2.676 +	typedef typename _Graph::Edge Edge;
   2.677 +	void constraints() {
   2.678 +	  checkConcept<GraphItem<'e'>, _GraphIncEdgeIterator>();
   2.679 +	  _GraphIncEdgeIterator it1(graph, node);
   2.680 +	  /// \todo Do we need OutEdgeIt(Edge) kind of constructor?
   2.681 +	  //	_GraphIncEdgeIterator it2(edge);
   2.682 +	  _GraphIncEdgeIterator it2;
   2.683 +
   2.684 +	  it2 = ++it1;
   2.685 +	  ++it2 = it1;
   2.686 +	  ++(++it1);
   2.687 +	  Edge e = it1;
   2.688 +	  e = it2;
   2.689 +	}
   2.690 +
   2.691 +	Edge& edge;
   2.692 +	Node& node;
   2.693 +	_Graph& graph;
   2.694 +      };
   2.695 +    };
   2.696 +    /// An empty iterable base graph class.
   2.697 +  
   2.698 +    /// This class provides beside the core graph features
   2.699 +    /// iterator based iterable interface for the graph structure.
   2.700 +    /// This concept is part of the StaticGraphConcept.
   2.701 +    class IterableGraphComponent : virtual public BaseGraphComponent {
   2.702  
   2.703      public:
   2.704      
   2.705 @@ -591,84 +588,80 @@
   2.706        typedef BaseGraphComponent::Node Node;
   2.707        typedef BaseGraphComponent::Edge Edge;
   2.708  
   2.709 -      class NodeIt : public Node {
   2.710 -      public:
   2.711 -	NodeIt() {}
   2.712 -	NodeIt(Invalid) {}
   2.713 -	// explicit NodeIt(Node) {}
   2.714 -	explicit NodeIt(const Graph&) {}
   2.715 +      /// This iterator goes through each node.
   2.716  
   2.717 -	NodeIt& operator++() { return *this; }
   2.718 -	//	Node operator*() const { return INVALID; }
   2.719 +      /// This iterator goes through each node.
   2.720 +      ///
   2.721 +      typedef GraphIterator<Graph, Node> NodeIt;
   2.722 +      /// This iterator goes through each node.
   2.723  
   2.724 -	bool operator==(const NodeIt&) const { return true;}
   2.725 -	bool operator!=(const NodeIt&) const { return true;}
   2.726 -      };
   2.727 +      /// This iterator goes through each node.
   2.728 +      ///
   2.729 +      typedef GraphIterator<Graph, Edge> EdgeIt;
   2.730 +      /// This iterator goes trough the incoming edges of a node.
   2.731  
   2.732 -      class EdgeIt : public Edge {
   2.733 -      public:
   2.734 -	EdgeIt() {}
   2.735 -	EdgeIt(Invalid) {}
   2.736 -	// explicit EdgeIt(Edge) {}
   2.737 -	explicit EdgeIt(const Graph&) {}
   2.738 +      /// This iterator goes trough the \e inccoming edges of a certain node
   2.739 +      /// of a graph.
   2.740 +      typedef GraphIncEdgeIterator<Graph, 'i'> InEdgeIt;
   2.741 +      /// This iterator goes trough the outgoing edges of a node.
   2.742  
   2.743 -	EdgeIt& operator++() { return *this; }
   2.744 -	//	Edge operator*() const { return INVALID; }
   2.745 +      /// This iterator goes trough the \e outgoing edges of a certain node
   2.746 +      /// of a graph.
   2.747 +      typedef GraphIncEdgeIterator<Graph, 'o'> OutEdgeIt;
   2.748 +    };
   2.749 +    
   2.750 +    template <typename _Graph> 
   2.751 +    struct Constraints {
   2.752 +      void constraints() {
   2.753 +  	checkConcept< BaseGraphComponent, _Graph>();
   2.754  
   2.755 -	bool operator==(const EdgeIt&) const { return true;}
   2.756 -	bool operator!=(const EdgeIt&) const { return true;}
   2.757 -      };
   2.758 +	checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >();
   2.759 +	checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >();
   2.760 +	checkConcept<GraphIncEdgeIterator<_Graph, 'i'>, typename _Graph::InEdgeIt >();
   2.761 +	checkConcept<GraphIncEdgeIterator<_Graph, 'o'>, typename _Graph::OutEdgeIt >();
   2.762 +      }
   2.763 +    };
   2.764  
   2.765 -      class InEdgeIt : public Edge {
   2.766 -      public:
   2.767 -	InEdgeIt() {}
   2.768 -	InEdgeIt(Invalid) {}
   2.769 -	// explicit InEdgeIt(Edge) {}
   2.770 -	explicit InEdgeIt(const Graph&, const Node&) {}
   2.771  
   2.772 -	InEdgeIt& operator++() { return *this; }
   2.773 -	//	Edge operator*() const { return INVALID; }
   2.774 +    template <typename Graph, typename Item, typename _Value>
   2.775 +    class GraphMap : public ReadWriteMap<Item, _Value> {
   2.776 +    protected:      
   2.777 +      GraphMap() {}
   2.778 +    public:
   2.779 +      explicit GraphMap(const Graph&) {}
   2.780 +      GraphMap(const Graph&, const _Value&) {}
   2.781 +      GraphMap(const GraphMap&) {}
   2.782 +      
   2.783 +      GraphMap& operator=(const GraphMap&) { return *this;}
   2.784  
   2.785 -	bool operator==(const InEdgeIt&) const { return true;}
   2.786 -	bool operator!=(const InEdgeIt&) const { return true;}
   2.787 -      };
   2.788 +      template<typename _Map>
   2.789 +      struct Constraints {
   2.790 +	void constraints() {
   2.791 +	  checkConcept<ReadWriteMap<Item, _Value>, _Map >();
   2.792 +	  // Construction with a graph parameter
   2.793 +	  _Map a(g);
   2.794 +	  // Constructor with a graph and a default value parameter
   2.795 +	  _Map a2(g,t);
   2.796 +	  // Copy constructor. Do we need it?
   2.797 +	  _Map b=c;
   2.798 +	  // Copy operator. Do we need it?
   2.799 +	  a=b;
   2.800  
   2.801 -      class OutEdgeIt : public Edge {
   2.802 -      public:
   2.803 -	OutEdgeIt() {}
   2.804 -	OutEdgeIt(Invalid) {}
   2.805 -	// explicit OutEdgeIt(Edge) {}
   2.806 -	explicit OutEdgeIt(const Graph&, const Node&) {}
   2.807 +	  ignore_unused_variable_warning(a2);
   2.808 +	}
   2.809  
   2.810 -	OutEdgeIt& operator++() { return *this; }
   2.811 -	//	Edge operator*() const { return INVALID; }
   2.812 -
   2.813 -	bool operator==(const OutEdgeIt&) const { return true;}
   2.814 -	bool operator!=(const OutEdgeIt&) const { return true;}
   2.815 +	const _Map &c;
   2.816 +	const Graph &g;
   2.817 +	const typename GraphMap::Value &t;
   2.818        };
   2.819  
   2.820      };
   2.821 -    
   2.822 -    template <typename Graph> 
   2.823 -    struct IterableGraphComponentConcept {
   2.824 -      void constraints() {
   2.825 -  	function_requires< BaseIterableGraphComponentConcept<Graph> >();
   2.826  
   2.827 -	typedef typename Graph::Node Node;
   2.828 -	typedef typename Graph::NodeIt NodeIt;
   2.829 -	typedef typename Graph::Edge Edge;
   2.830 -	typedef typename Graph::EdgeIt EdgeIt;
   2.831 -	typedef typename Graph::InEdgeIt InEdgeIt;
   2.832 -	typedef typename Graph::OutEdgeIt OutEdgeIt;
   2.833 +    /// An empty mappable base graph class.
   2.834    
   2.835 -	function_requires< GraphIteratorConcept<NodeIt, Graph, Node> >();
   2.836 -	function_requires< GraphIteratorConcept<EdgeIt, Graph, Edge> >();
   2.837 -	function_requires< GraphIncIteratorConcept<OutEdgeIt, Graph> >();
   2.838 -	function_requires< GraphIncIteratorConcept<InEdgeIt, Graph> >();
   2.839 -      }
   2.840 -    };
   2.841 -
   2.842 -
   2.843 +    /// This class provides beside the core graph features
   2.844 +    /// map interface for the graph structure.
   2.845 +    /// This concept is part of the StaticGraphConcept.
   2.846      class MappableGraphComponent : virtual public BaseGraphComponent {
   2.847      public:
   2.848  
   2.849 @@ -677,65 +670,78 @@
   2.850        typedef BaseGraphComponent::Node Node;
   2.851        typedef BaseGraphComponent::Edge Edge;
   2.852  
   2.853 +      /// ReadWrite map of the nodes.
   2.854 +    
   2.855 +      /// ReadWrite map of the nodes.
   2.856 +      ///
   2.857        template <typename _Value>
   2.858 -      class NodeMap : public ReferenceMap<Node, _Value> {
   2.859 +      class NodeMap : public GraphMap<Graph, Node, _Value> {
   2.860 +      private:
   2.861 +	NodeMap();
   2.862        public:
   2.863 -	NodeMap(const Graph&) {}
   2.864 +	// \todo call the right parent class constructor
   2.865 +	explicit NodeMap(const Graph&) {}
   2.866  	NodeMap(const Graph&, const _Value&) {}
   2.867  	NodeMap(const NodeMap&) {}
   2.868  
   2.869  	NodeMap& operator=(const NodeMap&) { return *this;}
   2.870 -	
   2.871 +
   2.872        };
   2.873  
   2.874 +      /// ReadWrite map of the edges.
   2.875 +    
   2.876 +      /// ReadWrite map of the edges.
   2.877 +      ///
   2.878        template <typename _Value>
   2.879 -      class EdgeMap : public ReferenceMap<Edge, _Value> {
   2.880 +      class EdgeMap : public GraphMap<Graph, Edge, _Value> {
   2.881 +      private:
   2.882 +	EdgeMap();
   2.883        public:
   2.884 -	EdgeMap(const Graph&) {}
   2.885 +	// \todo call the right parent class constructor
   2.886 +	explicit EdgeMap(const Graph&) {}
   2.887  	EdgeMap(const Graph&, const _Value&) {}
   2.888  	EdgeMap(const EdgeMap&) {}
   2.889  
   2.890  	EdgeMap& operator=(const EdgeMap&) { return *this;}
   2.891 -	
   2.892 +
   2.893        };
   2.894  
   2.895 -    };
   2.896 +      template <typename _Graph>
   2.897 +      struct Constraints {
   2.898  
   2.899 -    template <typename Graph>
   2.900 -    struct MappableGraphComponentConcept {
   2.901 +	struct Type {
   2.902 +	  int value;
   2.903 +	  Type() : value(0) {}
   2.904 +	  Type(int _v) : value(_v) {}
   2.905 +	};
   2.906  
   2.907 -      struct Type {
   2.908 -	int value;
   2.909 -	Type() : value(0) {}
   2.910 -	Type(int _v) : value(_v) {}
   2.911 +	void constraints() {
   2.912 +	  checkConcept<BaseGraphComponent, _Graph>();
   2.913 +	  { // int map test
   2.914 +	    typedef typename _Graph::template NodeMap<int> IntNodeMap;
   2.915 +	    checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, IntNodeMap >();
   2.916 +	  } { // bool map test
   2.917 +	    typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
   2.918 +	    checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>, BoolNodeMap >();
   2.919 +	  } { // Type map test
   2.920 +	    typedef typename _Graph::template NodeMap<Type> TypeNodeMap;
   2.921 +	    checkConcept<GraphMap<_Graph, typename _Graph::Node, Type>, TypeNodeMap >();
   2.922 +	  } 
   2.923 +
   2.924 +	  { // int map test
   2.925 +	    typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
   2.926 +	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>, IntEdgeMap >();
   2.927 +	  } { // bool map test
   2.928 +	    typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
   2.929 +	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>, BoolEdgeMap >();
   2.930 +	  } { // Type map test
   2.931 +	    typedef typename _Graph::template EdgeMap<Type> TypeEdgeMap;
   2.932 +	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, Type>, TypeEdgeMap >();
   2.933 +	  } 
   2.934 +	}
   2.935 +
   2.936 +	_Graph& graph;
   2.937        };
   2.938 -
   2.939 -      void constraints() {
   2.940 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.941 -	{ // int map test
   2.942 -	  typedef typename Graph::template NodeMap<int> IntNodeMap;
   2.943 -	  function_requires<GraphMapConcept<IntNodeMap,Graph> >();
   2.944 -	} { // bool map test
   2.945 -	  typedef typename Graph::template NodeMap<bool> BoolNodeMap;
   2.946 -	  function_requires<GraphMapConcept<BoolNodeMap,Graph> >();
   2.947 -	} { // Type map test
   2.948 -	  typedef typename Graph::template NodeMap<Type> TypeNodeMap;
   2.949 -	  function_requires<GraphMapConcept<TypeNodeMap,Graph> >();
   2.950 -	} 
   2.951 -
   2.952 -	{ // int map test
   2.953 -	  typedef typename Graph::template EdgeMap<int> IntEdgeMap;
   2.954 -	  function_requires<GraphMapConcept<IntEdgeMap,Graph> >();
   2.955 -	} { // bool map test
   2.956 -	  typedef typename Graph::template EdgeMap<bool> BoolEdgeMap;
   2.957 -	  function_requires<GraphMapConcept<BoolEdgeMap,Graph> >();
   2.958 -	} { // Type map test
   2.959 -	  typedef typename Graph::template EdgeMap<Type> TypeEdgeMap;
   2.960 -	  function_requires<GraphMapConcept<TypeEdgeMap,Graph> >();
   2.961 -	} 
   2.962 -      }
   2.963 -
   2.964 -      Graph& graph;
   2.965      };
   2.966  
   2.967  
   2.968 @@ -755,20 +761,18 @@
   2.969  	return INVALID;
   2.970        }
   2.971  
   2.972 +      template <typename _Graph>
   2.973 +      struct Constraints {
   2.974 +	void constraints() {
   2.975 +	  checkConcept<BaseGraphComponent, _Graph >();
   2.976 +	  typename _Graph::Node node_a, node_b;
   2.977 +	  node_a = graph.addNode();
   2.978 +	  typename _Graph::Edge edge;
   2.979 +	  edge = graph.addEdge(node_a, node_b);      
   2.980 +	}
   2.981 +	_Graph& graph;
   2.982 +      };
   2.983      };
   2.984 -
   2.985 -    template <typename Graph>
   2.986 -    struct ExtendableGraphComponentConcept {
   2.987 -      void constraints() {
   2.988 -	function_requires< BaseGraphComponentConcept<Graph> >();
   2.989 -	typename Graph::Node node_a, node_b;
   2.990 -	node_a = graph.addNode();
   2.991 -	typename Graph::Edge edge;
   2.992 -	edge = graph.addEdge(node_a, node_b);      
   2.993 -      }
   2.994 -      Graph& graph;
   2.995 -    };
   2.996 -
   2.997      class ErasableGraphComponent : virtual public BaseGraphComponent {
   2.998      public:
   2.999  
  2.1000 @@ -780,19 +784,18 @@
  2.1001        void erase(const Node&) {}    
  2.1002        void erase(const Edge&) {}
  2.1003  
  2.1004 -    };
  2.1005 +      template <typename _Graph>
  2.1006 +      struct Constraints {
  2.1007 +	void constraints() {
  2.1008 +	  checkConcept<BaseGraphComponent, _Graph >();
  2.1009 +	  typename _Graph::Node node;
  2.1010 +	  graph.erase(node);
  2.1011 +	  typename _Graph::Edge edge;
  2.1012 +	  graph.erase(edge);      
  2.1013 +	}
  2.1014  
  2.1015 -    template <typename Graph>
  2.1016 -    struct ErasableGraphComponentConcept {
  2.1017 -      void constraints() {
  2.1018 -	function_requires< BaseGraphComponentConcept<Graph> >();
  2.1019 -	typename Graph::Node node;
  2.1020 -	graph.erase(node);
  2.1021 -	typename Graph::Edge edge;
  2.1022 -	graph.erase(edge);      
  2.1023 -      }
  2.1024 -
  2.1025 -      Graph& graph;
  2.1026 +	_Graph& graph;
  2.1027 +      };
  2.1028      };
  2.1029  
  2.1030      class ClearableGraphComponent : virtual public BaseGraphComponent {
  2.1031 @@ -805,15 +808,15 @@
  2.1032  
  2.1033        void clear() {}    
  2.1034  
  2.1035 -    };
  2.1036  
  2.1037 -    template <typename Graph>
  2.1038 -    struct ClearableGraphComponentConcept {
  2.1039 -      void constraints() {
  2.1040 -	function_requires< BaseGraphComponentConcept<Graph> >();
  2.1041 -	graph.clear();
  2.1042 -      }
  2.1043 -      Graph& graph;
  2.1044 +      template <typename _Graph>
  2.1045 +      struct ClearableGraphComponentConcept {
  2.1046 +	void constraints() {
  2.1047 +	  checkConcept< BaseGraphComponent, _Graph >();
  2.1048 +	  graph.clear();
  2.1049 +	}
  2.1050 +	_Graph& graph;
  2.1051 +      };
  2.1052      };
  2.1053  
  2.1054    }
     3.1 --- a/src/lemon/concept/maps.h	Sat Nov 13 17:47:44 2004 +0000
     3.2 +++ b/src/lemon/concept/maps.h	Sat Nov 13 21:37:54 2004 +0000
     3.3 @@ -40,11 +40,28 @@
     3.4        /// Map's value type. (The type of objects associated with the keys).
     3.5        typedef T Value;
     3.6  
     3.7 +      // \bug Value don't need to be default constructible.
     3.8        /// Returns the value associated with a key.
     3.9 -      Value operator[](const Key &k) const {return Value();}
    3.10 +      Value operator[](const Key &) const {return Value();}
    3.11  
    3.12 -      ///Default constructor
    3.13 -      ReadMap() {}
    3.14 +      template<typename _ReadMap>
    3.15 +      struct Constraints {
    3.16 +
    3.17 +	void constraints() {
    3.18 +	  Value val = m[key];
    3.19 +	  val = m[key];
    3.20 +	  typename _ReadMap::Value own_val = m[own_key]; 
    3.21 +	  own_val = m[own_key]; 
    3.22 +
    3.23 +	  ignore_unused_variable_warning(val);
    3.24 +	  ignore_unused_variable_warning(own_val);
    3.25 +	  ignore_unused_variable_warning(key);
    3.26 +	}
    3.27 +	Key& key;
    3.28 +	typename _ReadMap::Key& own_key;
    3.29 +	_ReadMap& m;
    3.30 +      };
    3.31 +      
    3.32      };
    3.33  
    3.34  
    3.35 @@ -63,6 +80,26 @@
    3.36  
    3.37        ///Default constructor
    3.38        WriteMap() {}
    3.39 +
    3.40 +      template <typename _WriteMap>
    3.41 +      struct Constraints {
    3.42 +	void constraints() {
    3.43 +	  // No constraints for constructor.
    3.44 +	  m.set(key, val);
    3.45 +	  m.set(own_key, own_val);
    3.46 +	  ignore_unused_variable(key);
    3.47 +	  ignore_unused_variable(val);
    3.48 +	  ignore_unused_variable(own_key);
    3.49 +	  ignore_unused_variable(own_val);
    3.50 +	}
    3.51 +
    3.52 +	Value& val;
    3.53 +	typename _WriteMap::Value own_val;
    3.54 +	Key& key;
    3.55 +	typename _WriteMap::Key& own_key;
    3.56 +	WriteMap& m;
    3.57 +
    3.58 +      };
    3.59      };
    3.60  
    3.61      ///Read/Writable map concept
    3.62 @@ -81,13 +118,18 @@
    3.63        /// Sets the value associated with a key.
    3.64        void set(const Key &k,const Value &t) {}
    3.65  
    3.66 -      ///Default constructor
    3.67 -      ReadWriteMap() {}
    3.68 +      template<typename _ReadWriteMap>
    3.69 +      struct Constraints {
    3.70 +	void constraints() {
    3.71 +	  checkConcept<ReadMap<K, T>, _ReadWriteMap >();
    3.72 +	  checkConcept<ReadMap<K, T>, _ReadWriteMap >();
    3.73 +	}
    3.74 +      };
    3.75      };
    3.76    
    3.77    
    3.78      ///Dereferable map concept
    3.79 -    template<typename K, typename T>
    3.80 +    template<typename K, typename T, typename R, typename CR>
    3.81      class ReferenceMap : public ReadWriteMap<K,T>
    3.82      {
    3.83      public:
    3.84 @@ -95,13 +137,14 @@
    3.85        typedef K Key;    
    3.86        /// Map's value type. (The type of objects associated with the keys).
    3.87        typedef T Value;
    3.88 +      /// Map's reference type.
    3.89 +      typedef R Reference;
    3.90 +      /// Map's const reference type.
    3.91 +      typedef CR ConstReference;
    3.92  
    3.93      protected:
    3.94        Value tmp;
    3.95      public:
    3.96 -      typedef Value& Reference;
    3.97 -      /// Map's const reference type.
    3.98 -      typedef const Value& ConstReference;
    3.99  
   3.100        ///Returns a reference to the value associated to a key.
   3.101        Reference operator[](const Key &i) { return tmp; }
   3.102 @@ -111,134 +154,32 @@
   3.103        /// Sets the value associated with a key.
   3.104        void set(const Key &k,const Value &t) { operator[](k)=t; }
   3.105  
   3.106 -      ///Default constructor
   3.107 -      ReferenceMap() {}
   3.108 +      // \todo rethink this concept
   3.109 +      template<typename _ReferenceMap>
   3.110 +      struct ReferenceMapConcept {
   3.111 +
   3.112 +	void constraints() {
   3.113 +	  checkConcept<ReadWriteMap, _ReferenceMap >();
   3.114 +	  m[key] = val;
   3.115 +	  val  = m[key];
   3.116 +	  m[key] = ref;
   3.117 +	  ref = m[key];
   3.118 +	  m[own_key] = own_val;
   3.119 +	  own_val  = m[own_key];
   3.120 +	  m[own_key] = own_ref;
   3.121 +	  own_ref = m[own_key];	  	  
   3.122 +	}
   3.123 +
   3.124 +	typename _ReferenceMap::Key& own_key;
   3.125 +	typename _ReferenceMap::Value& own_val;
   3.126 +	typename _ReferenceMap::Reference& own_ref;
   3.127 +	Key& key;
   3.128 +	Value& val;
   3.129 +	Reference& ref;
   3.130 +	ReferenceMap& m;
   3.131 +      };
   3.132      };
   3.133  
   3.134 -
   3.135 -    template<typename Item, typename T, typename Graph>
   3.136 -    class GraphMap : public ReadWriteMap<Item, T> {
   3.137 -      // I really, really don't like the idea that every graph should have
   3.138 -      // reference maps! --klao
   3.139 -
   3.140 -    private:
   3.141 -      // We state explicitly that graph maps have no default constructor?
   3.142 -      GraphMap();
   3.143 -
   3.144 -    public:
   3.145 -      explicit GraphMap(Graph const&) {}
   3.146 -      // value for initializing
   3.147 -      GraphMap(Graph const&, T) {}
   3.148 -
   3.149 -      // this probably should be required:
   3.150 -      GraphMap(GraphMap const&) {}
   3.151 -      GraphMap& operator=(GraphMap const&) { return *this; }
   3.152 -
   3.153 -      // but this is a absolute no-op! We should provide a more generic
   3.154 -      // graph-map-copy operation.
   3.155 -      //
   3.156 -      // template<typename TT>
   3.157 -      // GraphMap(GraphMap<TT> const&);
   3.158 -      //
   3.159 -      // template<typename TT>
   3.160 -      // GraphMap& operator=(const GraphMap<TT>&);
   3.161 -    };
   3.162 -
   3.163 -
   3.164 -    /****************  Concept-checking classes  ****************/
   3.165 -
   3.166 -    template<typename ReadMap>
   3.167 -    struct ReadMapConcept {
   3.168 -      typedef typename ReadMap::Key Key;
   3.169 -      typedef typename ReadMap::Value Value;
   3.170 -
   3.171 -      void constraints() {
   3.172 -	// No constraints for constructor.
   3.173 -
   3.174 -	// What are the requirement for the Value?
   3.175 -	// CopyConstructible? Assignable? None of these?
   3.176 -	Value v = m[k];
   3.177 -	v = m[k];
   3.178 -
   3.179 -	// FIXME:
   3.180 -	ignore_unused_variable_warning(v);
   3.181 -      }
   3.182 -
   3.183 -      ReadMap m;
   3.184 -      Key k;
   3.185 -    };
   3.186 -
   3.187 -    template<typename WriteMap>
   3.188 -    struct WriteMapConcept {
   3.189 -      typedef typename WriteMap::Key Key;
   3.190 -      typedef typename WriteMap::Value Value;
   3.191 -
   3.192 -      void constraints() {
   3.193 -	// No constraints for constructor.
   3.194 -
   3.195 -	m.set(k, v);
   3.196 -      }
   3.197 -
   3.198 -      WriteMap m;
   3.199 -      Key k;
   3.200 -      Value v;
   3.201 -    };
   3.202 -
   3.203 -    template<typename ReadWriteMap>
   3.204 -    struct ReadWriteMapConcept {
   3.205 -      void constraints() {
   3.206 -	function_requires< ReadMapConcept<ReadWriteMap> >();
   3.207 -	function_requires< WriteMapConcept<ReadWriteMap> >();
   3.208 -      }
   3.209 -    };
   3.210 -
   3.211 -    template<typename ReferenceMap>
   3.212 -    struct ReferenceMapConcept {
   3.213 -      typedef typename ReferenceMap::Key Key;
   3.214 -      typedef typename ReferenceMap::Value Value;
   3.215 -      typedef typename ReferenceMap::Reference Reference;
   3.216 -
   3.217 -      // What for is this?
   3.218 -      typedef typename ReferenceMap::ConstReference ConstReference;
   3.219 -
   3.220 -      void constraints() {
   3.221 -	function_requires< ReadWriteMapConcept<ReferenceMap> >();
   3.222 -
   3.223 -	m[k] = v;
   3.224 -	// Or should we require real reference?
   3.225 -	// Like this:
   3.226 -	// Value &vv = m[k];
   3.227 -	// ignore_unused_variable_warning(vv);
   3.228 -      }
   3.229 -
   3.230 -      ReferenceMap m;
   3.231 -      Key k;
   3.232 -      Value v;
   3.233 -    };
   3.234 -
   3.235 -    /// \todo GraphMapConceptCheck
   3.236 -
   3.237 -    template<typename GraphMap, typename Graph>
   3.238 -    struct GraphMapConcept {
   3.239 -      void constraints() {
   3.240 -	function_requires< ReadWriteMapConcept<GraphMap> >();
   3.241 -	// Construction with a graph parameter
   3.242 -	GraphMap a(g);
   3.243 -	// Ctor with a graph and a default value parameter
   3.244 -	GraphMap a2(g,t);
   3.245 -	// Copy ctor. Do we need it?
   3.246 -	GraphMap b=c;
   3.247 -	// Copy operator. Do we need it?
   3.248 -	a=b;
   3.249 -
   3.250 -	ignore_unused_variable_warning(a2);
   3.251 -      }
   3.252 -      const GraphMap &c;
   3.253 -      const Graph &g;
   3.254 -      const typename GraphMap::Value &t;
   3.255 -    };
   3.256 -    
   3.257 -
   3.258      // @}
   3.259  
   3.260    } //namespace concept
     4.1 --- a/src/lemon/concept/undir_graph.h	Sat Nov 13 17:47:44 2004 +0000
     4.2 +++ b/src/lemon/concept/undir_graph.h	Sat Nov 13 21:37:54 2004 +0000
     4.3 @@ -38,9 +38,10 @@
     4.4        typedef typename Graph::UndirEdge UndirEdge;
     4.5        typedef typename Graph::Edge Edge;
     4.6        typedef typename Graph::Node Node;
     4.7 +
     4.8        void constraints() {
     4.9 -	function_requires< BaseIterableGraphComponentConcept<Graph> >();
    4.10 -	function_requires< GraphItemConcept<UndirEdge> >();
    4.11 +	checkConcept<BaseIterableGraphComponent, Graph>();
    4.12 +	checkConcept<GraphItem<'u'>, UndirEdge >();
    4.13  
    4.14  	/// \bug this should be base_and_derived:
    4.15  	UndirEdge ue = e;
    4.16 @@ -60,14 +61,14 @@
    4.17      template <typename Graph>
    4.18      struct IterableUndirGraphConcept {
    4.19        void constraints() {
    4.20 -	function_requires< BaseIterableUndirGraphConcept<Graph> > ();
    4.21 -	function_requires< IterableGraphComponentConcept<Graph> > ();
    4.22 +	/// \todo we don't need the iterable component should base iterable	
    4.23 +	//	checkConcept< BaseIterableUndirGraph, Graph > ();
    4.24 +	checkConcept< IterableGraphComponent, Graph > ();
    4.25  
    4.26  	typedef typename Graph::UndirEdge UndirEdge;
    4.27  	typedef typename Graph::UndirEdgeIt UndirEdgeIt;
    4.28  
    4.29 -	function_requires<
    4.30 -	  GraphIteratorConcept<UndirEdgeIt, Graph, UndirEdge> >();
    4.31 +	checkConcept< GraphIterator<Graph, UndirEdge>, UndirEdgeIt >();
    4.32        }
    4.33      };
    4.34  
     5.1 --- a/src/lemon/concept_check.h	Sat Nov 13 17:47:44 2004 +0000
     5.2 +++ b/src/lemon/concept_check.h	Sat Nov 13 21:37:54 2004 +0000
     5.3 @@ -39,6 +39,11 @@
     5.4  #endif
     5.5    }
     5.6  
     5.7 +  template <typename Concept, typename Type>
     5.8 +  inline void checkConcept() {
     5.9 +    function_requires<typename Concept::template Constraints<Type> >();
    5.10 +  }
    5.11 +
    5.12  #define BOOST_CLASS_REQUIRE(type_var, ns, concept) \
    5.13    typedef void (ns::concept <type_var>::* func##type_var##concept)(); \
    5.14    template <func##type_var##concept Tp1_> \
     6.1 --- a/src/test/graph_test.cc	Sat Nov 13 17:47:44 2004 +0000
     6.2 +++ b/src/test/graph_test.cc	Sat Nov 13 21:37:54 2004 +0000
     6.3 @@ -20,46 +20,46 @@
     6.4  int main() {
     6.5    ///\file
     6.6    { // checking graph components
     6.7 -    function_requires<BaseGraphComponentConcept<BaseGraphComponent> >();
     6.8 +    checkConcept<BaseGraphComponent, BaseGraphComponent >();
     6.9  
    6.10 -    function_requires<BaseIterableGraphComponentConcept<BaseIterableGraphComponent> >();
    6.11 +    checkConcept<BaseIterableGraphComponent, BaseIterableGraphComponent >();
    6.12  
    6.13 -    function_requires<IDableGraphComponentConcept<IDableGraphComponent> >();
    6.14 -    function_requires<MaxIDableGraphComponentConcept<MaxIDableGraphComponent> >();
    6.15 +    checkConcept<IDableGraphComponent, IDableGraphComponent >();
    6.16 +    checkConcept<MaxIDableGraphComponent, MaxIDableGraphComponent >();
    6.17  
    6.18 -    function_requires<BaseExtendableGraphComponentConcept<BaseExtendableGraphComponent> >();
    6.19 -    function_requires<BaseErasableGraphComponentConcept<BaseErasableGraphComponent> >();
    6.20 -    function_requires<BaseClearableGraphComponentConcept<BaseClearableGraphComponent> >();
    6.21 +    checkConcept<BaseExtendableGraphComponent, BaseExtendableGraphComponent >();
    6.22 +    checkConcept<BaseErasableGraphComponent, BaseErasableGraphComponent >();
    6.23 +    checkConcept<BaseClearableGraphComponent, BaseClearableGraphComponent >();
    6.24  
    6.25 -    function_requires<IterableGraphComponentConcept<IterableGraphComponent> >();
    6.26 +    checkConcept<IterableGraphComponent, IterableGraphComponent >();
    6.27  
    6.28 -    function_requires<MappableGraphComponentConcept<MappableGraphComponent> >();
    6.29 +    checkConcept<MappableGraphComponent, MappableGraphComponent >();
    6.30  
    6.31 -    function_requires<ExtendableGraphComponentConcept<ExtendableGraphComponent> >();
    6.32 -    function_requires<ErasableGraphComponentConcept<ErasableGraphComponent> >();
    6.33 -    function_requires<ClearableGraphComponentConcept<ClearableGraphComponent> >();
    6.34 +    checkConcept<ExtendableGraphComponent, ExtendableGraphComponent >();
    6.35 +    checkConcept<ErasableGraphComponent, ErasableGraphComponent >();
    6.36 +    checkConcept<ClearableGraphComponent, ClearableGraphComponent >();
    6.37    }
    6.38    { // checking skeleton graphs
    6.39 -    function_requires<StaticGraphConcept<StaticGraph> >();
    6.40 -    function_requires<ExtendableGraphConcept<ExtendableGraph> >();
    6.41 -    function_requires<ErasableGraphConcept<ErasableGraph> >();
    6.42 +    checkConcept<StaticGraph, StaticGraph >();
    6.43 +    checkConcept<ExtendableGraph, ExtendableGraph >();
    6.44 +    checkConcept<ErasableGraph, ErasableGraph >();
    6.45    }
    6.46    { // checking list graph
    6.47 -    function_requires<ErasableGraphConcept<ListGraph> >();
    6.48 +    checkConcept<ErasableGraph, ListGraph >();
    6.49  
    6.50      checkGraph<ListGraph>();
    6.51      checkGraphNodeMap<ListGraph>();
    6.52      checkGraphEdgeMap<ListGraph>();
    6.53    }
    6.54    { // checking smart graph
    6.55 -    function_requires<ExtendableGraphConcept<SmartGraph> >();
    6.56 +    checkConcept<ExtendableGraph, SmartGraph >();
    6.57  
    6.58      checkGraph<SmartGraph>();
    6.59      checkGraphNodeMap<SmartGraph>();
    6.60      checkGraphEdgeMap<SmartGraph>();
    6.61    }
    6.62    { // checking full graph
    6.63 -    function_requires<StaticGraphConcept<FullGraph> >();
    6.64 +    checkConcept<StaticGraph, FullGraph >();
    6.65    }
    6.66  
    6.67    std::cout << __FILE__ ": All tests passed.\n";
     7.1 --- a/src/test/graph_wrapper_test.cc	Sat Nov 13 17:47:44 2004 +0000
     7.2 +++ b/src/test/graph_wrapper_test.cc	Sat Nov 13 21:37:54 2004 +0000
     7.3 @@ -38,13 +38,11 @@
     7.4  using namespace lemon::concept;
     7.5  
     7.6  
     7.7 -typedef SmartGraph Graph;
     7.8 -
     7.9  
    7.10  int main() 
    7.11  {
    7.12    {
    7.13 -    function_requires<StaticGraphConcept<GraphWrapper<Graph> > >();
    7.14 +    checkConcept<StaticGraph, GraphWrapper<StaticGraph> >();
    7.15  
    7.16  //     function_requires<StaticGraphConcept<RevGraphWrapper<Graph> > >();
    7.17