alpar@2260: /* -*- C++ -*-
alpar@2260:  *
alpar@2260:  * This file is a part of LEMON, a generic C++ optimization library
alpar@2260:  *
alpar@2391:  * Copyright (C) 2003-2007
alpar@2260:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@2260:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@2260:  *
alpar@2260:  * Permission to use, modify and distribute this software is granted
alpar@2260:  * provided that this copyright notice appears in all copies. For
alpar@2260:  * precise terms see the accompanying LICENSE file.
alpar@2260:  *
alpar@2260:  * This software is provided "AS IS" with no warranty of any kind,
alpar@2260:  * express or implied, and with no claim as to its suitability for any
alpar@2260:  * purpose.
alpar@2260:  *
alpar@2260:  */
alpar@2260: 
alpar@2260: ///\ingroup graph_concepts
alpar@2260: ///\file
alpar@2260: ///\brief The concept of the graph components.
alpar@2260: 
alpar@2260: 
alpar@2260: #ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H
alpar@2260: #define LEMON_CONCEPT_GRAPH_COMPONENTS_H
alpar@2260: 
alpar@2260: #include <lemon/bits/invalid.h>
alpar@2260: #include <lemon/concepts/maps.h>
alpar@2260: 
alpar@2260: #include <lemon/bits/alteration_notifier.h>
alpar@2260: 
alpar@2260: namespace lemon {
alpar@2260:   namespace concepts {
alpar@2260: 
alpar@2260:     /// \brief Skeleton class for graph Node and Edge types
alpar@2260:     ///
alpar@2260:     /// This class describes the interface of Node and Edge (and UEdge
alpar@2260:     /// in undirected graphs) subtypes of graph types.
alpar@2260:     ///
alpar@2260:     /// \note This class is a template class so that we can use it to
alpar@2260:     /// create graph skeleton classes. The reason for this is than Node
alpar@2260:     /// and Edge types should \em not derive from the same base class.
alpar@2260:     /// For Node you should instantiate it with character 'n' and for Edge
alpar@2260:     /// with 'e'.
alpar@2260: 
alpar@2260: #ifndef DOXYGEN
alpar@2260:     template <char _selector = '0'>
alpar@2260: #endif
alpar@2260:     class GraphItem {
alpar@2260:     public:
alpar@2260:       /// \brief Default constructor.
alpar@2260:       ///      
alpar@2260:       /// \warning The default constructor is not required to set
alpar@2260:       /// the item to some well-defined value. So you should consider it
alpar@2260:       /// as uninitialized.
alpar@2260:       GraphItem() {}
alpar@2260:       /// \brief Copy constructor.
alpar@2260:       ///
alpar@2260:       /// Copy constructor.
alpar@2260:       ///
alpar@2260:       GraphItem(const GraphItem &) {}
alpar@2260:       /// \brief Invalid constructor \& conversion.
alpar@2260:       ///
alpar@2260:       /// This constructor initializes the item to be invalid.
alpar@2260:       /// \sa Invalid for more details.
alpar@2260:       GraphItem(Invalid) {}
alpar@2260:       /// \brief Assign operator for nodes.
alpar@2260:       ///
alpar@2260:       /// The nodes are assignable. 
alpar@2260:       ///
alpar@2260:       GraphItem& operator=(GraphItem const&) { return *this; }
alpar@2260:       /// \brief Equality operator.
alpar@2260:       ///
alpar@2260:       /// Two iterators are equal if and only if they represents the
alpar@2260:       /// same node in the graph or both are invalid.
alpar@2260:       bool operator==(GraphItem) const { return false; }
alpar@2260:       /// \brief Inequality operator.
alpar@2260:       ///
alpar@2260:       /// \sa operator==(const Node& n)
alpar@2260:       ///
alpar@2260:       bool operator!=(GraphItem) const { return false; }
alpar@2260: 
alpar@2260:       /// \brief Artificial ordering operator.
alpar@2260:       ///
alpar@2260:       /// To allow the use of graph descriptors as key type in std::map or
alpar@2260:       /// similar associative container we require this.
alpar@2260:       ///
alpar@2260:       /// \note This operator only have to define some strict ordering of
alpar@2260:       /// the items; this order has nothing to do with the iteration
alpar@2260:       /// ordering of the items.
alpar@2260:       bool operator<(GraphItem) const { return false; }
alpar@2260: 
alpar@2260:       template<typename _GraphItem>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  _GraphItem i1;
alpar@2260: 	  _GraphItem i2 = i1;
alpar@2260: 	  _GraphItem i3 = INVALID;
alpar@2260: 	  
alpar@2260: 	  i1 = i2 = i3;
alpar@2260: 
alpar@2260: 	  bool b;
alpar@2260: 	  //	  b = (ia == ib) && (ia != ib) && (ia < ib);
alpar@2260: 	  b = (ia == ib) && (ia != ib);
alpar@2260: 	  b = (ia == INVALID) && (ib != INVALID);
alpar@2260:           b = (ia < ib);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	const _GraphItem &ia;
alpar@2260: 	const _GraphItem &ib;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty base graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides the minimal set of features needed for a graph
alpar@2260:     /// structure. All graph concepts have to be conform to this base
alpar@2260:     /// graph. It just provides types for nodes and edges and functions to
alpar@2260:     /// get the source and the target of the edges.
alpar@2260:     class BaseGraphComponent {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef BaseGraphComponent Graph;
alpar@2260:       
alpar@2260:       /// \brief Node class of the graph.
alpar@2260:       ///
alpar@2260:       /// This class represents the Nodes of the graph. 
alpar@2260:       ///
alpar@2260:       typedef GraphItem<'n'> Node;
alpar@2260: 
alpar@2260:       /// \brief Edge class of the graph.
alpar@2260:       ///
alpar@2260:       /// This class represents the Edges of the graph. 
alpar@2260:       ///
alpar@2260:       typedef GraphItem<'e'> Edge;
alpar@2260: 
alpar@2260:       /// \brief Gives back the target node of an edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the target node of an edge.
alpar@2260:       ///
alpar@2260:       Node target(const Edge&) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the source node of an edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the source node of an edge.
alpar@2260:       ///
alpar@2260:       Node source(const Edge&) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the opposite node on the given edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the opposite node on the given edge.
alpar@2260:       Node oppositeNode(const Node&, const Edge&) const {
alpar@2260:         return INVALID;
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	typedef typename _Graph::Node Node;
alpar@2260: 	typedef typename _Graph::Edge Edge;
alpar@2260:       
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<GraphItem<'n'>, Node>();
alpar@2260: 	  checkConcept<GraphItem<'e'>, Edge>();
alpar@2260: 	  {
alpar@2260: 	    Node n;
alpar@2260: 	    Edge e(INVALID);
alpar@2260: 	    n = graph.source(e);
alpar@2260: 	    n = graph.target(e);
alpar@2260:             n = graph.oppositeNode(n, e);
alpar@2260: 	  }      
alpar@2260: 	}
alpar@2260:       
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty base undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides the minimal set of features needed for an
alpar@2260:     /// undirected graph structure. All undirected graph concepts have
alpar@2260:     /// to be conform to this base graph. It just provides types for
alpar@2260:     /// nodes, edges and undirected edges and functions to get the
alpar@2260:     /// source and the target of the edges and undirected edges,
alpar@2260:     /// conversion from edges to undirected edges and function to get
alpar@2260:     /// both direction of the undirected edges.
alpar@2260:     class BaseUGraphComponent : public BaseGraphComponent {
alpar@2260:     public:
alpar@2260:       typedef BaseGraphComponent::Node Node;
alpar@2260:       typedef BaseGraphComponent::Edge Edge;
alpar@2260:       /// \brief Undirected edge class of the graph.
alpar@2260:       ///
alpar@2260:       /// This class represents the undirected edges of the graph.
alpar@2260:       /// The undirected graphs can be used as a directed graph which
alpar@2260:       /// for each edge contains the opposite edge too so the graph is
alpar@2260:       /// bidirected. The undirected edge represents two opposite
alpar@2260:       /// directed edges.
alpar@2260:       class UEdge : public GraphItem<'u'> {
alpar@2260:       public:
alpar@2260:         typedef GraphItem<'u'> Parent;
alpar@2260:         /// \brief Default constructor.
alpar@2260:         ///      
alpar@2260:         /// \warning The default constructor is not required to set
alpar@2260:         /// the item to some well-defined value. So you should consider it
alpar@2260:         /// as uninitialized.
alpar@2260:         UEdge() {}
alpar@2260:         /// \brief Copy constructor.
alpar@2260:         ///
alpar@2260:         /// Copy constructor.
alpar@2260:         ///
alpar@2260:         UEdge(const UEdge &) : Parent() {}
alpar@2260:         /// \brief Invalid constructor \& conversion.
alpar@2260:         ///
alpar@2260:         /// This constructor initializes the item to be invalid.
alpar@2260:         /// \sa Invalid for more details.
alpar@2260:         UEdge(Invalid) {}
alpar@2260:         /// \brief Converter from edge to undirected edge.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each edge should
alpar@2260:         /// be convertible to the represented undirected edge. 
alpar@2260:         UEdge(const Edge&) {}
alpar@2260:         /// \brief Assign edge to undirected edge.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each edge should
alpar@2260:         /// be convertible to the represented undirected edge. 
alpar@2260:         UEdge& operator=(const Edge&) { return *this; }
alpar@2260:       };
alpar@2260: 
alpar@2260:       /// \brief Returns the direction of the edge.
alpar@2260:       ///
alpar@2260:       /// Returns the direction of the edge. Each edge represents an
alpar@2260:       /// undirected edge with a direction. It gives back the
alpar@2260:       /// direction.
alpar@2260:       bool direction(const Edge&) const { return true; }
alpar@2260: 
alpar@2260:       /// \brief Returns the directed edge.
alpar@2260:       ///
alpar@2260:       /// Returns the directed edge from its direction and the
alpar@2260:       /// represented undirected edge.
alpar@2260:       Edge direct(const UEdge&, bool) const { return INVALID;} 
alpar@2260: 
alpar@2260:       /// \brief Returns the directed edge.
alpar@2260:       ///
alpar@2260:       /// Returns the directed edge from its source and the
alpar@2260:       /// represented undirected edge.
alpar@2260:       Edge direct(const UEdge&, const Node&) const { return INVALID;} 
alpar@2260: 
alpar@2260:       /// \brief Returns the opposite edge.
alpar@2260:       ///
alpar@2260:       /// Returns the opposite edge. It is the edge representing the
alpar@2260:       /// same undirected edge and has opposite direction.
alpar@2260:       Edge oppositeEdge(const Edge&) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the target node of an undirected edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the target node of an undirected edge. The name
alpar@2260:       /// target is a little confusing because the undirected edge
alpar@2260:       /// does not have target but it just means that one of the end 
alpar@2260:       /// node.
alpar@2260:       Node target(const UEdge&) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the source node of an undirected edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the source node of an undirected edge. The name
alpar@2260:       /// source is a little confusing because the undirected edge
alpar@2260:       /// does not have source but it just means that one of the end 
alpar@2260:       /// node.
alpar@2260:       Node source(const UEdge&) const { return INVALID;}
alpar@2260:       
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	typedef typename _Graph::Node Node;
alpar@2260: 	typedef typename _Graph::Edge Edge;
alpar@2260: 	typedef typename _Graph::UEdge UEdge;
alpar@2260:       
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<BaseGraphComponent, _Graph>();
alpar@2260: 	  checkConcept<GraphItem<'u'>, UEdge>();
alpar@2260: 	  {
alpar@2260: 	    Node n;
alpar@2260: 	    UEdge ue(INVALID);
alpar@2260:             Edge e;
alpar@2260: 	    n = graph.source(ue);
alpar@2260: 	    n = graph.target(ue);
alpar@2260:             e = graph.direct(ue, true);
alpar@2260:             e = graph.direct(ue, n);
alpar@2260:             e = graph.oppositeEdge(e);
alpar@2260:             ue = e;
alpar@2260:             bool d = graph.direction(e);
alpar@2260:             ignore_unused_variable_warning(d);
alpar@2260: 	  }      
alpar@2260: 	}
alpar@2260:       
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260: 
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty base bipartite undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides the minimal set of features needed for an
alpar@2260:     /// bipartite undirected graph structure. All bipartite undirected
alpar@2260:     /// graph concepts have to be conform to this base graph. It just
alpar@2260:     /// provides types for nodes, A-nodes, B-nodes, edges and
alpar@2260:     /// undirected edges and functions to get the source and the
alpar@2260:     /// target of the edges and undirected edges, conversion from
alpar@2260:     /// edges to undirected edges and function to get both direction
alpar@2260:     /// of the undirected edges.
alpar@2260:     class BaseBpUGraphComponent : public BaseUGraphComponent {
alpar@2260:     public:
alpar@2260:       typedef BaseUGraphComponent::Node Node;
alpar@2260:       typedef BaseUGraphComponent::Edge Edge;
alpar@2260:       typedef BaseUGraphComponent::UEdge UEdge;
alpar@2260: 
alpar@2260:       /// \brief Helper class for A-nodes.
alpar@2260:       ///
alpar@2260:       /// This class is just a helper class for A-nodes, it is not
alpar@2260:       /// suggested to use it directly. It can be converted easily to
alpar@2260:       /// node and vice versa. The usage of this class is limited
alpar@2260:       /// to use just as template parameters for special map types. 
alpar@2260:       class ANode : public Node {
alpar@2260:       public:
alpar@2260:         typedef Node Parent;
alpar@2260: 
alpar@2260:         /// \brief Default constructor.
alpar@2260:         ///      
alpar@2260:         /// \warning The default constructor is not required to set
alpar@2260:         /// the item to some well-defined value. So you should consider it
alpar@2260:         /// as uninitialized.
alpar@2260:         ANode() {}
alpar@2260:         /// \brief Copy constructor.
alpar@2260:         ///
alpar@2260:         /// Copy constructor.
alpar@2260:         ///
alpar@2260:         ANode(const ANode &) : Parent() {}
alpar@2260:         /// \brief Invalid constructor \& conversion.
alpar@2260:         ///
alpar@2260:         /// This constructor initializes the item to be invalid.
alpar@2260:         /// \sa Invalid for more details.
alpar@2260:         ANode(Invalid) {}
alpar@2260:         /// \brief Converter from node to A-node.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each node should
alpar@2260:         /// be convertible to the represented A-node if it is it possible. 
alpar@2260:         ANode(const Node&) {}
alpar@2260:         /// \brief Assign node to A-node.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each node should
alpar@2260:         /// be convertible to the represented A-node if it is it possible. 
alpar@2260:         ANode& operator=(const Node&) { return *this; }
alpar@2260:       };
alpar@2260: 
alpar@2260:       /// \brief Helper class for B-nodes.
alpar@2260:       ///
alpar@2260:       /// This class is just a helper class for B-nodes, it is not
alpar@2260:       /// suggested to use it directly. It can be converted easily to
alpar@2260:       /// node and vice versa. The usage of this class is limited
alpar@2260:       /// to use just as template parameters for special map types. 
alpar@2260:       class BNode : public Node {
alpar@2260:       public:
alpar@2260:         typedef Node Parent;
alpar@2260: 
alpar@2260:         /// \brief Default constructor.
alpar@2260:         ///      
alpar@2260:         /// \warning The default constructor is not required to set
alpar@2260:         /// the item to some well-defined value. So you should consider it
alpar@2260:         /// as uninitialized.
alpar@2260:         BNode() {}
alpar@2260:         /// \brief Copy constructor.
alpar@2260:         ///
alpar@2260:         /// Copy constructor.
alpar@2260:         ///
alpar@2260:         BNode(const BNode &) : Parent() {}
alpar@2260:         /// \brief Invalid constructor \& conversion.
alpar@2260:         ///
alpar@2260:         /// This constructor initializes the item to be invalid.
alpar@2260:         /// \sa Invalid for more details.
alpar@2260:         BNode(Invalid) {}
alpar@2260:         /// \brief Converter from node to B-node.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each node should
alpar@2260:         /// be convertible to the represented B-node if it is it possible. 
alpar@2260:         BNode(const Node&) {}
alpar@2260:         /// \brief Assign node to B-node.
alpar@2260:         ///
alpar@2260:         /// Besides the core graph item functionality each node should
alpar@2260:         /// be convertible to the represented B-node if it is it possible. 
alpar@2260:         BNode& operator=(const Node&) { return *this; }
alpar@2260:       };
alpar@2260:       
alpar@2260:       /// \brief Gives back %true when the node is A-node.
alpar@2260:       ///
alpar@2260:       /// Gives back %true when the node is A-node.
alpar@2260:       bool aNode(const Node&) const { return false; }
alpar@2260: 
alpar@2260:       /// \brief Gives back %true when the node is B-node.
alpar@2260:       ///
alpar@2260:       /// Gives back %true when the node is B-node.
alpar@2260:       bool bNode(const Node&) const { return false; }
alpar@2260: 
alpar@2260:       /// \brief Gives back the A-node of the undirected edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the A-node of the undirected edge.
alpar@2260:       Node aNode(const UEdge&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// \brief Gives back the B-node of the undirected edge.
alpar@2260:       ///
alpar@2260:       /// Gives back the B-node of the undirected edge.
alpar@2260:       Node bNode(const UEdge&) const { return INVALID; }
alpar@2260:       
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	typedef typename _Graph::Node Node;
alpar@2260: 	typedef typename _Graph::ANode ANode;
alpar@2260: 	typedef typename _Graph::BNode BNode;
alpar@2260: 	typedef typename _Graph::Edge Edge;
alpar@2260: 	typedef typename _Graph::UEdge UEdge;
alpar@2260:       
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<BaseUGraphComponent, _Graph>();
alpar@2260: 	  checkConcept<GraphItem<'a'>, ANode>();
alpar@2260: 	  checkConcept<GraphItem<'b'>, BNode>();
alpar@2260: 	  {
alpar@2260: 	    Node n;
alpar@2260: 	    UEdge ue(INVALID);
alpar@2260:             bool b;
alpar@2260: 	    n = graph.aNode(ue);
alpar@2260: 	    n = graph.bNode(ue);
alpar@2260:             b = graph.aNode(n);
alpar@2260:             b = graph.bNode(n);
alpar@2260:             ANode an;
alpar@2260:             an = n; n = an;
alpar@2260:             BNode bn;
alpar@2260:             bn = n; n = bn;            
alpar@2260:             ignore_unused_variable_warning(b);
alpar@2260: 	  }      
alpar@2260: 	}
alpar@2260:       
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260: 
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty idable base graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core graph features
alpar@2260:     /// core id functions for the graph structure.
alpar@2260:     /// The most of the base graphs should be conform to this concept.
alpar@2260:     /// The id's are unique and immutable.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class IDableGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260: 
alpar@2260:       /// \brief Gives back an unique integer id for the Node. 
alpar@2260:       ///
alpar@2260:       /// Gives back an unique integer id for the Node. 
alpar@2260:       ///
alpar@2260:       int id(const Node&) const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the node by the unique id.
alpar@2260:       ///
alpar@2260:       /// Gives back the node by the unique id.
alpar@2260:       /// If the graph does not contain node with the given id
alpar@2260:       /// then the result of the function is undetermined. 
alpar@2260:       Node nodeFromId(int) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an unique integer id for the Edge. 
alpar@2260:       ///
alpar@2260:       /// Gives back an unique integer id for the Edge. 
alpar@2260:       ///
alpar@2260:       int id(const Edge&) const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the edge by the unique id.
alpar@2260:       ///
alpar@2260:       /// Gives back the edge by the unique id.
alpar@2260:       /// If the graph does not contain edge with the given id
alpar@2260:       /// then the result of the function is undetermined. 
alpar@2260:       Edge edgeFromId(int) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an integer greater or equal to the maximum
alpar@2260:       /// Node id.
alpar@2260:       ///
alpar@2260:       /// Gives back an integer greater or equal to the maximum Node
alpar@2260:       /// id.
alpar@2260:       int maxNodeId() const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an integer greater or equal to the maximum
alpar@2260:       /// Edge id.
alpar@2260:       ///
alpar@2260:       /// Gives back an integer greater or equal to the maximum Edge
alpar@2260:       /// id.
alpar@2260:       int maxEdgeId() const { return -1;}
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph >();
alpar@2260: 	  typename _Graph::Node node;
alpar@2260: 	  int nid = graph.id(node);
alpar@2260: 	  nid = graph.id(node);
alpar@2260: 	  node = graph.nodeFromId(nid);
alpar@2260: 	  typename _Graph::Edge edge;
alpar@2260: 	  int eid = graph.id(edge);
alpar@2260: 	  eid = graph.id(edge);
alpar@2260: 	  edge = graph.edgeFromId(eid);
alpar@2260: 
alpar@2260: 	  nid = graph.maxNodeId();
alpar@2260: 	  ignore_unused_variable_warning(nid);
alpar@2260: 	  eid = graph.maxEdgeId();
alpar@2260: 	  ignore_unused_variable_warning(eid);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty idable base undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core undirected graph features
alpar@2260:     /// core id functions for the undirected graph structure.  The
alpar@2260:     /// most of the base undirected graphs should be conform to this
alpar@2260:     /// concept.  The id's are unique and immutable.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class IDableUGraphComponent : public IDableGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260: 
alpar@2260:       using IDableGraphComponent<_Base>::id;
alpar@2260: 
alpar@2260:       /// \brief Gives back an unique integer id for the UEdge. 
alpar@2260:       ///
alpar@2260:       /// Gives back an unique integer id for the UEdge. 
alpar@2260:       ///
alpar@2260:       int id(const UEdge&) const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the undirected edge by the unique id.
alpar@2260:       ///
alpar@2260:       /// Gives back the undirected edge by the unique id.  If the
alpar@2260:       /// graph does not contain edge with the given id then the
alpar@2260:       /// result of the function is undetermined.
alpar@2260:       UEdge uEdgeFromId(int) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an integer greater or equal to the maximum
alpar@2260:       /// UEdge id.
alpar@2260:       ///
alpar@2260:       /// Gives back an integer greater or equal to the maximum UEdge
alpar@2260:       /// id.
alpar@2260:       int maxUEdgeId() const { return -1;}
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph >();
alpar@2260: 	  checkConcept<IDableGraphComponent<Base>, _Graph >();
alpar@2260: 	  typename _Graph::UEdge uedge;
alpar@2260: 	  int ueid = graph.id(uedge);
alpar@2260: 	  ueid = graph.id(uedge);
alpar@2260: 	  uedge = graph.uEdgeFromId(ueid);
alpar@2260: 	  ueid = graph.maxUEdgeId();
alpar@2260: 	  ignore_unused_variable_warning(ueid);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty idable base bipartite undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core bipartite undirected graph
alpar@2260:     /// features core id functions for the bipartite undirected graph
alpar@2260:     /// structure.  The most of the base undirected graphs should be
alpar@2260:     /// conform to this concept.
alpar@2260:     template <typename _Base = BaseBpUGraphComponent>
alpar@2260:     class IDableBpUGraphComponent : public IDableUGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260: 
alpar@2260:       using IDableUGraphComponent<_Base>::id;
alpar@2260: 
alpar@2260:       /// \brief Gives back an unique integer id for the ANode. 
alpar@2260:       ///
alpar@2260:       /// Gives back an unique integer id for the ANode. 
alpar@2260:       ///
alpar@2260:       int aNodeId(const Node&) const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the undirected edge by the unique id.
alpar@2260:       ///
alpar@2260:       /// Gives back the undirected edge by the unique id.  If the
alpar@2260:       /// graph does not contain edge with the given id then the
alpar@2260:       /// result of the function is undetermined.
alpar@2260:       Node nodeFromANodeId(int) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an integer greater or equal to the maximum
alpar@2260:       /// ANode id.
alpar@2260:       ///
alpar@2260:       /// Gives back an integer greater or equal to the maximum ANode
alpar@2260:       /// id.
alpar@2260:       int maxANodeId() const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an unique integer id for the BNode. 
alpar@2260:       ///
alpar@2260:       /// Gives back an unique integer id for the BNode. 
alpar@2260:       ///
alpar@2260:       int bNodeId(const Node&) const { return -1;}
alpar@2260: 
alpar@2260:       /// \brief Gives back the undirected edge by the unique id.
alpar@2260:       ///
alpar@2260:       /// Gives back the undirected edge by the unique id.  If the
alpar@2260:       /// graph does not contain edge with the given id then the
alpar@2260:       /// result of the function is undetermined.
alpar@2260:       Node nodeFromBNodeId(int) const { return INVALID;}
alpar@2260: 
alpar@2260:       /// \brief Gives back an integer greater or equal to the maximum
alpar@2260:       /// BNode id.
alpar@2260:       ///
alpar@2260:       /// Gives back an integer greater or equal to the maximum BNode
alpar@2260:       /// id.
alpar@2260:       int maxBNodeId() const { return -1;}
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph >();
alpar@2260: 	  checkConcept<IDableGraphComponent<Base>, _Graph >();
alpar@2260: 	  typename _Graph::Node node(INVALID);
alpar@2260: 	  int id;
alpar@2260:           id = graph.aNodeId(node);
alpar@2260:           id = graph.bNodeId(node);
alpar@2260:           node = graph.nodeFromANodeId(id);
alpar@2260:           node = graph.nodeFromBNodeId(id);
alpar@2260:           id = graph.maxANodeId();
alpar@2260:           id = graph.maxBNodeId();
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	const _Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief Skeleton class for graph NodeIt and EdgeIt
alpar@2260:     ///
alpar@2260:     /// Skeleton class for graph NodeIt and EdgeIt.
alpar@2260:     ///
alpar@2260:     template <typename _Graph, typename _Item>
alpar@2260:     class GraphItemIt : public _Item {
alpar@2260:     public:
alpar@2260:       /// \brief Default constructor.
alpar@2260:       ///
alpar@2260:       /// @warning The default constructor sets the iterator
alpar@2260:       /// to an undefined value.
alpar@2260:       GraphItemIt() {}
alpar@2260:       /// \brief Copy constructor.
alpar@2260:       ///
alpar@2260:       /// Copy constructor.
alpar@2260:       ///
alpar@2260:       GraphItemIt(const GraphItemIt& ) {}
alpar@2260:       /// \brief Sets the iterator to the first item.
alpar@2260:       ///
alpar@2260:       /// Sets the iterator to the first item of \c the graph.
alpar@2260:       ///
alpar@2260:       explicit GraphItemIt(const _Graph&) {}
alpar@2260:       /// \brief Invalid constructor \& conversion.
alpar@2260:       ///
alpar@2260:       /// This constructor initializes the item to be invalid.
alpar@2260:       /// \sa Invalid for more details.
alpar@2260:       GraphItemIt(Invalid) {}
alpar@2260:       /// \brief Assign operator for items.
alpar@2260:       ///
alpar@2260:       /// The items are assignable. 
alpar@2260:       ///
alpar@2260:       GraphItemIt& operator=(const GraphItemIt&) { return *this; }      
alpar@2260:       /// \brief Next item.
alpar@2260:       /// 
alpar@2260:       /// Assign the iterator to the next item.
alpar@2260:       ///
alpar@2260:       GraphItemIt& operator++() { return *this; }
alpar@2260:       /// \brief Equality operator
alpar@2260:       /// 
alpar@2260:       /// Two iterators are equal if and only if they point to the
alpar@2260:       /// same object or both are invalid.
alpar@2260:       bool operator==(const GraphItemIt&) const { return true;}
alpar@2260:       /// \brief Inequality operator
alpar@2260:       ///	
alpar@2260:       /// \sa operator==(Node n)
alpar@2260:       ///
alpar@2260:       bool operator!=(const GraphItemIt&) const { return true;}
alpar@2260:       
alpar@2260:       template<typename _GraphItemIt>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  _GraphItemIt it1(g);	
alpar@2260: 	  _GraphItemIt it2;
alpar@2260: 
alpar@2260: 	  it2 = ++it1;
alpar@2260: 	  ++it2 = it1;
alpar@2260: 	  ++(++it1);
alpar@2260: 
alpar@2260: 	  _Item bi = it1;
alpar@2260: 	  bi = it2;
alpar@2260: 	}
alpar@2260: 	_Graph& g;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief Skeleton class for graph InEdgeIt and OutEdgeIt
alpar@2260:     ///
alpar@2260:     /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
alpar@2260:     /// base class, the _selector is a additional template parameter. For 
alpar@2260:     /// InEdgeIt you should instantiate it with character 'i' and for 
alpar@2260:     /// OutEdgeIt with 'o'.
alpar@2260:     template <typename _Graph,
alpar@2260: 	      typename _Item = typename _Graph::Edge,
alpar@2260:               typename _Base = typename _Graph::Node, 
alpar@2260: 	      char _selector = '0'>
alpar@2260:     class GraphIncIt : public _Item {
alpar@2260:     public:
alpar@2260:       /// \brief Default constructor.
alpar@2260:       ///
alpar@2260:       /// @warning The default constructor sets the iterator
alpar@2260:       /// to an undefined value.
alpar@2260:       GraphIncIt() {}
alpar@2260:       /// \brief Copy constructor.
alpar@2260:       ///
alpar@2260:       /// Copy constructor.
alpar@2260:       ///
alpar@2260:       GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
alpar@2260:       /// \brief Sets the iterator to the first edge incoming into or outgoing 
alpar@2260:       /// from the node.
alpar@2260:       ///
alpar@2260:       /// Sets the iterator to the first edge incoming into or outgoing 
alpar@2260:       /// from the node.
alpar@2260:       ///
alpar@2260:       explicit GraphIncIt(const _Graph&, const _Base&) {}
alpar@2260:       /// \brief Invalid constructor \& conversion.
alpar@2260:       ///
alpar@2260:       /// This constructor initializes the item to be invalid.
alpar@2260:       /// \sa Invalid for more details.
alpar@2260:       GraphIncIt(Invalid) {}
alpar@2260:       /// \brief Assign operator for iterators.
alpar@2260:       ///
alpar@2260:       /// The iterators are assignable. 
alpar@2260:       ///
alpar@2260:       GraphIncIt& operator=(GraphIncIt const&) { return *this; }      
alpar@2260:       /// \brief Next item.
alpar@2260:       ///
alpar@2260:       /// Assign the iterator to the next item.
alpar@2260:       ///
alpar@2260:       GraphIncIt& operator++() { return *this; }
alpar@2260: 
alpar@2260:       /// \brief Equality operator
alpar@2260:       ///
alpar@2260:       /// Two iterators are equal if and only if they point to the
alpar@2260:       /// same object or both are invalid.
alpar@2260:       bool operator==(const GraphIncIt&) const { return true;}
alpar@2260: 
alpar@2260:       /// \brief Inequality operator
alpar@2260:       ///
alpar@2260:       /// \sa operator==(Node n)
alpar@2260:       ///
alpar@2260:       bool operator!=(const GraphIncIt&) const { return true;}
alpar@2260: 
alpar@2260:       template <typename _GraphIncIt>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<GraphItem<_selector>, _GraphIncIt>();
alpar@2260: 	  _GraphIncIt it1(graph, node);
alpar@2260: 	  _GraphIncIt it2;
alpar@2260: 
alpar@2260: 	  it2 = ++it1;
alpar@2260: 	  ++it2 = it1;
alpar@2260: 	  ++(++it1);
alpar@2260: 	  _Item e = it1;
alpar@2260: 	  e = it2;
alpar@2260: 
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Item edge;
alpar@2260: 	_Base node;
alpar@2260: 	_Graph graph;
alpar@2260: 	_GraphIncIt it;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260: 
alpar@2260:     /// \brief An empty iterable graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features
alpar@2260:     /// iterator based iterable interface for the graph structure.
alpar@2260:     /// This concept is part of the Graph concept.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class IterableGraphComponent : public _Base {
alpar@2260: 
alpar@2260:     public:
alpar@2260:     
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260: 
alpar@2260:       typedef IterableGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \name Base iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       ///
alpar@2260:       /// @{  
alpar@2260: 
alpar@2260:       /// \brief Gives back the first node in the iterating order.
alpar@2260:       ///      
alpar@2260:       /// Gives back the first node in the iterating order.
alpar@2260:       ///     
alpar@2260:       void first(Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next node in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the next node in the iterating order.
alpar@2260:       ///     
alpar@2260:       void next(Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the first edge in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the first edge in the iterating order.
alpar@2260:       ///     
alpar@2260:       void first(Edge&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next edge in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the next edge in the iterating order.
alpar@2260:       ///     
alpar@2260:       void next(Edge&) const {}
alpar@2260: 
alpar@2260: 
alpar@2260:       /// \brief Gives back the first of the edges point to the given
alpar@2260:       /// node.
alpar@2260:       ///
alpar@2260:       /// Gives back the first of the edges point to the given node.
alpar@2260:       ///     
alpar@2260:       void firstIn(Edge&, const Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next of the edges points to the given
alpar@2260:       /// node.
alpar@2260:       ///
alpar@2260:       /// Gives back the next of the edges points to the given node.
alpar@2260:       ///
alpar@2260:       void nextIn(Edge&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the first of the edges start from the
alpar@2260:       /// given node.
alpar@2260:       ///      
alpar@2260:       /// Gives back the first of the edges start from the given node.
alpar@2260:       ///     
alpar@2260:       void firstOut(Edge&, const Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next of the edges start from the given
alpar@2260:       /// node.
alpar@2260:       ///
alpar@2260:       /// Gives back the next of the edges start from the given node.
alpar@2260:       ///     
alpar@2260:       void nextOut(Edge&) const {}
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       /// \name Class based iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       ///
alpar@2260:       /// @{
alpar@2260: 
alpar@2260:       /// \brief This iterator goes through each node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes through each node.
alpar@2260:       ///
alpar@2260:       typedef GraphItemIt<Graph, Node> NodeIt;
alpar@2260: 
alpar@2260:       /// \brief This iterator goes through each node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes through each node.
alpar@2260:       ///
alpar@2260:       typedef GraphItemIt<Graph, Edge> EdgeIt;
alpar@2260: 
alpar@2260:       /// \brief This iterator goes trough the incoming edges of a node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes trough the \e inccoming edges of a certain node
alpar@2260:       /// of a graph.
alpar@2260:       typedef GraphIncIt<Graph, Edge, Node, 'i'> InEdgeIt;
alpar@2260: 
alpar@2260:       /// \brief This iterator goes trough the outgoing edges of a node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes trough the \e outgoing edges of a certain node
alpar@2260:       /// of a graph.
alpar@2260:       typedef GraphIncIt<Graph, Edge, Node, 'o'> OutEdgeIt;
alpar@2260: 
alpar@2260:       /// \brief The base node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the base node of the iterator.
alpar@2260:       /// It is always the target of the pointed edge.
alpar@2260:       Node baseNode(const InEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// \brief The running node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the running node of the iterator.
alpar@2260:       /// It is always the source of the pointed edge.
alpar@2260:       Node runningNode(const InEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// \brief The base node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the base node of the iterator.
alpar@2260:       /// It is always the source of the pointed edge.
alpar@2260:       Node baseNode(const OutEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// \brief The running node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the running node of the iterator.
alpar@2260:       /// It is always the target of the pointed edge.
alpar@2260:       Node runningNode(const OutEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph>();
alpar@2260: 
alpar@2260:           {
alpar@2260:             typename _Graph::Node node(INVALID);      
alpar@2260:             typename _Graph::Edge edge(INVALID);
alpar@2260:             {
alpar@2260:               graph.first(node);
alpar@2260:               graph.next(node);
alpar@2260:             }
alpar@2260:             {
alpar@2260:               graph.first(edge);
alpar@2260:               graph.next(edge);
alpar@2260:             }
alpar@2260:             {
alpar@2260:               graph.firstIn(edge, node);
alpar@2260:               graph.nextIn(edge);
alpar@2260:             }
alpar@2260:             {
alpar@2260:               graph.firstOut(edge, node);
alpar@2260:               graph.nextOut(edge);
alpar@2260:             }
alpar@2260:           }           
alpar@2260: 
alpar@2260:           {
alpar@2260:             checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
alpar@2260:               typename _Graph::EdgeIt >();
alpar@2260:             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
alpar@2260:               typename _Graph::NodeIt >();
alpar@2260:             checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
alpar@2260:               typename _Graph::Node, 'i'>, typename _Graph::InEdgeIt>();
alpar@2260:             checkConcept<GraphIncIt<_Graph, typename _Graph::Edge, 
alpar@2260:               typename _Graph::Node, 'o'>, typename _Graph::OutEdgeIt>();
alpar@2260: 
alpar@2260:             typename _Graph::Node n;
alpar@2260:             typename _Graph::InEdgeIt ieit(INVALID);
alpar@2260:             typename _Graph::OutEdgeIt oeit(INVALID);
alpar@2260:             n = graph.baseNode(ieit);
alpar@2260:             n = graph.runningNode(ieit);
alpar@2260:             n = graph.baseNode(oeit);
alpar@2260:             n = graph.runningNode(oeit);
alpar@2260:             ignore_unused_variable_warning(n);
alpar@2260:           }
alpar@2260:         }
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty iterable undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features iterator
alpar@2260:     /// based iterable interface for the undirected graph structure.
alpar@2260:     /// This concept is part of the UGraph concept.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class IterableUGraphComponent : public IterableGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260: 
alpar@2260:     
alpar@2260:       typedef IterableUGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \name Base iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       /// @{  
alpar@2260: 
alpar@2260:       using IterableGraphComponent<_Base>::first;
alpar@2260:       using IterableGraphComponent<_Base>::next;
alpar@2260: 
alpar@2260:       /// \brief Gives back the first undirected edge in the iterating
alpar@2260:       /// order.
alpar@2260:       ///
alpar@2260:       /// Gives back the first undirected edge in the iterating order.
alpar@2260:       ///     
alpar@2260:       void first(UEdge&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next undirected edge in the iterating
alpar@2260:       /// order.
alpar@2260:       ///
alpar@2260:       /// Gives back the next undirected edge in the iterating order.
alpar@2260:       ///     
alpar@2260:       void next(UEdge&) const {}
alpar@2260: 
alpar@2260: 
alpar@2260:       /// \brief Gives back the first of the undirected edges from the
alpar@2260:       /// given node.
alpar@2260:       ///
alpar@2260:       /// Gives back the first of the undirected edges from the given
alpar@2260:       /// node. The bool parameter gives back that direction which
alpar@2260:       /// gives a good direction of the uedge so the source of the
alpar@2260:       /// directed edge is the given node.
alpar@2260:       void firstInc(UEdge&, bool&, const Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next of the undirected edges from the
alpar@2260:       /// given node.
alpar@2260:       ///
alpar@2260:       /// Gives back the next of the undirected edges from the given
alpar@2260:       /// node. The bool parameter should be used as the \c firstInc()
alpar@2260:       /// use it.
alpar@2260:       void nextInc(UEdge&, bool&) const {}
alpar@2260: 
alpar@2260:       using IterableGraphComponent<_Base>::baseNode;
alpar@2260:       using IterableGraphComponent<_Base>::runningNode;
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       /// \name Class based iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       ///
alpar@2260:       /// @{
alpar@2260: 
alpar@2260:       /// \brief This iterator goes through each node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes through each node.
alpar@2260:       typedef GraphItemIt<Graph, UEdge> UEdgeIt;
alpar@2260:       /// \brief This iterator goes trough the incident edges of a
alpar@2260:       /// node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes trough the incident edges of a certain
alpar@2260:       /// node of a graph.
alpar@2260:       typedef GraphIncIt<Graph, UEdge, Node, 'u'> IncEdgeIt;
alpar@2260:       /// \brief The base node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the base node of the iterator.
alpar@2260:       Node baseNode(const IncEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// \brief The running node of the iterator.
alpar@2260:       ///
alpar@2260:       /// Gives back the running node of the iterator.
alpar@2260:       Node runningNode(const IncEdgeIt&) const { return INVALID; }
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<IterableGraphComponent<Base>, _Graph>();
alpar@2260: 
alpar@2260:           {
alpar@2260:             typename _Graph::Node node(INVALID);
alpar@2260:             typename _Graph::UEdge uedge(INVALID);
alpar@2260:             bool dir;
alpar@2260:             {
alpar@2260:               graph.first(uedge);
alpar@2260:               graph.next(uedge);
alpar@2260:             }
alpar@2260:             {
alpar@2260:               graph.firstInc(uedge, dir, node);
alpar@2260:               graph.nextInc(uedge, dir);
alpar@2260:             }
alpar@2260:             
alpar@2260:           }	
alpar@2260:   
alpar@2260:           {
alpar@2260:             checkConcept<GraphItemIt<_Graph, typename _Graph::UEdge>,
alpar@2260:               typename _Graph::UEdgeIt >();
alpar@2260:             checkConcept<GraphIncIt<_Graph, typename _Graph::UEdge, 
alpar@2260:               typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
alpar@2260:             
alpar@2260:             typename _Graph::Node n;
alpar@2260:             typename _Graph::IncEdgeIt ueit(INVALID);
alpar@2260:             n = graph.baseNode(ueit);
alpar@2260:             n = graph.runningNode(ueit);
alpar@2260:           }
alpar@2260:         }
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty iterable bipartite undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features iterator
alpar@2260:     /// based iterable interface for the bipartite undirected graph
alpar@2260:     /// structure. This concept is part of the BpUGraph concept.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class IterableBpUGraphComponent : public IterableUGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260:     
alpar@2260:       typedef IterableBpUGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \name Base iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       /// @{  
alpar@2260: 
alpar@2260:       using IterableUGraphComponent<_Base>::first;
alpar@2260:       using IterableUGraphComponent<_Base>::next;
alpar@2260: 
alpar@2260:       /// \brief Gives back the first A-node in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the first undirected A-node in the iterating
alpar@2260:       /// order.
alpar@2260:       ///     
alpar@2260:       void firstANode(Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next A-node in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the next A-node in the iterating order.
alpar@2260:       ///     
alpar@2260:       void nextANode(Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the first B-node in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the first undirected B-node in the iterating
alpar@2260:       /// order.
alpar@2260:       ///     
alpar@2260:       void firstBNode(Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next B-node in the iterating order.
alpar@2260:       ///
alpar@2260:       /// Gives back the next B-node in the iterating order.
alpar@2260:       ///     
alpar@2260:       void nextBNode(Node&) const {}
alpar@2260: 
alpar@2260: 
alpar@2260:       /// \brief Gives back the first of the undirected edges start
alpar@2260:       /// from the given A-node.
alpar@2260:       ///      
alpar@2260:       /// Gives back the first of the undirected edges start from the
alpar@2260:       /// given A-node.
alpar@2260:       void firstFromANode(UEdge&, const Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next of the undirected edges start
alpar@2260:       /// from the given A-node.
alpar@2260:       ///      
alpar@2260:       /// Gives back the next of the undirected edges start from the
alpar@2260:       /// given A-node.
alpar@2260:       void nextFromANode(UEdge&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the first of the undirected edges start
alpar@2260:       /// from the given B-node.
alpar@2260:       ///      
alpar@2260:       /// Gives back the first of the undirected edges start from the
alpar@2260:       /// given B-node.
alpar@2260:       void firstFromBNode(UEdge&, const Node&) const {}
alpar@2260: 
alpar@2260:       /// \brief Gives back the next of the undirected edges start
alpar@2260:       /// from the given B-node.
alpar@2260:       ///      
alpar@2260:       /// Gives back the next of the undirected edges start from the
alpar@2260:       /// given B-node.
alpar@2260:       void nextFromBNode(UEdge&) const {}
alpar@2260: 
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       /// \name Class based iteration
alpar@2260:       /// 
alpar@2260:       /// This interface provides functions for iteration on graph items
alpar@2260:       ///
alpar@2260:       /// @{
alpar@2260: 
alpar@2260:       /// \brief This iterator goes through each A-node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes through each A-node.
alpar@2260:       typedef GraphItemIt<Graph, Node> ANodeIt;
alpar@2260: 
alpar@2260:       /// \brief This iterator goes through each B-node.
alpar@2260:       ///
alpar@2260:       /// This iterator goes through each B-node.
alpar@2260:       typedef GraphItemIt<Graph, Node> BNodeIt;
alpar@2260: 
alpar@2260:       /// @}
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<IterableUGraphComponent<Base>, _Graph>();
alpar@2260: 
alpar@2260:           {
alpar@2260:             typename _Graph::Node node(INVALID);
alpar@2260:             typename _Graph::UEdge uedge(INVALID);
alpar@2260:             graph.firstANode(node);
alpar@2260:             graph.nextANode(node);
alpar@2260:             graph.firstBNode(node);
alpar@2260:             graph.nextBNode(node);
alpar@2260: 
alpar@2260:             graph.firstFromANode(uedge, node);
alpar@2260:             graph.nextFromANode(uedge);
alpar@2260:             graph.firstFromBNode(uedge, node);
alpar@2260:             graph.nextFromBNode(uedge);
alpar@2260:           }
alpar@2260:           {
alpar@2260:             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
alpar@2260:               typename _Graph::ANodeIt >();
alpar@2260:             checkConcept<GraphItemIt<_Graph, typename _Graph::Node>,
alpar@2260:               typename _Graph::BNodeIt >();
alpar@2260:           }
alpar@2260: 
alpar@2260: 	}
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty alteration notifier graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core graph features alteration
alpar@2260:     /// notifier interface for the graph structure.  This implements
alpar@2260:     /// an observer-notifier pattern for each graph item. More
alpar@2260:     /// obsevers can be registered into the notifier and whenever an
alpar@2260:     /// alteration occured in the graph all the observers will
alpar@2260:     /// notified about it.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class AlterableGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260: 
alpar@2260: 
alpar@2260:       /// The node observer registry.
alpar@2260:       typedef AlterationNotifier<AlterableGraphComponent, Node> 
alpar@2260:       NodeNotifier;
alpar@2260:       /// The edge observer registry.
alpar@2260:       typedef AlterationNotifier<AlterableGraphComponent, Edge> 
alpar@2260:       EdgeNotifier;
alpar@2260:       
alpar@2260:       /// \brief Gives back the node alteration notifier.
alpar@2260:       ///
alpar@2260:       /// Gives back the node alteration notifier.
deba@2384:       NodeNotifier& notifier(Node) const {
alpar@2260: 	return NodeNotifier();
alpar@2260:       }
alpar@2260:       
alpar@2260:       /// \brief Gives back the edge alteration notifier.
alpar@2260:       ///
alpar@2260:       /// Gives back the edge alteration notifier.
deba@2384:       EdgeNotifier& notifier(Edge) const {
alpar@2260: 	return EdgeNotifier();
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph>();
alpar@2260:           typename _Graph::NodeNotifier& nn 
deba@2384:             = graph.notifier(typename _Graph::Node());
alpar@2260: 
alpar@2260:           typename _Graph::EdgeNotifier& en 
deba@2384:             = graph.notifier(typename _Graph::Edge());
alpar@2260:           
alpar@2260:           ignore_unused_variable_warning(nn);
alpar@2260:           ignore_unused_variable_warning(en);
alpar@2260: 	}
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:       
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty alteration notifier undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core graph features alteration
alpar@2260:     /// notifier interface for the graph structure.  This implements
alpar@2260:     /// an observer-notifier pattern for each graph item. More
alpar@2260:     /// obsevers can be registered into the notifier and whenever an
alpar@2260:     /// alteration occured in the graph all the observers will
alpar@2260:     /// notified about it.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class AlterableUGraphComponent : public AlterableGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260: 
alpar@2260: 
alpar@2260:       /// The edge observer registry.
alpar@2260:       typedef AlterationNotifier<AlterableUGraphComponent, UEdge> 
alpar@2260:       UEdgeNotifier;
alpar@2260:       
alpar@2260:       /// \brief Gives back the edge alteration notifier.
alpar@2260:       ///
alpar@2260:       /// Gives back the edge alteration notifier.
deba@2384:       UEdgeNotifier& notifier(UEdge) const {
alpar@2260: 	return UEdgeNotifier();
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<AlterableGraphComponent<Base>, _Graph>();
alpar@2260:           typename _Graph::UEdgeNotifier& uen 
deba@2384:             = graph.notifier(typename _Graph::UEdge());
alpar@2260:           ignore_unused_variable_warning(uen);
alpar@2260: 	}
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:       
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty alteration notifier bipartite undirected graph
alpar@2260:     /// class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core graph features alteration
alpar@2260:     /// notifier interface for the graph structure.  This implements
alpar@2260:     /// an observer-notifier pattern for each graph item. More
alpar@2260:     /// obsevers can be registered into the notifier and whenever an
alpar@2260:     /// alteration occured in the graph all the observers will
alpar@2260:     /// notified about it.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class AlterableBpUGraphComponent : public AlterableUGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::ANode ANode;
alpar@2260:       typedef typename Base::BNode BNode;
alpar@2260: 
alpar@2260: 
alpar@2260:       /// The A-node observer registry.
alpar@2260:       typedef AlterationNotifier<AlterableBpUGraphComponent, ANode> 
alpar@2260:       ANodeNotifier;
alpar@2260: 
alpar@2260:       /// The B-node observer registry.
alpar@2260:       typedef AlterationNotifier<AlterableBpUGraphComponent, BNode> 
alpar@2260:       BNodeNotifier;
alpar@2260:       
alpar@2260:       /// \brief Gives back the A-node alteration notifier.
alpar@2260:       ///
alpar@2260:       /// Gives back the A-node alteration notifier.
deba@2384:       ANodeNotifier& notifier(ANode) const {
alpar@2260: 	return ANodeNotifier();
alpar@2260:       }
alpar@2260: 
alpar@2260:       /// \brief Gives back the B-node alteration notifier.
alpar@2260:       ///
alpar@2260:       /// Gives back the B-node alteration notifier.
deba@2384:       BNodeNotifier& notifier(BNode) const {
alpar@2260: 	return BNodeNotifier();
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph> 
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<AlterableUGraphComponent<Base>, _Graph>();
alpar@2260:           typename _Graph::ANodeNotifier& ann 
deba@2384:             = graph.notifier(typename _Graph::ANode());
alpar@2260:           typename _Graph::BNodeNotifier& bnn 
deba@2384:             = graph.notifier(typename _Graph::BNode());
alpar@2260:           ignore_unused_variable_warning(ann);
alpar@2260:           ignore_unused_variable_warning(bnn);
alpar@2260: 	}
alpar@2260: 	
alpar@2260: 	const _Graph& graph;
alpar@2260: 	
alpar@2260:       };
alpar@2260:       
alpar@2260:     };
alpar@2260: 
alpar@2260: 
alpar@2260:     /// \brief Class describing the concept of graph maps
alpar@2260:     /// 
alpar@2260:     /// This class describes the common interface of the graph maps
alpar@2260:     /// (NodeMap, EdgeMap), that is \ref maps-page "maps" which can be used to
alpar@2260:     /// associate data to graph descriptors (nodes or edges).
alpar@2260:     template <typename _Graph, typename _Item, typename _Value>
alpar@2260:     class GraphMap : public ReadWriteMap<_Item, _Value> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef ReadWriteMap<_Item, _Value> Parent;
alpar@2260: 
alpar@2260:       /// The graph type of the map.
alpar@2260:       typedef _Graph Graph;
alpar@2260:       /// The key type of the map.
alpar@2260:       typedef _Item Key;
alpar@2260:       /// The value type of the map.
alpar@2260:       typedef _Value Value;
alpar@2260: 
alpar@2260:       /// \brief Construct a new map.
alpar@2260:       ///
alpar@2260:       /// Construct a new map for the graph.
alpar@2260:       explicit GraphMap(const Graph&) {}
alpar@2260:       /// \brief Construct a new map with default value.
alpar@2260:       ///
alpar@2260:       /// Construct a new map for the graph and initalise the values.
alpar@2260:       GraphMap(const Graph&, const Value&) {}
alpar@2260:       /// \brief Copy constructor.
alpar@2260:       ///
alpar@2260:       /// Copy Constructor.
alpar@2260:       GraphMap(const GraphMap&) : Parent() {}
alpar@2260:       
alpar@2260:       /// \brief Assign operator.
alpar@2260:       ///
alpar@2260:       /// Assign operator. It does not mofify the underlying graph,
alpar@2260:       /// it just iterates on the current item set and set the  map
alpar@2260:       /// with the value returned by the assigned map. 
alpar@2260:       template <typename CMap>
alpar@2260:       GraphMap& operator=(const CMap&) { 
alpar@2260:         checkConcept<ReadMap<Key, Value>, CMap>();
alpar@2260:         return *this;
alpar@2260:       }
alpar@2260: 
alpar@2260:       template<typename _Map>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<ReadWriteMap<Key, Value>, _Map >();
alpar@2260: 	  // Construction with a graph parameter
alpar@2260: 	  _Map a(g);
alpar@2260: 	  // Constructor with a graph and a default value parameter
alpar@2260: 	  _Map a2(g,t);
alpar@2260: 	  // Copy constructor.
alpar@2260: 	  _Map b(c);
alpar@2260:           
alpar@2260:           ReadMap<Key, Value> cmap;
alpar@2260:           b = cmap;
alpar@2260: 
alpar@2260: 	  ignore_unused_variable_warning(a2);
alpar@2260: 	  ignore_unused_variable_warning(b);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	const _Map &c;
alpar@2260: 	const Graph &g;
alpar@2260: 	const typename GraphMap::Value &t;
alpar@2260:       };
alpar@2260: 
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty mappable graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features
alpar@2260:     /// map interface for the graph structure.
alpar@2260:     /// This concept is part of the Graph concept.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class MappableGraphComponent : public _Base  {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260: 
alpar@2260:       typedef MappableGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \brief ReadWrite map of the nodes.
alpar@2260:       ///
alpar@2260:       /// ReadWrite map of the nodes.
alpar@2260:       ///
alpar@2260:       template <typename _Value>
alpar@2260:       class NodeMap : public GraphMap<Graph, Node, _Value> {
alpar@2260:       private:
alpar@2260: 	NodeMap();
alpar@2260:       public:
alpar@2260:         typedef GraphMap<MappableGraphComponent, Node, _Value> Parent;
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph.
alpar@2260: 	/// \todo call the right parent class constructor
alpar@2260: 	explicit NodeMap(const MappableGraphComponent& graph) 
alpar@2260:           : Parent(graph) {}
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map with default value.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph and initalise the values.
alpar@2260: 	NodeMap(const MappableGraphComponent& graph, const _Value& value)
alpar@2260:           : Parent(graph, value) {}
alpar@2260: 
alpar@2260: 	/// \brief Copy constructor.
alpar@2260: 	///
alpar@2260: 	/// Copy Constructor.
alpar@2260: 	NodeMap(const NodeMap& nm) : Parent(nm) {}
alpar@2260: 
alpar@2260: 	/// \brief Assign operator.
alpar@2260: 	///
alpar@2260: 	/// Assign operator.
alpar@2260:         template <typename CMap>
alpar@2260:         NodeMap& operator=(const CMap&) { 
alpar@2260:           checkConcept<ReadMap<Node, _Value>, CMap>();
alpar@2260:           return *this;
alpar@2260:         }
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260:       /// \brief ReadWrite map of the edges.
alpar@2260:       ///
alpar@2260:       /// ReadWrite map of the edges.
alpar@2260:       ///
alpar@2260:       template <typename _Value>
alpar@2260:       class EdgeMap : public GraphMap<Graph, Edge, _Value> {
alpar@2260:       private:
alpar@2260: 	EdgeMap();
alpar@2260:       public:
alpar@2260:         typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph.
alpar@2260: 	/// \todo call the right parent class constructor
alpar@2260: 	explicit EdgeMap(const MappableGraphComponent& graph) 
alpar@2260:           : Parent(graph) {}
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map with default value.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph and initalise the values.
alpar@2260: 	EdgeMap(const MappableGraphComponent& graph, const _Value& value)
alpar@2260:           : Parent(graph, value) {}
alpar@2260: 
alpar@2260: 	/// \brief Copy constructor.
alpar@2260: 	///
alpar@2260: 	/// Copy Constructor.
alpar@2260: 	EdgeMap(const EdgeMap& nm) : Parent(nm) {}
alpar@2260: 
alpar@2260: 	/// \brief Assign operator.
alpar@2260: 	///
alpar@2260: 	/// Assign operator.
alpar@2260:         template <typename CMap>
alpar@2260:         EdgeMap& operator=(const CMap&) { 
alpar@2260:           checkConcept<ReadMap<Edge, _Value>, CMap>();
alpar@2260:           return *this;
alpar@2260:         }
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	struct Dummy {
alpar@2260: 	  int value;
alpar@2260: 	  Dummy() : value(0) {}
alpar@2260: 	  Dummy(int _v) : value(_v) {}
alpar@2260: 	};
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph>();
alpar@2260: 	  { // int map test
alpar@2260: 	    typedef typename _Graph::template NodeMap<int> IntNodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Node, int>, 
alpar@2260: 	      IntNodeMap >();
alpar@2260: 	  } { // bool map test
alpar@2260: 	    typedef typename _Graph::template NodeMap<bool> BoolNodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Node, bool>,
alpar@2260: 	      BoolNodeMap >();
alpar@2260: 	  } { // Dummy map test
alpar@2260: 	    typedef typename _Graph::template NodeMap<Dummy> DummyNodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Node, Dummy>,
alpar@2260: 	      DummyNodeMap >();
alpar@2260: 	  } 
alpar@2260: 
alpar@2260: 	  { // int map test
alpar@2260: 	    typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
alpar@2260: 	      IntEdgeMap >();
alpar@2260: 	  } { // bool map test
alpar@2260: 	    typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
alpar@2260: 	      BoolEdgeMap >();
alpar@2260: 	  } { // Dummy map test
alpar@2260: 	    typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>, 
alpar@2260: 	      DummyEdgeMap >();
alpar@2260: 	  } 
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty mappable base bipartite undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features
alpar@2260:     /// map interface for the graph structure.
alpar@2260:     /// This concept is part of the UGraph concept.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class MappableUGraphComponent : public MappableGraphComponent<_Base>  {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260: 
alpar@2260:       typedef MappableUGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \brief ReadWrite map of the uedges.
alpar@2260:       ///
alpar@2260:       /// ReadWrite map of the uedges.
alpar@2260:       ///
alpar@2260:       template <typename _Value>
alpar@2260:       class UEdgeMap : public GraphMap<Graph, UEdge, _Value> {  
alpar@2260:       public:
alpar@2260:         typedef GraphMap<MappableUGraphComponent, UEdge, _Value> Parent;
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph.
alpar@2260: 	/// \todo call the right parent class constructor
alpar@2260: 	explicit UEdgeMap(const MappableUGraphComponent& graph) 
alpar@2260:           : Parent(graph) {}
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map with default value.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph and initalise the values.
alpar@2260: 	UEdgeMap(const MappableUGraphComponent& graph, const _Value& value)
alpar@2260:           : Parent(graph, value) {}
alpar@2260: 
alpar@2260: 	/// \brief Copy constructor.
alpar@2260: 	///
alpar@2260: 	/// Copy Constructor.
alpar@2260: 	UEdgeMap(const UEdgeMap& nm) : Parent(nm) {}
alpar@2260: 
alpar@2260: 	/// \brief Assign operator.
alpar@2260: 	///
alpar@2260: 	/// Assign operator.
alpar@2260:         template <typename CMap>
alpar@2260:         UEdgeMap& operator=(const CMap&) { 
alpar@2260:           checkConcept<ReadMap<UEdge, _Value>, CMap>();
alpar@2260:           return *this;
alpar@2260:         }
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	struct Dummy {
alpar@2260: 	  int value;
alpar@2260: 	  Dummy() : value(0) {}
alpar@2260: 	  Dummy(int _v) : value(_v) {}
alpar@2260: 	};
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<MappableGraphComponent<Base>, _Graph>();
alpar@2260: 
alpar@2260: 	  { // int map test
alpar@2260: 	    typedef typename _Graph::template UEdgeMap<int> IntUEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, int>,
alpar@2260: 	      IntUEdgeMap >();
alpar@2260: 	  } { // bool map test
alpar@2260: 	    typedef typename _Graph::template UEdgeMap<bool> BoolUEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, bool>,
alpar@2260: 	      BoolUEdgeMap >();
alpar@2260: 	  } { // Dummy map test
alpar@2260: 	    typedef typename _Graph::template UEdgeMap<Dummy> DummyUEdgeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::UEdge, Dummy>, 
alpar@2260: 	      DummyUEdgeMap >();
alpar@2260: 	  } 
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty mappable base bipartite undirected graph
alpar@2260:     /// class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features
alpar@2260:     /// map interface for the graph structure.
alpar@2260:     /// This concept is part of the BpUGraph concept.
alpar@2260:     template <typename _Base = BaseBpUGraphComponent>
alpar@2260:     class MappableBpUGraphComponent : public MappableUGraphComponent<_Base>  {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260: 
alpar@2260:       typedef MappableBpUGraphComponent Graph;
alpar@2260: 
alpar@2260:       /// \brief ReadWrite map of the A-nodes.
alpar@2260:       ///
alpar@2260:       /// ReadWrite map of the A-nodes.
alpar@2260:       ///
alpar@2260:       template <typename _Value>
alpar@2260:       class ANodeMap : public GraphMap<Graph, Node, _Value> {  
alpar@2260:       public:
alpar@2260:         typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph.
alpar@2260: 	/// \todo call the right parent class constructor
alpar@2260: 	explicit ANodeMap(const MappableBpUGraphComponent& graph) 
alpar@2260:           : Parent(graph) {}
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map with default value.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph and initalise the values.
alpar@2260: 	ANodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
alpar@2260:           : Parent(graph, value) {}
alpar@2260: 
alpar@2260: 	/// \brief Copy constructor.
alpar@2260: 	///
alpar@2260: 	/// Copy Constructor.
alpar@2260: 	ANodeMap(const ANodeMap& nm) : Parent(nm) {}
alpar@2260: 
alpar@2260: 	/// \brief Assign operator.
alpar@2260: 	///
alpar@2260: 	/// Assign operator.
alpar@2260:         template <typename CMap>
alpar@2260:         ANodeMap& operator=(const CMap&) { 
alpar@2260:           checkConcept<ReadMap<Node, _Value>, CMap>();
alpar@2260:           return *this;
alpar@2260:         }
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260:       /// \brief ReadWrite map of the B-nodes.
alpar@2260:       ///
alpar@2260:       /// ReadWrite map of the A-nodes.
alpar@2260:       ///
alpar@2260:       template <typename _Value>
alpar@2260:       class BNodeMap : public GraphMap<Graph, Node, _Value> {  
alpar@2260:       public:
alpar@2260:         typedef GraphMap<MappableBpUGraphComponent, Node, _Value> Parent;
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph.
alpar@2260: 	/// \todo call the right parent class constructor
alpar@2260: 	explicit BNodeMap(const MappableBpUGraphComponent& graph) 
alpar@2260:           : Parent(graph) {}
alpar@2260: 
alpar@2260: 	/// \brief Construct a new map with default value.
alpar@2260: 	///
alpar@2260: 	/// Construct a new map for the graph and initalise the values.
alpar@2260: 	BNodeMap(const MappableBpUGraphComponent& graph, const _Value& value)
alpar@2260:           : Parent(graph, value) {}
alpar@2260: 
alpar@2260: 	/// \brief Copy constructor.
alpar@2260: 	///
alpar@2260: 	/// Copy Constructor.
alpar@2260: 	BNodeMap(const BNodeMap& nm) : Parent(nm) {}
alpar@2260: 
alpar@2260: 	/// \brief Assign operator.
alpar@2260: 	///
alpar@2260: 	/// Assign operator.
alpar@2260:         template <typename CMap>
alpar@2260:         BNodeMap& operator=(const CMap&) { 
alpar@2260:           checkConcept<ReadMap<Node, _Value>, CMap>();
alpar@2260:           return *this;
alpar@2260:         }
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 
alpar@2260: 	struct Dummy {
alpar@2260: 	  int value;
alpar@2260: 	  Dummy() : value(0) {}
alpar@2260: 	  Dummy(int _v) : value(_v) {}
alpar@2260: 	};
alpar@2260: 
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<MappableUGraphComponent<Base>, _Graph>();
alpar@2260: 
alpar@2260: 	  { // int map test
alpar@2260: 	    typedef typename _Graph::template ANodeMap<int> IntANodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, int>,
alpar@2260: 	      IntANodeMap >();
alpar@2260: 	  } { // bool map test
alpar@2260: 	    typedef typename _Graph::template ANodeMap<bool> BoolANodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, bool>,
alpar@2260: 	      BoolANodeMap >();
alpar@2260: 	  } { // Dummy map test
alpar@2260: 	    typedef typename _Graph::template ANodeMap<Dummy> DummyANodeMap;
alpar@2260: 	    checkConcept<GraphMap<_Graph, typename _Graph::ANode, Dummy>, 
alpar@2260: 	      DummyANodeMap >();
alpar@2260: 	  } 
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260: 
alpar@2260:     /// \brief An empty extendable graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features graph
alpar@2260:     /// extendable interface for the graph structure.  The main
alpar@2260:     /// difference between the base and this interface is that the
alpar@2260:     /// graph alterations should handled already on this level.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class ExtendableGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       typedef typename _Base::Node Node;
alpar@2260:       typedef typename _Base::Edge Edge;
alpar@2260: 
alpar@2260:       /// \brief Adds a new node to the graph.
alpar@2260:       ///
alpar@2260:       /// Adds a new node to the graph.
alpar@2260:       ///
alpar@2260:       Node addNode() {
alpar@2260: 	return INVALID;
alpar@2260:       }
alpar@2260:     
alpar@2260:       /// \brief Adds a new edge connects the given two nodes.
alpar@2260:       ///
alpar@2260:       /// Adds a new edge connects the the given two nodes.
alpar@2260:       Edge addEdge(const Node&, const Node&) {
alpar@2260: 	return INVALID;
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<Base, _Graph>();
alpar@2260: 	  typename _Graph::Node node_a, node_b;
alpar@2260: 	  node_a = graph.addNode();
alpar@2260: 	  node_b = graph.addNode();
alpar@2260: 	  typename _Graph::Edge edge;
alpar@2260: 	  edge = graph.addEdge(node_a, node_b);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty extendable base undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core undirected graph features
alpar@2260:     /// core undircted graph extend interface for the graph structure.
alpar@2260:     /// The main difference between the base and this interface is
alpar@2260:     /// that the graph alterations should handled already on this
alpar@2260:     /// level.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class ExtendableUGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename _Base::Node Node;
alpar@2260:       typedef typename _Base::UEdge UEdge;
alpar@2260: 
alpar@2260:       /// \brief Adds a new node to the graph.
alpar@2260:       ///
alpar@2260:       /// Adds a new node to the graph.
alpar@2260:       ///
alpar@2260:       Node addNode() {
alpar@2260: 	return INVALID;
alpar@2260:       }
alpar@2260:     
alpar@2260:       /// \brief Adds a new edge connects the given two nodes.
alpar@2260:       ///
alpar@2260:       /// Adds a new edge connects the the given two nodes.
alpar@2260:       UEdge addEdge(const Node&, const Node&) {
alpar@2260: 	return INVALID;
alpar@2260:       }
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260: 	  checkConcept<Base, _Graph>();
alpar@2260: 	  typename _Graph::Node node_a, node_b;
alpar@2260: 	  node_a = graph.addNode();
alpar@2260: 	  node_b = graph.addNode();
alpar@2260: 	  typename _Graph::UEdge uedge;
alpar@2260: 	  uedge = graph.addUEdge(node_a, node_b);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty extendable base undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core bipartite undirected graph
alpar@2260:     /// features core undircted graph extend interface for the graph
alpar@2260:     /// structure.  The main difference between the base and this
alpar@2260:     /// interface is that the graph alterations should handled already
alpar@2260:     /// on this level.
alpar@2260:     template <typename _Base = BaseBpUGraphComponent>
alpar@2260:     class ExtendableBpUGraphComponent 
alpar@2260:       : public ExtendableUGraphComponent<_Base> {
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<ExtendableUGraphComponent<Base>, _Graph>();
alpar@2260: 	}
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty erasable graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core graph features core erase
alpar@2260:     /// functions for the graph structure. The main difference between
alpar@2260:     /// the base and this interface is that the graph alterations
alpar@2260:     /// should handled already on this level.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class ErasableGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::Edge Edge;
alpar@2260: 
alpar@2260:       /// \brief Erase a node from the graph.
alpar@2260:       ///
alpar@2260:       /// Erase a node from the graph. This function should 
alpar@2260:       /// erase all edges connecting to the node.
alpar@2260:       void erase(const Node&) {}    
alpar@2260: 
alpar@2260:       /// \brief Erase an edge from the graph.
alpar@2260:       ///
alpar@2260:       /// Erase an edge from the graph.
alpar@2260:       ///
alpar@2260:       void erase(const Edge&) {}
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<Base, _Graph>();
alpar@2260: 	  typename _Graph::Node node;
alpar@2260: 	  graph.erase(node);
alpar@2260: 	  typename _Graph::Edge edge;
alpar@2260: 	  graph.erase(edge);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty erasable base undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core undirected graph features
alpar@2260:     /// core erase functions for the undirceted graph structure. The
alpar@2260:     /// main difference between the base and this interface is that
alpar@2260:     /// the graph alterations should handled already on this level.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
alpar@2260:     class ErasableUGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260:       typedef typename Base::Node Node;
alpar@2260:       typedef typename Base::UEdge UEdge;
alpar@2260: 
alpar@2260:       /// \brief Erase a node from the graph.
alpar@2260:       ///
alpar@2260:       /// Erase a node from the graph. This function should erase
alpar@2260:       /// edges connecting to the node.
alpar@2260:       void erase(const Node&) {}    
alpar@2260: 
alpar@2260:       /// \brief Erase an edge from the graph.
alpar@2260:       ///
alpar@2260:       /// Erase an edge from the graph.
alpar@2260:       ///
alpar@2260:       void erase(const UEdge&) {}
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<Base, _Graph>();
alpar@2260: 	  typename _Graph::Node node;
alpar@2260: 	  graph.erase(node);
alpar@2260: 	  typename _Graph::Edge edge;
alpar@2260: 	  graph.erase(edge);
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph& graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty erasable base bipartite undirected graph class.
alpar@2260:     ///  
alpar@2260:     /// This class provides beside the core bipartite undirected graph
alpar@2260:     /// features core erase functions for the undirceted graph
alpar@2260:     /// structure. The main difference between the base and this
alpar@2260:     /// interface is that the graph alterations should handled already
alpar@2260:     /// on this level.
alpar@2260:     template <typename _Base = BaseBpUGraphComponent>
alpar@2260:     class ErasableBpUGraphComponent : public ErasableUGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<ErasableUGraphComponent<Base>, _Graph>();
alpar@2260: 	}
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty clearable base graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core graph features core clear
alpar@2260:     /// functions for the graph structure. The main difference between
alpar@2260:     /// the base and this interface is that the graph alterations
alpar@2260:     /// should handled already on this level.
alpar@2260:     template <typename _Base = BaseGraphComponent>
alpar@2260:     class ClearableGraphComponent : public _Base {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       /// \brief Erase all nodes and edges from the graph.
alpar@2260:       ///
alpar@2260:       /// Erase all nodes and edges from the graph.
alpar@2260:       ///
alpar@2260:       void clear() {}    
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<Base, _Graph>();
alpar@2260: 	  graph.clear();
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty clearable base undirected graph class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core undirected graph features
alpar@2260:     /// core clear functions for the undirected graph structure. The
alpar@2260:     /// main difference between the base and this interface is that
alpar@2260:     /// the graph alterations should handled already on this level.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
deba@2351:     class ClearableUGraphComponent : public ClearableGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<ClearableUGraphComponent<Base>, _Graph>();
alpar@2260: 	}
alpar@2260: 
alpar@2260: 	_Graph graph;
alpar@2260:       };
alpar@2260:     };
alpar@2260: 
alpar@2260:     /// \brief An empty clearable base bipartite undirected graph
alpar@2260:     /// class.
alpar@2260:     ///
alpar@2260:     /// This class provides beside the core bipartite undirected graph
alpar@2260:     /// features core clear functions for the undirected graph
alpar@2260:     /// structure. The main difference between the base and this
alpar@2260:     /// interface is that the graph alterations should handled already
alpar@2260:     /// on this level.
alpar@2260:     template <typename _Base = BaseUGraphComponent>
deba@2351:     class ClearableBpUGraphComponent : public ClearableUGraphComponent<_Base> {
alpar@2260:     public:
alpar@2260: 
alpar@2260:       typedef _Base Base;
alpar@2260: 
alpar@2260:       template <typename _Graph>
alpar@2260:       struct Constraints {
alpar@2260: 	void constraints() {
alpar@2260:           checkConcept<ClearableBpUGraphComponent<Base>, _Graph>();
alpar@2260: 	}
alpar@2260: 
alpar@2260:       };
alpar@2260: 
alpar@2260:     };
alpar@2260: 
alpar@2260:   }
alpar@2260: 
alpar@2260: }
alpar@2260: 
alpar@2260: #endif