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