lemon/concept/graph_components.h
changeset 2259 da142c310d02
parent 2181 b2c38f4f72ff
equal deleted inserted replaced
2:88bc79d2eb76 3:72d0745a3e19
   216         /// \brief Converter from edge to undirected edge.
   216         /// \brief Converter from edge to undirected edge.
   217         ///
   217         ///
   218         /// Besides the core graph item functionality each edge should
   218         /// Besides the core graph item functionality each edge should
   219         /// be convertible to the represented undirected edge. 
   219         /// be convertible to the represented undirected edge. 
   220         UEdge(const Edge&) {}
   220         UEdge(const Edge&) {}
       
   221         /// \brief Assign edge to undirected edge.
       
   222         ///
       
   223         /// Besides the core graph item functionality each edge should
       
   224         /// be convertible to the represented undirected edge. 
       
   225         UEdge& operator=(const Edge&) { return *this; }
   221       };
   226       };
   222 
   227 
   223       /// \brief Returns the direction of the edge.
   228       /// \brief Returns the direction of the edge.
   224       ///
   229       ///
   225       /// Returns the direction of the edge. Each edge represents an
   230       /// Returns the direction of the edge. Each edge represents an
   288 	const _Graph& graph;
   293 	const _Graph& graph;
   289       };
   294       };
   290 
   295 
   291     };
   296     };
   292 
   297 
   293     /// \brief An empty iterable base graph class.
   298     /// \brief An empty base bipartite undirected graph class.
   294     ///  
   299     ///  
   295     /// This class provides beside the core graph features
   300     /// This class provides the minimal set of features needed for an
   296     /// core iterable interface for the graph structure.
   301     /// bipartite undirected graph structure. All bipartite undirected
   297     /// Most of the base graphs should be conform to this concept.
   302     /// graph concepts have to be conform to this base graph. It just
   298     template <typename _Base = BaseGraphComponent>
   303     /// provides types for nodes, A-nodes, B-nodes, edges and
   299     class BaseIterableGraphComponent : public _Base {
   304     /// undirected edges and functions to get the source and the
   300     public:
   305     /// target of the edges and undirected edges, conversion from
   301 
   306     /// edges to undirected edges and function to get both direction
   302       typedef _Base Base; 
   307     /// of the undirected edges.
   303       typedef typename Base::Node Node;
   308     class BaseBpUGraphComponent : public BaseUGraphComponent {
   304       typedef typename Base::Edge Edge;
   309     public:
   305 
   310       typedef BaseUGraphComponent::Node Node;
   306       /// \brief Gives back the first node in the iterating order.
   311       typedef BaseUGraphComponent::Edge Edge;
   307       ///      
   312       typedef BaseUGraphComponent::UEdge UEdge;
   308       /// Gives back the first node in the iterating order.
   313 
   309       ///     
   314       /// \brief Helper class for A-nodes.
   310       void first(Node&) const {}
   315       ///
   311 
   316       /// This class is just a helper class for A-nodes, it is not
   312       /// \brief Gives back the next node in the iterating order.
   317       /// suggested to use it directly. It can be converted easily to
   313       ///
   318       /// node and vice versa. The usage of this class is limited
   314       /// Gives back the next node in the iterating order.
   319       /// to use just as template parameters for special map types. 
   315       ///     
   320       class ANode : public Node {
   316       void next(Node&) const {}
   321       public:
   317 
   322         typedef Node Parent;
   318       /// \brief Gives back the first edge in the iterating order.
   323 
   319       ///
   324         /// \brief Default constructor.
   320       /// Gives back the first edge in the iterating order.
   325         ///      
   321       ///     
   326         /// \warning The default constructor is not required to set
   322       void first(Edge&) const {}
   327         /// the item to some well-defined value. So you should consider it
   323 
   328         /// as uninitialized.
   324       /// \brief Gives back the next edge in the iterating order.
   329         ANode() {}
   325       ///
   330         /// \brief Copy constructor.
   326       /// Gives back the next edge in the iterating order.
   331         ///
   327       ///     
   332         /// Copy constructor.
   328       void next(Edge&) const {}
   333         ///
   329 
   334         ANode(const ANode &) : Parent() {}
   330 
   335         /// \brief Invalid constructor \& conversion.
   331       /// \brief Gives back the first of the edges point to the given
   336         ///
   332       /// node.
   337         /// This constructor initializes the item to be invalid.
   333       ///
   338         /// \sa Invalid for more details.
   334       /// Gives back the first of the edges point to the given node.
   339         ANode(Invalid) {}
   335       ///     
   340         /// \brief Converter from node to A-node.
   336       void firstIn(Edge&, const Node&) const {}
   341         ///
   337 
   342         /// Besides the core graph item functionality each node should
   338       /// \brief Gives back the next of the edges points to the given
   343         /// be convertible to the represented A-node if it is it possible. 
   339       /// node.
   344         ANode(const Node&) {}
   340       ///
   345         /// \brief Assign node to A-node.
   341       /// Gives back the next of the edges points to the given node.
   346         ///
   342       ///
   347         /// Besides the core graph item functionality each node should
   343       void nextIn(Edge&) const {}
   348         /// be convertible to the represented A-node if it is it possible. 
   344 
   349         ANode& operator=(const Node&) { return *this; }
   345       /// \brief Gives back the first of the edges start from the
   350       };
   346       /// given node.
   351 
   347       ///      
   352       /// \brief Helper class for B-nodes.
   348       /// Gives back the first of the edges start from the given node.
   353       ///
   349       ///     
   354       /// This class is just a helper class for B-nodes, it is not
   350       void firstOut(Edge&, const Node&) const {}
   355       /// suggested to use it directly. It can be converted easily to
   351 
   356       /// node and vice versa. The usage of this class is limited
   352       /// \brief Gives back the next of the edges start from the given
   357       /// to use just as template parameters for special map types. 
   353       /// node.
   358       class BNode : public Node {
   354       ///
   359       public:
   355       /// Gives back the next of the edges start from the given node.
   360         typedef Node Parent;
   356       ///     
   361 
   357       void nextOut(Edge&) const {}
   362         /// \brief Default constructor.
   358 
   363         ///      
   359 
   364         /// \warning The default constructor is not required to set
       
   365         /// the item to some well-defined value. So you should consider it
       
   366         /// as uninitialized.
       
   367         BNode() {}
       
   368         /// \brief Copy constructor.
       
   369         ///
       
   370         /// Copy constructor.
       
   371         ///
       
   372         BNode(const BNode &) : Parent() {}
       
   373         /// \brief Invalid constructor \& conversion.
       
   374         ///
       
   375         /// This constructor initializes the item to be invalid.
       
   376         /// \sa Invalid for more details.
       
   377         BNode(Invalid) {}
       
   378         /// \brief Converter from node to B-node.
       
   379         ///
       
   380         /// Besides the core graph item functionality each node should
       
   381         /// be convertible to the represented B-node if it is it possible. 
       
   382         BNode(const Node&) {}
       
   383         /// \brief Assign node to B-node.
       
   384         ///
       
   385         /// Besides the core graph item functionality each node should
       
   386         /// be convertible to the represented B-node if it is it possible. 
       
   387         BNode& operator=(const Node&) { return *this; }
       
   388       };
       
   389       
       
   390       /// \brief Gives back %true when the node is A-node.
       
   391       ///
       
   392       /// Gives back %true when the node is A-node.
       
   393       bool aNode(const Node&) const { return false; }
       
   394 
       
   395       /// \brief Gives back %true when the node is B-node.
       
   396       ///
       
   397       /// Gives back %true when the node is B-node.
       
   398       bool bNode(const Node&) const { return false; }
       
   399 
       
   400       /// \brief Gives back the A-node of the undirected edge.
       
   401       ///
       
   402       /// Gives back the A-node of the undirected edge.
       
   403       Node aNode(const UEdge&) const { return INVALID; }
       
   404 
       
   405       /// \brief Gives back the B-node of the undirected edge.
       
   406       ///
       
   407       /// Gives back the B-node of the undirected edge.
       
   408       Node bNode(const UEdge&) const { return INVALID; }
       
   409       
   360       template <typename _Graph>
   410       template <typename _Graph>
   361       struct Constraints {
   411       struct Constraints {
       
   412 	typedef typename _Graph::Node Node;
       
   413 	typedef typename _Graph::ANode ANode;
       
   414 	typedef typename _Graph::BNode BNode;
       
   415 	typedef typename _Graph::Edge Edge;
       
   416 	typedef typename _Graph::UEdge UEdge;
   362       
   417       
   363 	void constraints() {
   418 	void constraints() {
   364 	  checkConcept< BaseGraphComponent, _Graph >();
   419           checkConcept<BaseUGraphComponent, _Graph>();
   365 	  typename _Graph::Node node(INVALID);      
   420 	  checkConcept<GraphItem<'a'>, ANode>();
   366 	  typename _Graph::Edge edge(INVALID);
   421 	  checkConcept<GraphItem<'b'>, BNode>();
   367 	  {
   422 	  {
   368 	    graph.first(node);
   423 	    Node n;
   369 	    graph.next(node);
   424 	    UEdge ue(INVALID);
   370 	  }
   425             bool b;
   371 	  {
   426 	    n = graph.aNode(ue);
   372 	    graph.first(edge);
   427 	    n = graph.bNode(ue);
   373 	    graph.next(edge);
   428             b = graph.aNode(n);
   374 	  }
   429             b = graph.bNode(n);
   375 	  {
   430             ANode an;
   376 	    graph.firstIn(edge, node);
   431             an = n; n = an;
   377 	    graph.nextIn(edge);
   432             BNode bn;
   378 	  }
   433             bn = n; n = bn;            
   379 	  {
   434             ignore_unused_variable_warning(b);
   380 	    graph.firstOut(edge, node);
   435 	  }      
   381 	    graph.nextOut(edge);
   436 	}
   382 	  }
   437       
   383 	}
       
   384 
       
   385 	const _Graph& graph;
   438 	const _Graph& graph;
   386       };
   439       };
   387     };
   440 
   388 
       
   389     /// \brief An empty iterable base undirected graph class.
       
   390     ///  
       
   391     /// This class provides beside the core undirceted graph features
       
   392     /// core iterable interface for the undirected graph structure.
       
   393     /// Most of the base undirected graphs should be conform to this
       
   394     /// concept.
       
   395     template <typename _Base = BaseUGraphComponent>
       
   396     class BaseIterableUGraphComponent 
       
   397       : public BaseIterableGraphComponent<_Base> {
       
   398     public:
       
   399 
       
   400       typedef _Base Base; 
       
   401       typedef typename Base::UEdge UEdge;
       
   402       typedef typename Base::Node Node;
       
   403 
       
   404       using BaseIterableGraphComponent<_Base>::first;
       
   405       using BaseIterableGraphComponent<_Base>::next;
       
   406 
       
   407       /// \brief Gives back the first undirected edge in the iterating
       
   408       /// order.
       
   409       ///
       
   410       /// Gives back the first undirected edge in the iterating order.
       
   411       ///     
       
   412       void first(UEdge&) const {}
       
   413 
       
   414       /// \brief Gives back the next undirected edge in the iterating
       
   415       /// order.
       
   416       ///
       
   417       /// Gives back the next undirected edge in the iterating order.
       
   418       ///     
       
   419       void next(UEdge&) const {}
       
   420 
       
   421 
       
   422       /// \brief Gives back the first of the undirected edges from the
       
   423       /// given node.
       
   424       ///
       
   425       /// Gives back the first of the undirected edges from the given
       
   426       /// node. The bool parameter gives back that direction which
       
   427       /// gives a good direction of the uedge so the source of the
       
   428       /// directed edge is the given node.
       
   429       void firstInc(UEdge&, bool&, const Node&) const {}
       
   430 
       
   431       /// \brief Gives back the next of the undirected edges from the
       
   432       /// given node.
       
   433       ///
       
   434       /// Gives back the next of the undirected edges from the given
       
   435       /// node. The bool parameter should be used as the \c firstInc()
       
   436       /// use it.
       
   437       void nextInc(UEdge&, bool&) const {}
       
   438 
       
   439       template <typename _Graph>
       
   440       struct Constraints {
       
   441       
       
   442 	void constraints() {
       
   443 	  checkConcept<Base, _Graph >();
       
   444 	  checkConcept<BaseIterableGraphComponent<Base>, _Graph>();
       
   445 	  typename _Graph::Node node(INVALID);
       
   446 	  typename _Graph::UEdge uedge(INVALID);
       
   447           bool dir;
       
   448 	  {
       
   449 	    graph.first(uedge);
       
   450 	    graph.next(uedge);
       
   451 	  }
       
   452 	  {
       
   453 	    graph.firstInc(uedge, dir, node);
       
   454 	    graph.nextInc(uedge, dir);
       
   455 	  }
       
   456 	}
       
   457 
       
   458 	const _Graph& graph;
       
   459       };
       
   460     };
   441     };
   461 
   442 
   462     /// \brief An empty idable base graph class.
   443     /// \brief An empty idable base graph class.
   463     ///  
   444     ///  
   464     /// This class provides beside the core graph features
   445     /// This class provides beside the core graph features
   515 
   496 
   516       template <typename _Graph>
   497       template <typename _Graph>
   517       struct Constraints {
   498       struct Constraints {
   518 
   499 
   519 	void constraints() {
   500 	void constraints() {
   520 	  checkConcept< BaseGraphComponent, _Graph >();
   501 	  checkConcept<Base, _Graph >();
   521 	  typename _Graph::Node node;
   502 	  typename _Graph::Node node;
   522 	  int nid = graph.id(node);
   503 	  int nid = graph.id(node);
   523 	  nid = graph.id(node);
   504 	  nid = graph.id(node);
   524 	  node = graph.nodeFromId(nid);
   505 	  node = graph.nodeFromId(nid);
   525 	  typename _Graph::Edge edge;
   506 	  typename _Graph::Edge edge;
   588 
   569 
   589 	const _Graph& graph;
   570 	const _Graph& graph;
   590       };
   571       };
   591     };
   572     };
   592 
   573 
   593     /// \brief An empty extendable base graph class.
   574     /// \brief An empty idable base bipartite undirected graph class.
   594     ///
       
   595     /// This class provides beside the core graph features
       
   596     /// core graph extend interface for the graph structure.
       
   597     /// The most of the base graphs should be conform to this concept.
       
   598     template <typename _Base = BaseGraphComponent>
       
   599     class BaseExtendableGraphComponent : public _Base {
       
   600     public:
       
   601 
       
   602       typedef typename _Base::Node Node;
       
   603       typedef typename _Base::Edge Edge;
       
   604 
       
   605       /// \brief Adds a new node to the graph.
       
   606       ///
       
   607       /// Adds a new node to the graph.
       
   608       ///
       
   609       Node addNode() {
       
   610 	return INVALID;
       
   611       }
       
   612     
       
   613       /// \brief Adds a new edge connects the given two nodes.
       
   614       ///
       
   615       /// Adds a new edge connects the the given two nodes.
       
   616       Edge addEdge(const Node&, const Node&) {
       
   617 	return INVALID;
       
   618       }
       
   619 
       
   620       template <typename _Graph>
       
   621       struct Constraints {
       
   622 	void constraints() {
       
   623 	  typename _Graph::Node node_a, node_b;
       
   624 	  node_a = graph.addNode();
       
   625 	  node_b = graph.addNode();
       
   626 	  typename _Graph::Edge edge;
       
   627 	  edge = graph.addEdge(node_a, node_b);
       
   628 	}
       
   629 
       
   630 	_Graph& graph;
       
   631       };
       
   632     };
       
   633 
       
   634     /// \brief An empty extendable base undirected graph class.
       
   635     ///
       
   636     /// This class provides beside the core undirected graph features
       
   637     /// core undircted graph extend interface for the graph structure.
       
   638     /// The most of the base graphs should be conform to this concept.
       
   639     template <typename _Base = BaseUGraphComponent>
       
   640     class BaseExtendableUGraphComponent : public _Base {
       
   641     public:
       
   642 
       
   643       typedef typename _Base::Node Node;
       
   644       typedef typename _Base::UEdge UEdge;
       
   645 
       
   646       /// \brief Adds a new node to the graph.
       
   647       ///
       
   648       /// Adds a new node to the graph.
       
   649       ///
       
   650       Node addNode() {
       
   651 	return INVALID;
       
   652       }
       
   653     
       
   654       /// \brief Adds a new edge connects the given two nodes.
       
   655       ///
       
   656       /// Adds a new edge connects the the given two nodes.
       
   657       UEdge addEdge(const Node&, const Node&) {
       
   658 	return INVALID;
       
   659       }
       
   660 
       
   661       template <typename _Graph>
       
   662       struct Constraints {
       
   663 	void constraints() {
       
   664 	  typename _Graph::Node node_a, node_b;
       
   665 	  node_a = graph.addNode();
       
   666 	  node_b = graph.addNode();
       
   667 	  typename _Graph::UEdge uedge;
       
   668 	  uedge = graph.addUEdge(node_a, node_b);
       
   669 	}
       
   670 
       
   671 	_Graph& graph;
       
   672       };
       
   673     };
       
   674 
       
   675     /// \brief An empty erasable base graph class.
       
   676     ///  
   575     ///  
   677     /// This class provides beside the core graph features
   576     /// This class provides beside the core bipartite undirected graph
   678     /// core erase functions for the graph structure.
   577     /// features core id functions for the bipartite undirected graph
   679     /// The most of the base graphs should be conform to this concept.
   578     /// structure.  The most of the base undirected graphs should be
   680     template <typename _Base = BaseGraphComponent>
   579     /// conform to this concept.
   681     class BaseErasableGraphComponent : public _Base {
   580     template <typename _Base = BaseBpUGraphComponent>
       
   581     class IDableBpUGraphComponent : public IDableUGraphComponent<_Base> {
   682     public:
   582     public:
   683 
   583 
   684       typedef _Base Base;
   584       typedef _Base Base;
   685       typedef typename Base::Node Node;
   585       typedef typename Base::Node Node;
   686       typedef typename Base::Edge Edge;
   586 
   687 
   587       using IDableUGraphComponent<_Base>::id;
   688       /// \brief Erase a node from the graph.
   588 
   689       ///
   589       /// \brief Gives back an unique integer id for the ANode. 
   690       /// Erase a node from the graph. This function should not
   590       ///
   691       /// erase edges connecting to the Node.
   591       /// Gives back an unique integer id for the ANode. 
   692       void erase(const Node&) {}    
   592       ///
   693 
   593       int aNodeId(const Node&) const { return -1;}
   694       /// \brief Erase an edge from the graph.
   594 
   695       ///
   595       /// \brief Gives back the undirected edge by the unique id.
   696       /// Erase an edge from the graph.
   596       ///
   697       ///
   597       /// Gives back the undirected edge by the unique id.  If the
   698       void erase(const Edge&) {}
   598       /// graph does not contain edge with the given id then the
       
   599       /// result of the function is undetermined.
       
   600       Node nodeFromANodeId(int) const { return INVALID;}
       
   601 
       
   602       /// \brief Gives back an integer greater or equal to the maximum
       
   603       /// ANode id.
       
   604       ///
       
   605       /// Gives back an integer greater or equal to the maximum ANode
       
   606       /// id.
       
   607       int maxANodeId() const { return -1;}
       
   608 
       
   609       /// \brief Gives back an unique integer id for the BNode. 
       
   610       ///
       
   611       /// Gives back an unique integer id for the BNode. 
       
   612       ///
       
   613       int bNodeId(const Node&) const { return -1;}
       
   614 
       
   615       /// \brief Gives back the undirected edge by the unique id.
       
   616       ///
       
   617       /// Gives back the undirected edge by the unique id.  If the
       
   618       /// graph does not contain edge with the given id then the
       
   619       /// result of the function is undetermined.
       
   620       Node nodeFromBNodeId(int) const { return INVALID;}
       
   621 
       
   622       /// \brief Gives back an integer greater or equal to the maximum
       
   623       /// BNode id.
       
   624       ///
       
   625       /// Gives back an integer greater or equal to the maximum BNode
       
   626       /// id.
       
   627       int maxBNodeId() const { return -1;}
   699 
   628 
   700       template <typename _Graph>
   629       template <typename _Graph>
   701       struct Constraints {
   630       struct Constraints {
   702 	void constraints() {
   631 
   703 	  typename _Graph::Node node;
   632 	void constraints() {
   704 	  graph.erase(node);
   633 	  checkConcept<Base, _Graph >();
   705 	  typename _Graph::Edge edge;
   634 	  checkConcept<IDableGraphComponent<Base>, _Graph >();
   706 	  graph.erase(edge);
   635 	  typename _Graph::Node node(INVALID);
   707 	}
   636 	  int id;
   708 
   637           id = graph.aNodeId(node);
   709 	_Graph& graph;
   638           id = graph.bNodeId(node);
   710       };
   639           node = graph.nodeFromANodeId(id);
   711     };
   640           node = graph.nodeFromBNodeId(id);
   712 
   641           id = graph.maxANodeId();
   713     /// \brief An empty erasable base undirected graph class.
   642           id = graph.maxBNodeId();
   714     ///  
   643 	}
   715     /// This class provides beside the core undirected graph features
   644 
   716     /// core erase functions for the undirceted graph structure.
   645 	const _Graph& graph;
   717     template <typename _Base = BaseUGraphComponent>
   646       };
   718     class BaseErasableUGraphComponent : public _Base {
   647     };
   719     public:
       
   720 
       
   721       typedef _Base Base;
       
   722       typedef typename Base::Node Node;
       
   723       typedef typename Base::UEdge UEdge;
       
   724 
       
   725       /// \brief Erase a node from the graph.
       
   726       ///
       
   727       /// Erase a node from the graph. This function should not
       
   728       /// erase edges connecting to the Node.
       
   729       void erase(const Node&) {}    
       
   730 
       
   731       /// \brief Erase an edge from the graph.
       
   732       ///
       
   733       /// Erase an edge from the graph.
       
   734       ///
       
   735       void erase(const UEdge&) {}
       
   736 
       
   737       template <typename _Graph>
       
   738       struct Constraints {
       
   739 	void constraints() {
       
   740 	  typename _Graph::Node node;
       
   741 	  graph.erase(node);
       
   742 	  typename _Graph::Edge edge;
       
   743 	  graph.erase(edge);
       
   744 	}
       
   745 
       
   746 	_Graph& graph;
       
   747       };
       
   748     };
       
   749 
       
   750     /// \brief An empty clearable base graph class.
       
   751     ///
       
   752     /// This class provides beside the core graph features
       
   753     /// core clear functions for the graph structure.
       
   754     /// The most of the base graphs should be conform to this concept.
       
   755     template <typename _Base = BaseGraphComponent>
       
   756     class BaseClearableGraphComponent : public _Base {
       
   757     public:
       
   758 
       
   759       /// \brief Erase all the nodes and edges from the graph.
       
   760       ///
       
   761       /// Erase all the nodes and edges from the graph.
       
   762       ///
       
   763       void clear() {}    
       
   764 
       
   765       template <typename _Graph>
       
   766       struct Constraints {
       
   767 	void constraints() {
       
   768 	  graph.clear();
       
   769 	}
       
   770 
       
   771 	_Graph graph;
       
   772       };
       
   773     };
       
   774 
       
   775     /// \brief An empty clearable base undirected graph class.
       
   776     ///
       
   777     /// This class provides beside the core undirected graph features
       
   778     /// core clear functions for the undirected graph structure.
       
   779     /// The most of the base graphs should be conform to this concept.
       
   780     template <typename _Base = BaseUGraphComponent>
       
   781     class BaseClearableUGraphComponent : public _Base {
       
   782     public:
       
   783 
       
   784       /// \brief Erase all the nodes and undirected edges from the graph.
       
   785       ///
       
   786       /// Erase all the nodes and undirected edges from the graph.
       
   787       ///
       
   788       void clear() {}    
       
   789 
       
   790       template <typename _Graph>
       
   791       struct Constraints {
       
   792 	void constraints() {
       
   793 	  graph.clear();
       
   794 	}
       
   795 
       
   796 	_Graph graph;
       
   797       };
       
   798     };
       
   799 
       
   800 
   648 
   801     /// \brief Skeleton class for graph NodeIt and EdgeIt
   649     /// \brief Skeleton class for graph NodeIt and EdgeIt
   802     ///
   650     ///
   803     /// Skeleton class for graph NodeIt and EdgeIt.
   651     /// Skeleton class for graph NodeIt and EdgeIt.
   804     ///
   652     ///
   945 
   793 
   946     /// \brief An empty iterable graph class.
   794     /// \brief An empty iterable graph class.
   947     ///
   795     ///
   948     /// This class provides beside the core graph features
   796     /// This class provides beside the core graph features
   949     /// iterator based iterable interface for the graph structure.
   797     /// iterator based iterable interface for the graph structure.
   950     /// This concept is part of the GraphConcept.
   798     /// This concept is part of the Graph concept.
   951     template <typename _Base = BaseGraphComponent>
   799     template <typename _Base = BaseGraphComponent>
   952     class IterableGraphComponent : public _Base {
   800     class IterableGraphComponent : public _Base {
   953 
   801 
   954     public:
   802     public:
   955     
   803     
   957       typedef typename Base::Node Node;
   805       typedef typename Base::Node Node;
   958       typedef typename Base::Edge Edge;
   806       typedef typename Base::Edge Edge;
   959 
   807 
   960       typedef IterableGraphComponent Graph;
   808       typedef IterableGraphComponent Graph;
   961 
   809 
       
   810       /// \name Base iteration
       
   811       /// 
       
   812       /// This interface provides functions for iteration on graph items
       
   813       ///
       
   814       /// @{  
       
   815 
       
   816       /// \brief Gives back the first node in the iterating order.
       
   817       ///      
       
   818       /// Gives back the first node in the iterating order.
       
   819       ///     
       
   820       void first(Node&) const {}
       
   821 
       
   822       /// \brief Gives back the next node in the iterating order.
       
   823       ///
       
   824       /// Gives back the next node in the iterating order.
       
   825       ///     
       
   826       void next(Node&) const {}
       
   827 
       
   828       /// \brief Gives back the first edge in the iterating order.
       
   829       ///
       
   830       /// Gives back the first edge in the iterating order.
       
   831       ///     
       
   832       void first(Edge&) const {}
       
   833 
       
   834       /// \brief Gives back the next edge in the iterating order.
       
   835       ///
       
   836       /// Gives back the next edge in the iterating order.
       
   837       ///     
       
   838       void next(Edge&) const {}
       
   839 
       
   840 
       
   841       /// \brief Gives back the first of the edges point to the given
       
   842       /// node.
       
   843       ///
       
   844       /// Gives back the first of the edges point to the given node.
       
   845       ///     
       
   846       void firstIn(Edge&, const Node&) const {}
       
   847 
       
   848       /// \brief Gives back the next of the edges points to the given
       
   849       /// node.
       
   850       ///
       
   851       /// Gives back the next of the edges points to the given node.
       
   852       ///
       
   853       void nextIn(Edge&) const {}
       
   854 
       
   855       /// \brief Gives back the first of the edges start from the
       
   856       /// given node.
       
   857       ///      
       
   858       /// Gives back the first of the edges start from the given node.
       
   859       ///     
       
   860       void firstOut(Edge&, const Node&) const {}
       
   861 
       
   862       /// \brief Gives back the next of the edges start from the given
       
   863       /// node.
       
   864       ///
       
   865       /// Gives back the next of the edges start from the given node.
       
   866       ///     
       
   867       void nextOut(Edge&) const {}
       
   868 
       
   869       /// @}
       
   870 
       
   871       /// \name Class based iteration
       
   872       /// 
       
   873       /// This interface provides functions for iteration on graph items
       
   874       ///
       
   875       /// @{
   962 
   876 
   963       /// \brief This iterator goes through each node.
   877       /// \brief This iterator goes through each node.
   964       ///
   878       ///
   965       /// This iterator goes through each node.
   879       /// This iterator goes through each node.
   966       ///
   880       ///
  1006       ///
   920       ///
  1007       /// Gives back the running node of the iterator.
   921       /// Gives back the running node of the iterator.
  1008       /// It is always the target of the pointed edge.
   922       /// It is always the target of the pointed edge.
  1009       Node runningNode(const OutEdgeIt&) const { return INVALID; }
   923       Node runningNode(const OutEdgeIt&) const { return INVALID; }
  1010 
   924 
  1011       /// \brief The opposite node on the given edge.
   925       /// @}
  1012       ///
   926 
  1013       /// Gives back the opposite on the given edge.
       
  1014       /// \todo It should not be here.
       
  1015       Node oppositeNode(const Node&, const Edge&) const { return INVALID; }
       
  1016 
       
  1017     
       
  1018       template <typename _Graph> 
   927       template <typename _Graph> 
  1019       struct Constraints {
   928       struct Constraints {
  1020 	void constraints() {
   929 	void constraints() {
  1021 	  checkConcept<Base, _Graph>();
   930 	  checkConcept<Base, _Graph>();
  1022 	  
   931 
  1023 	  checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
   932           {
  1024 	    typename _Graph::EdgeIt >();
   933             typename _Graph::Node node(INVALID);      
  1025 	  checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
   934             typename _Graph::Edge edge(INVALID);
  1026 	    typename _Graph::NodeIt >();
   935             {
  1027 	  checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
   936               graph.first(node);
  1028             typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
   937               graph.next(node);
  1029 	  checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
   938             }
  1030             typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
   939             {
  1031 
   940               graph.first(edge);
  1032           typename _Graph::Node n;
   941               graph.next(edge);
  1033           typename _Graph::InEdgeIt ieit(INVALID);
   942             }
  1034           typename _Graph::OutEdgeIt oeit(INVALID);
   943             {
  1035           n = graph.baseNode(ieit);
   944               graph.firstIn(edge, node);
  1036           n = graph.runningNode(ieit);
   945               graph.nextIn(edge);
  1037           n = graph.baseNode(oeit);
   946             }
  1038           n = graph.runningNode(oeit);
   947             {
  1039           ignore_unused_variable_warning(n);
   948               graph.firstOut(edge, node);
       
   949               graph.nextOut(edge);
       
   950             }
       
   951           }           
       
   952 
       
   953           {
       
   954             checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
       
   955               typename _Graph::EdgeIt >();
       
   956             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
       
   957               typename _Graph::NodeIt >();
       
   958             checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
       
   959               typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
       
   960             checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
       
   961               typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
       
   962 
       
   963             typename _Graph::Node n;
       
   964             typename _Graph::InEdgeIt ieit(INVALID);
       
   965             typename _Graph::OutEdgeIt oeit(INVALID);
       
   966             n = graph.baseNode(ieit);
       
   967             n = graph.runningNode(ieit);
       
   968             n = graph.baseNode(oeit);
       
   969             n = graph.runningNode(oeit);
       
   970             ignore_unused_variable_warning(n);
       
   971           }
  1040         }
   972         }
  1041 	
   973 	
  1042 	const _Graph& graph;
   974 	const _Graph& graph;
  1043 	
   975 	
  1044       };
   976       };
  1046 
   978 
  1047     /// \brief An empty iterable undirected graph class.
   979     /// \brief An empty iterable undirected graph class.
  1048     ///
   980     ///
  1049     /// This class provides beside the core graph features iterator
   981     /// This class provides beside the core graph features iterator
  1050     /// based iterable interface for the undirected graph structure.
   982     /// based iterable interface for the undirected graph structure.
  1051     /// This concept is part of the GraphConcept.
   983     /// This concept is part of the UGraph concept.
  1052     template <typename _Base = BaseUGraphComponent>
   984     template <typename _Base = BaseUGraphComponent>
  1053     class IterableUGraphComponent : public IterableGraphComponent<_Base> {
   985     class IterableUGraphComponent : public IterableGraphComponent<_Base> {
  1054     public:
   986     public:
  1055 
   987 
  1056       typedef _Base Base;
   988       typedef _Base Base;
  1058       typedef typename Base::Edge Edge;
   990       typedef typename Base::Edge Edge;
  1059       typedef typename Base::UEdge UEdge;
   991       typedef typename Base::UEdge UEdge;
  1060 
   992 
  1061     
   993     
  1062       typedef IterableUGraphComponent Graph;
   994       typedef IterableUGraphComponent Graph;
       
   995 
       
   996       /// \name Base iteration
       
   997       /// 
       
   998       /// This interface provides functions for iteration on graph items
       
   999       /// @{  
       
  1000 
       
  1001       using IterableGraphComponent<_Base>::first;
       
  1002       using IterableGraphComponent<_Base>::next;
       
  1003 
       
  1004       /// \brief Gives back the first undirected edge in the iterating
       
  1005       /// order.
       
  1006       ///
       
  1007       /// Gives back the first undirected edge in the iterating order.
       
  1008       ///     
       
  1009       void first(UEdge&) const {}
       
  1010 
       
  1011       /// \brief Gives back the next undirected edge in the iterating
       
  1012       /// order.
       
  1013       ///
       
  1014       /// Gives back the next undirected edge in the iterating order.
       
  1015       ///     
       
  1016       void next(UEdge&) const {}
       
  1017 
       
  1018 
       
  1019       /// \brief Gives back the first of the undirected edges from the
       
  1020       /// given node.
       
  1021       ///
       
  1022       /// Gives back the first of the undirected edges from the given
       
  1023       /// node. The bool parameter gives back that direction which
       
  1024       /// gives a good direction of the uedge so the source of the
       
  1025       /// directed edge is the given node.
       
  1026       void firstInc(UEdge&, bool&, const Node&) const {}
       
  1027 
       
  1028       /// \brief Gives back the next of the undirected edges from the
       
  1029       /// given node.
       
  1030       ///
       
  1031       /// Gives back the next of the undirected edges from the given
       
  1032       /// node. The bool parameter should be used as the \c firstInc()
       
  1033       /// use it.
       
  1034       void nextInc(UEdge&, bool&) const {}
       
  1035 
  1063       using IterableGraphComponent<_Base>::baseNode;
  1036       using IterableGraphComponent<_Base>::baseNode;
  1064       using IterableGraphComponent<_Base>::runningNode;
  1037       using IterableGraphComponent<_Base>::runningNode;
  1065 
  1038 
       
  1039       /// @}
       
  1040 
       
  1041       /// \name Class based iteration
       
  1042       /// 
       
  1043       /// This interface provides functions for iteration on graph items
       
  1044       ///
       
  1045       /// @{
  1066 
  1046 
  1067       /// \brief This iterator goes through each node.
  1047       /// \brief This iterator goes through each node.
  1068       ///
  1048       ///
  1069       /// This iterator goes through each node.
  1049       /// This iterator goes through each node.
  1070       typedef GraphItemIt<Graph, UEdge> UEdgeIt;
  1050       typedef GraphItemIt<Graph, UEdge> UEdgeIt;
  1082       /// \brief The running node of the iterator.
  1062       /// \brief The running node of the iterator.
  1083       ///
  1063       ///
  1084       /// Gives back the running node of the iterator.
  1064       /// Gives back the running node of the iterator.
  1085       Node runningNode(const IncEdgeIt&) const { return INVALID; }
  1065       Node runningNode(const IncEdgeIt&) const { return INVALID; }
  1086 
  1066 
       
  1067       /// @}
       
  1068 
  1087       template <typename _Graph> 
  1069       template <typename _Graph> 
  1088       struct Constraints {
  1070       struct Constraints {
  1089 	void constraints() {
  1071 	void constraints() {
  1090 	  checkConcept<Base, _Graph>();
       
  1091 	  checkConcept<IterableGraphComponent<Base>, _Graph>();
  1072 	  checkConcept<IterableGraphComponent<Base>, _Graph>();
  1092 	  
  1073 
  1093 	  checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
  1074           {
  1094 	    typename _Graph::UEdgeIt >();
  1075             typename _Graph::Node node(INVALID);
  1095 	  checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge, 
  1076             typename _Graph::UEdge uedge(INVALID);
  1096             typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
  1077             bool dir;
  1097 
  1078             {
  1098           typename _Graph::Node n;
  1079               graph.first(uedge);
  1099           typename _Graph::IncEdgeIt ueit(INVALID);
  1080               graph.next(uedge);
  1100           n = graph.baseNode(ueit);
  1081             }
  1101           n = graph.runningNode(ueit);
  1082             {
       
  1083               graph.firstInc(uedge, dir, node);
       
  1084               graph.nextInc(uedge, dir);
       
  1085             }
       
  1086             
       
  1087           }	
       
  1088   
       
  1089           {
       
  1090             checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
       
  1091               typename _Graph::UEdgeIt >();
       
  1092             checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge, 
       
  1093               typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
       
  1094             
       
  1095             typename _Graph::Node n;
       
  1096             typename _Graph::IncEdgeIt ueit(INVALID);
       
  1097             n = graph.baseNode(ueit);
       
  1098             n = graph.runningNode(ueit);
       
  1099           }
       
  1100         }
       
  1101 	
       
  1102 	const _Graph& graph;
       
  1103 	
       
  1104       };
       
  1105     };
       
  1106 
       
  1107     /// \brief An empty iterable bipartite undirected graph class.
       
  1108     ///
       
  1109     /// This class provides beside the core graph features iterator
       
  1110     /// based iterable interface for the bipartite undirected graph
       
  1111     /// structure. This concept is part of the BpUGraph concept.
       
  1112     template <typename _Base = BaseUGraphComponent>
       
  1113     class IterableBpUGraphComponent : public IterableUGraphComponent<_Base> {
       
  1114     public:
       
  1115 
       
  1116       typedef _Base Base;
       
  1117       typedef typename Base::Node Node;
       
  1118       typedef typename Base::UEdge UEdge;
       
  1119     
       
  1120       typedef IterableBpUGraphComponent Graph;
       
  1121 
       
  1122       /// \name Base iteration
       
  1123       /// 
       
  1124       /// This interface provides functions for iteration on graph items
       
  1125       /// @{  
       
  1126 
       
  1127       using IterableUGraphComponent<_Base>::first;
       
  1128       using IterableUGraphComponent<_Base>::next;
       
  1129 
       
  1130       /// \brief Gives back the first A-node in the iterating order.
       
  1131       ///
       
  1132       /// Gives back the first undirected A-node in the iterating
       
  1133       /// order.
       
  1134       ///     
       
  1135       void firstANode(Node&) const {}
       
  1136 
       
  1137       /// \brief Gives back the next A-node in the iterating order.
       
  1138       ///
       
  1139       /// Gives back the next A-node in the iterating order.
       
  1140       ///     
       
  1141       void nextANode(Node&) const {}
       
  1142 
       
  1143       /// \brief Gives back the first B-node in the iterating order.
       
  1144       ///
       
  1145       /// Gives back the first undirected B-node in the iterating
       
  1146       /// order.
       
  1147       ///     
       
  1148       void firstBNode(Node&) const {}
       
  1149 
       
  1150       /// \brief Gives back the next B-node in the iterating order.
       
  1151       ///
       
  1152       /// Gives back the next B-node in the iterating order.
       
  1153       ///     
       
  1154       void nextBNode(Node&) const {}
       
  1155 
       
  1156 
       
  1157       /// \brief Gives back the first of the undirected edges start
       
  1158       /// from the given A-node.
       
  1159       ///      
       
  1160       /// Gives back the first of the undirected edges start from the
       
  1161       /// given A-node.
       
  1162       void firstFromANode(UEdge&, const Node&) const {}
       
  1163 
       
  1164       /// \brief Gives back the next of the undirected edges start
       
  1165       /// from the given A-node.
       
  1166       ///      
       
  1167       /// Gives back the next of the undirected edges start from the
       
  1168       /// given A-node.
       
  1169       void nextFromANode(UEdge&) const {}
       
  1170 
       
  1171       /// \brief Gives back the first of the undirected edges start
       
  1172       /// from the given B-node.
       
  1173       ///      
       
  1174       /// Gives back the first of the undirected edges start from the
       
  1175       /// given B-node.
       
  1176       void firstFromBNode(UEdge&, const Node&) const {}
       
  1177 
       
  1178       /// \brief Gives back the next of the undirected edges start
       
  1179       /// from the given B-node.
       
  1180       ///      
       
  1181       /// Gives back the next of the undirected edges start from the
       
  1182       /// given B-node.
       
  1183       void nextFromBNode(UEdge&) const {}
       
  1184 
       
  1185 
       
  1186       /// @}
       
  1187 
       
  1188       /// \name Class based iteration
       
  1189       /// 
       
  1190       /// This interface provides functions for iteration on graph items
       
  1191       ///
       
  1192       /// @{
       
  1193 
       
  1194       /// \brief This iterator goes through each A-node.
       
  1195       ///
       
  1196       /// This iterator goes through each A-node.
       
  1197       typedef GraphItemIt<Graph, Node> ANodeIt;
       
  1198 
       
  1199       /// \brief This iterator goes through each B-node.
       
  1200       ///
       
  1201       /// This iterator goes through each B-node.
       
  1202       typedef GraphItemIt<Graph, Node> BNodeIt;
       
  1203 
       
  1204       /// @}
       
  1205 
       
  1206       template <typename _Graph> 
       
  1207       struct Constraints {
       
  1208 	void constraints() {
       
  1209 	  checkConcept<IterableUGraphComponent<Base>, _Graph>();
       
  1210 
       
  1211           {
       
  1212             typename _Graph::Node node(INVALID);
       
  1213             typename _Graph::UEdge uedge(INVALID);
       
  1214             graph.firstANode(node);
       
  1215             graph.nextANode(node);
       
  1216             graph.firstBNode(node);
       
  1217             graph.nextBNode(node);
       
  1218 
       
  1219             graph.firstFromANode(uedge, node);
       
  1220             graph.nextFromANode(uedge);
       
  1221             graph.firstFromBNode(uedge, node);
       
  1222             graph.nextFromBNode(uedge);
       
  1223           }
       
  1224           {
       
  1225             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
       
  1226               typename _Graph::ANodeIt >();
       
  1227             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
       
  1228               typename _Graph::BNodeIt >();
       
  1229           }
       
  1230 
  1102 	}
  1231 	}
  1103 	
  1232 	
  1104 	const _Graph& graph;
  1233 	const _Graph& graph;
  1105 	
  1234 	
  1106       };
  1235       };
  1192       }
  1321       }
  1193 
  1322 
  1194       template <typename _Graph> 
  1323       template <typename _Graph> 
  1195       struct Constraints {
  1324       struct Constraints {
  1196 	void constraints() {
  1325 	void constraints() {
  1197 	  checkConcept<Base, _Graph>();
  1326 	  checkConcept<AlterableGraphComponent<Base>, _Graph>();
  1198           checkConcept<AlterableGraphComponent, _Graph>();
       
  1199           typename _Graph::UEdgeNotifier& uen 
  1327           typename _Graph::UEdgeNotifier& uen 
  1200             = graph.getNotifier(typename _Graph::UEdge());
  1328             = graph.getNotifier(typename _Graph::UEdge());
  1201           ignore_unused_variable_warning(uen);
  1329           ignore_unused_variable_warning(uen);
       
  1330 	}
       
  1331 	
       
  1332 	const _Graph& graph;
       
  1333 	
       
  1334       };
       
  1335       
       
  1336     };
       
  1337 
       
  1338     /// \brief An empty alteration notifier bipartite undirected graph
       
  1339     /// class.
       
  1340     ///  
       
  1341     /// This class provides beside the core graph features alteration
       
  1342     /// notifier interface for the graph structure.  This implements
       
  1343     /// an observer-notifier pattern for each graph item. More
       
  1344     /// obsevers can be registered into the notifier and whenever an
       
  1345     /// alteration occured in the graph all the observers will
       
  1346     /// notified about it.
       
  1347     template <typename _Base = BaseUGraphComponent>
       
  1348     class AlterableBpUGraphComponent : public AlterableUGraphComponent<_Base> {
       
  1349     public:
       
  1350 
       
  1351       typedef _Base Base;
       
  1352       typedef typename Base::ANode ANode;
       
  1353       typedef typename Base::BNode BNode;
       
  1354 
       
  1355 
       
  1356       /// The A-node observer registry.
       
  1357       typedef AlterationNotifier<AlterableBpUGraphComponent, ANode> 
       
  1358       ANodeNotifier;
       
  1359 
       
  1360       /// The B-node observer registry.
       
  1361       typedef AlterationNotifier<AlterableBpUGraphComponent, BNode> 
       
  1362       BNodeNotifier;
       
  1363       
       
  1364       /// \brief Gives back the A-node alteration notifier.
       
  1365       ///
       
  1366       /// Gives back the A-node alteration notifier.
       
  1367       ANodeNotifier& getNotifier(ANode) const {
       
  1368 	return ANodeNotifier();
       
  1369       }
       
  1370 
       
  1371       /// \brief Gives back the B-node alteration notifier.
       
  1372       ///
       
  1373       /// Gives back the B-node alteration notifier.
       
  1374       BNodeNotifier& getNotifier(BNode) const {
       
  1375 	return BNodeNotifier();
       
  1376       }
       
  1377 
       
  1378       template <typename _Graph> 
       
  1379       struct Constraints {
       
  1380 	void constraints() {
       
  1381           checkConcept<AlterableUGraphComponent<Base>, _Graph>();
       
  1382           typename _Graph::ANodeNotifier& ann 
       
  1383             = graph.getNotifier(typename _Graph::ANode());
       
  1384           typename _Graph::BNodeNotifier& bnn 
       
  1385             = graph.getNotifier(typename _Graph::BNode());
       
  1386           ignore_unused_variable_warning(ann);
       
  1387           ignore_unused_variable_warning(bnn);
  1202 	}
  1388 	}
  1203 	
  1389 	
  1204 	const _Graph& graph;
  1390 	const _Graph& graph;
  1205 	
  1391 	
  1206       };
  1392       };
  1413 
  1599 
  1414 	_Graph& graph;
  1600 	_Graph& graph;
  1415       };
  1601       };
  1416     };
  1602     };
  1417 
  1603 
  1418     /// \brief An empty mappable base graph class.
  1604     /// \brief An empty mappable base bipartite undirected graph class.
  1419     ///
  1605     ///
  1420     /// This class provides beside the core graph features
  1606     /// This class provides beside the core graph features
  1421     /// map interface for the graph structure.
  1607     /// map interface for the graph structure.
  1422     /// This concept is part of the UGraph concept.
  1608     /// This concept is part of the UGraph concept.
  1423     template <typename _Base = BaseUGraphComponent>
  1609     template <typename _Base = BaseUGraphComponent>
  1476 	  Dummy() : value(0) {}
  1662 	  Dummy() : value(0) {}
  1477 	  Dummy(int _v) : value(_v) {}
  1663 	  Dummy(int _v) : value(_v) {}
  1478 	};
  1664 	};
  1479 
  1665 
  1480 	void constraints() {
  1666 	void constraints() {
  1481 	  checkConcept<Base, _Graph>();
       
  1482 	  checkConcept<MappableGraphComponent<Base>, _Graph>();
  1667 	  checkConcept<MappableGraphComponent<Base>, _Graph>();
  1483 
  1668 
  1484 	  { // int map test
  1669 	  { // int map test
  1485 	    typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
  1670 	    typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
  1486 	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
  1671 	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
  1498 
  1683 
  1499 	_Graph& graph;
  1684 	_Graph& graph;
  1500       };
  1685       };
  1501     };
  1686     };
  1502 
  1687 
       
  1688     /// \brief An empty mappable base bipartite undirected graph
       
  1689     /// class.
       
  1690     ///
       
  1691     /// This class provides beside the core graph features
       
  1692     /// map interface for the graph structure.
       
  1693     /// This concept is part of the BpUGraph concept.
       
  1694     template <typename _Base = BaseBpUGraphComponent>
       
  1695     class MappableBpUGraphComponent : public MappableUGraphComponent<_Base>  {
       
  1696     public:
       
  1697 
       
  1698       typedef _Base Base;
       
  1699       typedef typename Base::Node Node;
       
  1700 
       
  1701       typedef MappableBpUGraphComponent Graph;
       
  1702 
       
  1703       /// \brief ReadWrite map of the A-nodes.
       
  1704       ///
       
  1705       /// ReadWrite map of the A-nodes.
       
  1706       ///
       
  1707       template <typename _Value>
       
  1708       class ANodeMap : public GraphMap<Graph, Node, _Value> {  
       
  1709       public:
       
  1710         typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
       
  1711 
       
  1712 	/// \brief Construct a new map.
       
  1713 	///
       
  1714 	/// Construct a new map for the graph.
       
  1715 	/// \todo call the right parent class constructor
       
  1716 	explicit ANodeMap(const MappableBpUGraphComponent& graph) 
       
  1717           : Parent(graph) {}
       
  1718 
       
  1719 	/// \brief Construct a new map with default value.
       
  1720 	///
       
  1721 	/// Construct a new map for the graph and initalise the values.
       
  1722 	ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
       
  1723           : Parent(graph, value) {}
       
  1724 
       
  1725 	/// \brief Copy constructor.
       
  1726 	///
       
  1727 	/// Copy Constructor.
       
  1728 	ANodeMap(const ANodeMap& nm) : Parent(nm) {}
       
  1729 
       
  1730 	/// \brief Assign operator.
       
  1731 	///
       
  1732 	/// Assign operator.
       
  1733         template <typename CMap>
       
  1734         ANodeMap& operator=(const CMap&) { 
       
  1735           checkConcept<ReadMap<Node, _Value>, CMap>();
       
  1736           return *this;
       
  1737         }
       
  1738 
       
  1739       };
       
  1740 
       
  1741       /// \brief ReadWrite map of the B-nodes.
       
  1742       ///
       
  1743       /// ReadWrite map of the A-nodes.
       
  1744       ///
       
  1745       template <typename _Value>
       
  1746       class BNodeMap : public GraphMap<Graph, Node, _Value> {  
       
  1747       public:
       
  1748         typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
       
  1749 
       
  1750 	/// \brief Construct a new map.
       
  1751 	///
       
  1752 	/// Construct a new map for the graph.
       
  1753 	/// \todo call the right parent class constructor
       
  1754 	explicit BNodeMap(const MappableBpUGraphComponent& graph) 
       
  1755           : Parent(graph) {}
       
  1756 
       
  1757 	/// \brief Construct a new map with default value.
       
  1758 	///
       
  1759 	/// Construct a new map for the graph and initalise the values.
       
  1760 	BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
       
  1761           : Parent(graph, value) {}
       
  1762 
       
  1763 	/// \brief Copy constructor.
       
  1764 	///
       
  1765 	/// Copy Constructor.
       
  1766 	BNodeMap(const BNodeMap& nm) : Parent(nm) {}
       
  1767 
       
  1768 	/// \brief Assign operator.
       
  1769 	///
       
  1770 	/// Assign operator.
       
  1771         template <typename CMap>
       
  1772         BNodeMap& operator=(const CMap&) { 
       
  1773           checkConcept<ReadMap<Node, _Value>, CMap>();
       
  1774           return *this;
       
  1775         }
       
  1776 
       
  1777       };
       
  1778 
       
  1779 
       
  1780       template <typename _Graph>
       
  1781       struct Constraints {
       
  1782 
       
  1783 	struct Dummy {
       
  1784 	  int value;
       
  1785 	  Dummy() : value(0) {}
       
  1786 	  Dummy(int _v) : value(_v) {}
       
  1787 	};
       
  1788 
       
  1789 	void constraints() {
       
  1790 	  checkConcept<MappableUGraphComponent<Base>, _Graph>();
       
  1791 
       
  1792 	  { // int map test
       
  1793 	    typedef typename _Graph::template ANodeMap<int> IntANodeMap;
       
  1794 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
       
  1795 	      IntANodeMap >();
       
  1796 	  } { // bool map test
       
  1797 	    typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
       
  1798 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
       
  1799 	      BoolANodeMap >();
       
  1800 	  } { // Dummy map test
       
  1801 	    typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
       
  1802 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>, 
       
  1803 	      DummyANodeMap >();
       
  1804 	  } 
       
  1805 	}
       
  1806 
       
  1807 	_Graph& graph;
       
  1808       };
       
  1809     };
       
  1810 
  1503 
  1811 
  1504     /// \brief An empty extendable graph class.
  1812     /// \brief An empty extendable graph class.
  1505     ///
  1813     ///
  1506     /// This class provides beside the core graph features graph
  1814     /// This class provides beside the core graph features graph
  1507     /// extendable interface for the graph structure.  The main
  1815     /// extendable interface for the graph structure.  The main
  1508     /// difference between the base and this interface is that the
  1816     /// difference between the base and this interface is that the
  1509     /// graph alterations should handled already on this level.
  1817     /// graph alterations should handled already on this level.
  1510     template <typename _Base = BaseGraphComponent>
  1818     template <typename _Base = BaseGraphComponent>
  1511     class ExtendableGraphComponent : public _Base {
  1819     class ExtendableGraphComponent : public _Base {
  1512     public:
  1820     public:
       
  1821       typedef _Base Base;
  1513 
  1822 
  1514       typedef typename _Base::Node Node;
  1823       typedef typename _Base::Node Node;
  1515       typedef typename _Base::Edge Edge;
  1824       typedef typename _Base::Edge Edge;
  1516 
  1825 
  1517       /// \brief Adds a new node to the graph.
  1826       /// \brief Adds a new node to the graph.
  1530       }
  1839       }
  1531 
  1840 
  1532       template <typename _Graph>
  1841       template <typename _Graph>
  1533       struct Constraints {
  1842       struct Constraints {
  1534 	void constraints() {
  1843 	void constraints() {
       
  1844           checkConcept<Base, _Graph>();
  1535 	  typename _Graph::Node node_a, node_b;
  1845 	  typename _Graph::Node node_a, node_b;
  1536 	  node_a = graph.addNode();
  1846 	  node_a = graph.addNode();
  1537 	  node_b = graph.addNode();
  1847 	  node_b = graph.addNode();
  1538 	  typename _Graph::Edge edge;
  1848 	  typename _Graph::Edge edge;
  1539 	  edge = graph.addEdge(node_a, node_b);
  1849 	  edge = graph.addEdge(node_a, node_b);
  1552     /// level.
  1862     /// level.
  1553     template <typename _Base = BaseUGraphComponent>
  1863     template <typename _Base = BaseUGraphComponent>
  1554     class ExtendableUGraphComponent : public _Base {
  1864     class ExtendableUGraphComponent : public _Base {
  1555     public:
  1865     public:
  1556 
  1866 
       
  1867       typedef _Base Base;
  1557       typedef typename _Base::Node Node;
  1868       typedef typename _Base::Node Node;
  1558       typedef typename _Base::UEdge UEdge;
  1869       typedef typename _Base::UEdge UEdge;
  1559 
  1870 
  1560       /// \brief Adds a new node to the graph.
  1871       /// \brief Adds a new node to the graph.
  1561       ///
  1872       ///
  1573       }
  1884       }
  1574 
  1885 
  1575       template <typename _Graph>
  1886       template <typename _Graph>
  1576       struct Constraints {
  1887       struct Constraints {
  1577 	void constraints() {
  1888 	void constraints() {
       
  1889 	  checkConcept<Base, _Graph>();
  1578 	  typename _Graph::Node node_a, node_b;
  1890 	  typename _Graph::Node node_a, node_b;
  1579 	  node_a = graph.addNode();
  1891 	  node_a = graph.addNode();
  1580 	  node_b = graph.addNode();
  1892 	  node_b = graph.addNode();
  1581 	  typename _Graph::UEdge uedge;
  1893 	  typename _Graph::UEdge uedge;
  1582 	  uedge = graph.addUEdge(node_a, node_b);
  1894 	  uedge = graph.addUEdge(node_a, node_b);
  1583 	}
  1895 	}
  1584 
  1896 
  1585 	_Graph& graph;
  1897 	_Graph& graph;
       
  1898       };
       
  1899     };
       
  1900 
       
  1901     /// \brief An empty extendable base undirected graph class.
       
  1902     ///
       
  1903     /// This class provides beside the core bipartite undirected graph
       
  1904     /// features core undircted graph extend interface for the graph
       
  1905     /// structure.  The main difference between the base and this
       
  1906     /// interface is that the graph alterations should handled already
       
  1907     /// on this level.
       
  1908     template <typename _Base = BaseBpUGraphComponent>
       
  1909     class ExtendableBpUGraphComponent 
       
  1910       : public ExtendableUGraphComponent<_Base> {
       
  1911 
       
  1912       typedef _Base Base;
       
  1913 
       
  1914       template <typename _Graph>
       
  1915       struct Constraints {
       
  1916 	void constraints() {
       
  1917           checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
       
  1918 	}
  1586       };
  1919       };
  1587     };
  1920     };
  1588 
  1921 
  1589     /// \brief An empty erasable graph class.
  1922     /// \brief An empty erasable graph class.
  1590     ///  
  1923     ///  
  1613       void erase(const Edge&) {}
  1946       void erase(const Edge&) {}
  1614 
  1947 
  1615       template <typename _Graph>
  1948       template <typename _Graph>
  1616       struct Constraints {
  1949       struct Constraints {
  1617 	void constraints() {
  1950 	void constraints() {
       
  1951           checkConcept<Base, _Graph>();
  1618 	  typename _Graph::Node node;
  1952 	  typename _Graph::Node node;
  1619 	  graph.erase(node);
  1953 	  graph.erase(node);
  1620 	  typename _Graph::Edge edge;
  1954 	  typename _Graph::Edge edge;
  1621 	  graph.erase(edge);
  1955 	  graph.erase(edge);
  1622 	}
  1956 	}
  1652       void erase(const UEdge&) {}
  1986       void erase(const UEdge&) {}
  1653 
  1987 
  1654       template <typename _Graph>
  1988       template <typename _Graph>
  1655       struct Constraints {
  1989       struct Constraints {
  1656 	void constraints() {
  1990 	void constraints() {
       
  1991           checkConcept<Base, _Graph>();
  1657 	  typename _Graph::Node node;
  1992 	  typename _Graph::Node node;
  1658 	  graph.erase(node);
  1993 	  graph.erase(node);
  1659 	  typename _Graph::Edge edge;
  1994 	  typename _Graph::Edge edge;
  1660 	  graph.erase(edge);
  1995 	  graph.erase(edge);
  1661 	}
  1996 	}
  1662 
  1997 
  1663 	_Graph& graph;
  1998 	_Graph& graph;
       
  1999       };
       
  2000     };
       
  2001 
       
  2002     /// \brief An empty erasable base bipartite undirected graph class.
       
  2003     ///  
       
  2004     /// This class provides beside the core bipartite undirected graph
       
  2005     /// features core erase functions for the undirceted graph
       
  2006     /// structure. The main difference between the base and this
       
  2007     /// interface is that the graph alterations should handled already
       
  2008     /// on this level.
       
  2009     template <typename _Base = BaseBpUGraphComponent>
       
  2010     class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
       
  2011     public:
       
  2012 
       
  2013       typedef _Base Base;
       
  2014 
       
  2015       template <typename _Graph>
       
  2016       struct Constraints {
       
  2017 	void constraints() {
       
  2018           checkConcept<ErasableUGraphComponent<Base>, _Graph>();
       
  2019 	}
  1664       };
  2020       };
  1665     };
  2021     };
  1666 
  2022 
  1667     /// \brief An empty clearable base graph class.
  2023     /// \brief An empty clearable base graph class.
  1668     ///
  2024     ///
  1672     /// should handled already on this level.
  2028     /// should handled already on this level.
  1673     template <typename _Base = BaseGraphComponent>
  2029     template <typename _Base = BaseGraphComponent>
  1674     class ClearableGraphComponent : public _Base {
  2030     class ClearableGraphComponent : public _Base {
  1675     public:
  2031     public:
  1676 
  2032 
       
  2033       typedef _Base Base;
       
  2034 
  1677       /// \brief Erase all nodes and edges from the graph.
  2035       /// \brief Erase all nodes and edges from the graph.
  1678       ///
  2036       ///
  1679       /// Erase all nodes and edges from the graph.
  2037       /// Erase all nodes and edges from the graph.
  1680       ///
  2038       ///
  1681       void clear() {}    
  2039       void clear() {}    
  1682 
  2040 
  1683       template <typename _Graph>
  2041       template <typename _Graph>
  1684       struct Constraints {
  2042       struct Constraints {
  1685 	void constraints() {
  2043 	void constraints() {
       
  2044           checkConcept<Base, _Graph>();
  1686 	  graph.clear();
  2045 	  graph.clear();
  1687 	}
  2046 	}
  1688 
  2047 
  1689 	_Graph graph;
  2048 	_Graph graph;
  1690       };
  2049       };
  1695     /// This class provides beside the core undirected graph features
  2054     /// This class provides beside the core undirected graph features
  1696     /// core clear functions for the undirected graph structure. The
  2055     /// core clear functions for the undirected graph structure. The
  1697     /// main difference between the base and this interface is that
  2056     /// main difference between the base and this interface is that
  1698     /// the graph alterations should handled already on this level.
  2057     /// the graph alterations should handled already on this level.
  1699     template <typename _Base = BaseUGraphComponent>
  2058     template <typename _Base = BaseUGraphComponent>
  1700     class ClearableUGraphComponent : public _Base {
  2059     class ClearableUGraphComponent : public ClearableUGraphComponent<_Base> {
  1701     public:
  2060     public:
  1702 
  2061 
  1703       /// \brief Erase all nodes and undirected edges from the graph.
  2062       typedef _Base Base;
  1704       ///
       
  1705       /// Erase all nodes and undirected edges from the graph.
       
  1706       ///
       
  1707       void clear() {}    
       
  1708 
  2063 
  1709       template <typename _Graph>
  2064       template <typename _Graph>
  1710       struct Constraints {
  2065       struct Constraints {
  1711 	void constraints() {
  2066 	void constraints() {
  1712 	  graph.clear();
  2067           checkConcept<ClearableUGraphComponent<Base>, _Graph>();
  1713 	}
  2068 	}
  1714 
  2069 
  1715 	_Graph graph;
  2070 	_Graph graph;
  1716       };
  2071       };
  1717     };
  2072     };
  1718 
  2073 
       
  2074     /// \brief An empty clearable base bipartite undirected graph
       
  2075     /// class.
       
  2076     ///
       
  2077     /// This class provides beside the core bipartite undirected graph
       
  2078     /// features core clear functions for the undirected graph
       
  2079     /// structure. The main difference between the base and this
       
  2080     /// interface is that the graph alterations should handled already
       
  2081     /// on this level.
       
  2082     template <typename _Base = BaseUGraphComponent>
       
  2083     class ClearableBpUGraphComponent 
       
  2084       : public ClearableBpUGraphComponent<_Base> {
       
  2085     public:
       
  2086 
       
  2087       typedef _Base Base;
       
  2088 
       
  2089       template <typename _Graph>
       
  2090       struct Constraints {
       
  2091 	void constraints() {
       
  2092           checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();
       
  2093 	}
       
  2094 
       
  2095       };
       
  2096 
       
  2097     };
       
  2098 
  1719   }
  2099   }
  1720 
  2100 
  1721 }
  2101 }
  1722 
  2102 
  1723 #endif
  2103 #endif