klao@959: /* -*- C++ -*- klao@959: * src/lemon/concept/graph_component.h - Part of LEMON, a generic C++ optimization library klao@959: * klao@959: * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport klao@959: * (Egervary Combinatorial Optimization Research Group, EGRES). klao@959: * klao@959: * Permission to use, modify and distribute this software is granted klao@959: * provided that this copyright notice appears in all copies. For klao@959: * precise terms see the accompanying LICENSE file. klao@959: * klao@959: * This software is provided "AS IS" with no warranty of any kind, klao@959: * express or implied, and with no claim as to its suitability for any klao@959: * purpose. klao@959: * klao@959: */ klao@959: klao@1030: ///\ingroup graph_concepts klao@959: ///\file klao@959: ///\brief The graph components. klao@959: klao@959: klao@959: #ifndef LEMON_CONCEPT_GRAPH_COMPONENT_H klao@959: #define LEMON_CONCEPT_GRAPH_COMPONENT_H klao@959: klao@959: #include klao@959: #include klao@959: klao@959: namespace lemon { klao@959: namespace concept { klao@959: klao@1030: /// \addtogroup graph_concepts klao@1030: /// @{ klao@961: klao@961: /**************** Graph iterator concepts ****************/ klao@961: klao@1030: /// Skeleton class for graph Node and Edge types klao@961: klao@1030: /// This class describes the interface of Node and Edge (and UndirEdge klao@1030: /// in undirected graphs) subtypes of graph types. klao@1030: /// klao@1030: /// \note This class is a template class so that we can use it to klao@1030: /// create graph skeleton classes. The reason for this is than Node klao@1030: /// and Edge types should \em not derive from the same base class. klao@1030: /// For Node you should instantiate it with character 'n' and for Edge klao@1030: /// with 'e'. klao@961: klao@1030: #ifndef DOXYGEN klao@1030: template klao@1030: #endif klao@961: class GraphItem { klao@961: public: deba@989: /// Default constructor. deba@989: klao@1030: /// \warning The default constructor is not required to set klao@1030: /// the item to some well-defined value. So you should consider it klao@1030: /// as uninitialized. klao@961: GraphItem() {} deba@989: /// Copy constructor. deba@989: deba@989: /// Copy constructor. deba@989: /// deba@989: GraphItem(GraphItem const&) {} deba@989: /// Invalid constructor \& conversion. deba@989: deba@989: /// This constructor initializes the item to be invalid. deba@989: /// \sa Invalid for more details. klao@961: GraphItem(Invalid) {} deba@989: /// Assign operator for nodes. klao@961: deba@989: /// The nodes are assignable. deba@989: /// klao@961: GraphItem& operator=(GraphItem const&) { return *this; } deba@989: /// Equality operator. deba@989: deba@989: /// Two iterators are equal if and only if they represents the deba@989: /// same node in the graph or both are invalid. klao@961: bool operator==(GraphItem) const { return false; } deba@989: /// Inequality operator. deba@989: deba@989: /// \sa operator==(const Node& n) deba@989: /// klao@961: bool operator!=(GraphItem) const { return false; } klao@961: klao@1030: /// Artificial ordering operator. deba@989: klao@1030: /// To allow the use of graph descriptors as key type in std::map or klao@1030: /// similar associative container we require this. klao@1030: /// klao@1030: /// \note This operator only have to define some strict ordering of klao@1030: /// the items; this order has nothing to do with the iteration klao@1030: /// ordering of the items. klao@1030: /// klao@1030: /// \bug This is a technical requirement. Do we really need this? klao@1030: bool operator<(GraphItem) const { return false; } deba@989: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: _GraphItem i1; deba@989: _GraphItem i2 = i1; deba@989: _GraphItem i3 = INVALID; deba@989: deba@989: i1 = i2 = i3; deba@989: deba@989: bool b; deba@989: // b = (ia == ib) && (ia != ib) && (ia < ib); deba@989: b = (ia == ib) && (ia != ib); deba@989: b = (ia == INVALID) && (ib != INVALID); klao@1030: b = (ia < ib); deba@989: } deba@989: deba@989: const _GraphItem &ia; deba@989: const _GraphItem &ib; deba@989: }; klao@961: }; klao@961: klao@1030: /// A type describing the concept of graph node klao@1030: klao@1030: /// This is an instantiation of \ref GraphItem which can be used as a klao@1030: /// Node subtype in graph skeleton definitions klao@1030: typedef GraphItem<'n'> GraphNode; klao@1030: klao@1030: /// A type describing the concept of graph edge klao@1030: klao@1030: /// This is an instantiation of \ref GraphItem which can be used as a klao@1030: /// Edge subtype in graph skeleton definitions klao@1030: typedef GraphItem<'e'> GraphEdge; klao@1030: klao@1030: klao@1030: /**************** Basic features of graphs ****************/ klao@1030: klao@959: /// An empty base graph class. klao@959: klao@961: /// This class provides the minimal set of features needed for a graph klao@961: /// structure. All graph concepts have to be conform to this base klao@961: /// graph. klao@961: /// klao@961: /// \bug This is not true. The minimal graph concept is the klao@961: /// BaseIterableGraphComponent. klao@959: klao@959: class BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef BaseGraphComponent Graph; klao@959: klao@959: /// Node class of the graph. klao@959: klao@959: /// This class represents the Nodes of the graph. klao@959: /// deba@989: typedef GraphItem<'n'> Node; klao@959: klao@959: /// Edge class of the graph. klao@959: klao@959: /// This class represents the Edges of the graph. klao@959: /// deba@989: typedef GraphItem<'e'> Edge; klao@959: alpar@986: ///Gives back the target node of an edge. klao@959: alpar@986: ///Gives back the target node of an edge. klao@959: /// alpar@986: Node target(const Edge&) const { return INVALID;} klao@959: alpar@986: ///Gives back the source node of an edge. klao@959: alpar@986: ///Gives back the source node of an edge. klao@959: /// alpar@986: Node source(const Edge&) const { return INVALID;} klao@959: klao@961: deba@989: template deba@989: struct Constraints { deba@989: typedef typename _Graph::Node Node; deba@989: typedef typename _Graph::Edge Edge; klao@959: deba@989: void constraints() { deba@989: checkConcept, Node>(); deba@989: checkConcept, Edge>(); deba@989: { deba@989: Node n; deba@989: Edge e; deba@989: n = graph.source(e); deba@989: n = graph.target(e); deba@989: } deba@989: } klao@959: deba@989: const _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: /// An empty iterable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core iterable interface for the graph structure. klao@959: /// Most of the base graphs should be conform to this concept. klao@959: klao@959: class BaseIterableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: /// Gives back the first Node in the iterating order. klao@959: klao@959: /// Gives back the first Node in the iterating order. klao@959: /// klao@959: void first(Node&) const {} klao@959: klao@959: /// Gives back the next Node in the iterating order. klao@959: klao@959: /// Gives back the next Node in the iterating order. klao@959: /// klao@959: void next(Node&) const {} klao@959: klao@959: /// Gives back the first Edge in the iterating order. klao@959: klao@959: /// Gives back the first Edge in the iterating order. klao@959: /// klao@959: void first(Edge&) const {} klao@959: /// Gives back the next Edge in the iterating order. klao@959: klao@959: /// Gives back the next Edge in the iterating order. klao@959: /// klao@959: void next(Edge&) const {} klao@959: klao@959: klao@959: /// Gives back the first of the Edges point to the given Node. klao@959: klao@959: /// Gives back the first of the Edges point to the given Node. klao@959: /// klao@959: void firstIn(Edge&, const Node&) const {} klao@959: klao@959: /// Gives back the next of the Edges points to the given Node. klao@959: klao@959: klao@959: /// Gives back the next of the Edges points to the given Node. klao@959: /// klao@959: void nextIn(Edge&) const {} klao@959: klao@959: /// Gives back the first of the Edges start from the given Node. klao@959: klao@959: /// Gives back the first of the Edges start from the given Node. klao@959: /// klao@959: void firstOut(Edge&, const Node&) const {} klao@959: klao@959: /// Gives back the next of the Edges start from the given Node. klao@959: klao@959: /// Gives back the next of the Edges start from the given Node. klao@959: /// klao@959: void nextOut(Edge&) const {} klao@959: klao@959: deba@989: template deba@989: struct Constraints { deba@989: deba@989: void constraints() { deba@989: checkConcept< BaseGraphComponent, _Graph >(); deba@989: typename _Graph::Node node; deba@989: typename _Graph::Edge edge; deba@989: { deba@989: graph.first(node); deba@989: graph.next(node); deba@989: } deba@989: { deba@989: graph.first(edge); deba@989: graph.next(edge); deba@989: } deba@989: { deba@989: graph.firstIn(edge, node); deba@989: graph.nextIn(edge); deba@989: } deba@989: { deba@989: graph.firstOut(edge, node); deba@989: graph.nextOut(edge); deba@989: } deba@989: } klao@959: deba@989: const _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: /// An empty idable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core id functions for the graph structure. klao@959: /// The most of the base graphs should be conform to this concept. klao@959: /// The id's are unique and immutable. klao@959: class IDableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: /// Gives back an unique integer id for the Node. klao@959: klao@959: /// Gives back an unique integer id for the Node. klao@959: /// klao@959: int id(const Node&) const { return -1;} klao@959: klao@959: /// Gives back an unique integer id for the Edge. klao@959: klao@959: /// Gives back an unique integer id for the Edge. klao@959: /// klao@959: int id(const Edge&) const { return -1;} klao@959: deba@989: template deba@989: struct Constraints { klao@959: deba@989: void constraints() { deba@989: checkConcept< BaseGraphComponent, _Graph >(); deba@989: typename _Graph::Node node; deba@989: int nid = graph.id(node); deba@989: nid = graph.id(node); deba@989: typename _Graph::Edge edge; deba@989: int eid = graph.id(edge); deba@989: eid = graph.id(edge); deba@989: } klao@959: deba@989: const _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: klao@959: /// An empty max-idable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core max id functions for the graph structure. klao@959: /// The most of the base graphs should be conform to this concept. klao@959: /// The id's are unique and immutable. klao@959: class MaxIDableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: /// Gives back an integer greater or equal to the maximum Node id. klao@959: klao@959: /// Gives back an integer greater or equal to the maximum Node id. klao@959: /// deba@980: int maxId(Node = INVALID) const { return -1;} klao@959: klao@959: /// Gives back an integer greater or equal to the maximum Edge id. klao@959: klao@959: /// Gives back an integer greater or equal to the maximum Edge id. klao@959: /// deba@980: int maxId(Edge = INVALID) const { return -1;} klao@959: deba@989: template deba@989: struct Constraints { klao@959: deba@989: void constraints() { deba@989: checkConcept(); deba@989: int nid = graph.maxId(typename _Graph::Node()); deba@989: ignore_unused_variable_warning(nid); deba@989: int eid = graph.maxId(typename _Graph::Edge()); deba@989: ignore_unused_variable_warning(eid); deba@989: } deba@989: deba@989: const _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: /// An empty extendable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core graph extend interface for the graph structure. klao@959: /// The most of the base graphs should be conform to this concept. klao@959: class BaseExtendableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: /// Adds a new Node to the graph. klao@959: klao@959: /// Adds a new Node to the graph. klao@959: /// klao@959: Node addNode() { klao@959: return INVALID; klao@959: } klao@959: klao@959: /// Adds a new Edge connects the two Nodes to the graph. klao@959: klao@959: /// Adds a new Edge connects the two Nodes to the graph. klao@959: /// klao@959: Edge addEdge(const Node& from, const Node& to) { klao@959: return INVALID; klao@959: } klao@959: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept(); deba@989: typename _Graph::Node node_a, node_b; deba@989: node_a = graph.addNode(); deba@989: typename _Graph::Edge edge; deba@989: edge = graph.addEdge(node_a, node_b); deba@989: } klao@959: deba@989: _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: /// An empty erasable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core erase functions for the graph structure. klao@959: /// The most of the base graphs should be conform to this concept. klao@959: class BaseErasableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: /// Erase a Node from the graph. klao@959: klao@959: /// Erase a Node from the graph. This function should not klao@959: /// erase edges connecting to the Node. klao@959: void erase(const Node&) {} klao@959: klao@959: /// Erase an Edge from the graph. klao@959: klao@959: /// Erase an Edge from the graph. klao@959: /// klao@959: void erase(const Edge&) {} klao@959: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept(); deba@989: typename _Graph::Node node; deba@989: graph.erase(node); deba@989: typename _Graph::Edge edge; deba@989: graph.erase(edge); deba@989: } klao@959: deba@989: _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@959: /// An empty clearable base graph class. klao@959: klao@959: /// This class provides beside the core graph features klao@959: /// core clear functions for the graph structure. klao@959: /// The most of the base graphs should be conform to this concept. klao@1022: class ClearableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: /// Erase all the Nodes and Edges from the graph. klao@959: klao@959: /// Erase all the Nodes and Edges from the graph. klao@959: /// klao@959: void clear() {} deba@989: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { klao@1022: checkConcept(); deba@989: graph.clear(); deba@989: } deba@989: klao@1022: _Graph graph; deba@989: }; klao@959: }; klao@959: klao@959: deba@989: /// Skeleton class for graph NodeIt and EdgeIt deba@989: deba@989: /// Skeleton class for graph NodeIt and EdgeIt. klao@959: /// deba@989: template deba@989: class GraphIterator : public _Item { deba@989: public: deba@989: /// \todo Don't we need the Item type as typedef? klao@959: deba@989: /// Default constructor. deba@989: deba@989: /// @warning The default constructor sets the iterator deba@989: /// to an undefined value. deba@989: GraphIterator() {} deba@989: /// Copy constructor. deba@989: deba@989: /// Copy constructor. deba@989: /// deba@989: GraphIterator(GraphIterator const&) {} deba@989: /// Sets the iterator to the first item. deba@989: deba@989: /// Sets the iterator to the first item of \c the graph. deba@989: /// deba@989: explicit GraphIterator(const _Graph&) {} deba@989: /// Invalid constructor \& conversion. deba@989: deba@989: /// This constructor initializes the item to be invalid. deba@989: /// \sa Invalid for more details. deba@989: GraphIterator(Invalid) {} deba@989: /// Assign operator for items. deba@989: deba@989: /// The items are assignable. deba@989: /// deba@989: GraphIterator& operator=(GraphIterator const&) { return *this; } deba@989: /// Next item. deba@989: deba@989: /// Assign the iterator to the next item. deba@989: /// deba@989: GraphIterator& operator++() { return *this; } deba@989: // Node operator*() const { return INVALID; } deba@989: /// Equality operator deba@989: deba@989: /// Two iterators are equal if and only if they point to the deba@989: /// same object or both are invalid. deba@989: bool operator==(const GraphIterator&) const { return true;} deba@989: /// Inequality operator deba@989: deba@989: /// \sa operator==(Node n) deba@989: /// deba@989: bool operator!=(const GraphIterator&) const { return true;} deba@989: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: // checkConcept< Item, _GraphIterator >(); deba@989: _GraphIterator it1(g); deba@989: deba@989: /// \todo Do we need NodeIt(Node) kind of constructor? deba@989: // _GraphIterator it2(bj); deba@989: _GraphIterator it2; deba@989: deba@989: it2 = ++it1; deba@989: ++it2 = it1; deba@989: ++(++it1); deba@989: /// \bug This should be: is_base_and_derived deba@989: _Item bi = it1; deba@989: bi = it2; deba@989: } deba@989: _Graph& g; deba@989: }; klao@959: }; klao@959: deba@989: /// Skeleton class for graph InEdgeIt and OutEdgeIt klao@959: deba@989: /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same deba@989: /// base class, the _selector is a additional template parameter. For deba@989: /// InEdgeIt you should instantiate it with character 'i' and for deba@989: /// OutEdgeIt with 'o'. klao@1021: /// \todo Is this a good name for this concept? klao@1021: template klao@1021: class GraphIncIterator : public Edge { deba@989: public: deba@989: /// Default constructor. deba@989: deba@989: /// @warning The default constructor sets the iterator deba@989: /// to an undefined value. klao@1021: GraphIncIterator() {} deba@989: /// Copy constructor. deba@989: deba@989: /// Copy constructor. deba@989: /// klao@1021: GraphIncIterator(GraphIncIterator const&) {} deba@989: /// Sets the iterator to the first edge incoming into or outgoing from the node. deba@989: deba@989: /// Sets the iterator to the first edge incoming into or outgoing from the node. deba@989: /// klao@1021: explicit GraphIncIterator(const Graph&, const typename Graph::Node&) {} deba@989: /// Invalid constructor \& conversion. deba@989: deba@989: /// This constructor initializes the item to be invalid. deba@989: /// \sa Invalid for more details. klao@1021: GraphIncIterator(Invalid) {} deba@989: /// Assign operator for nodes. deba@989: deba@989: /// The nodes are assignable. deba@989: /// klao@1021: GraphIncIterator& operator=(GraphIncIterator const&) { return *this; } deba@989: /// Next edge. deba@989: deba@989: /// Assign the iterator to the next node. deba@989: /// klao@1021: GraphIncIterator& operator++() { return *this; } klao@1021: deba@989: // Node operator*() const { return INVALID; } klao@1021: deba@989: /// Equality operator deba@989: deba@989: /// Two iterators are equal if and only if they point to the deba@989: /// same object or both are invalid. klao@1021: bool operator==(const GraphIncIterator&) const { return true;} klao@1021: deba@989: /// Inequality operator deba@989: deba@989: /// \sa operator==(Node n) deba@989: /// klao@1021: bool operator!=(const GraphIncIterator&) const { return true;} deba@989: klao@1021: template deba@989: struct Constraints { klao@1021: typedef typename Graph::Node Node; deba@989: void constraints() { klao@1021: checkConcept, _GraphIncIterator>(); klao@1021: _GraphIncIterator it1(graph, node); deba@989: /// \todo Do we need OutEdgeIt(Edge) kind of constructor? klao@1021: // _GraphIncIterator it2(edge); klao@1021: _GraphIncIterator it2; deba@989: deba@989: it2 = ++it1; deba@989: ++it2 = it1; deba@989: ++(++it1); deba@989: Edge e = it1; deba@989: e = it2; deba@989: } deba@989: deba@989: Edge& edge; deba@989: Node& node; klao@1021: Graph& graph; deba@989: }; deba@989: }; klao@1021: klao@1021: deba@989: /// An empty iterable base graph class. deba@989: deba@989: /// This class provides beside the core graph features deba@989: /// iterator based iterable interface for the graph structure. deba@989: /// This concept is part of the StaticGraphConcept. deba@989: class IterableGraphComponent : virtual public BaseGraphComponent { klao@959: klao@959: public: klao@959: klao@959: typedef IterableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: deba@989: /// This iterator goes through each node. klao@959: deba@989: /// This iterator goes through each node. deba@989: /// deba@989: typedef GraphIterator NodeIt; deba@989: /// This iterator goes through each node. klao@959: deba@989: /// This iterator goes through each node. deba@989: /// deba@989: typedef GraphIterator EdgeIt; deba@989: /// This iterator goes trough the incoming edges of a node. klao@959: deba@989: /// This iterator goes trough the \e inccoming edges of a certain node deba@989: /// of a graph. klao@1021: typedef GraphIncIterator InEdgeIt; deba@989: /// This iterator goes trough the outgoing edges of a node. klao@959: deba@989: /// This iterator goes trough the \e outgoing edges of a certain node deba@989: /// of a graph. klao@1021: typedef GraphIncIterator OutEdgeIt; deba@989: }; deba@989: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept< BaseGraphComponent, _Graph>(); klao@959: deba@989: checkConcept, typename _Graph::EdgeIt >(); deba@989: checkConcept, typename _Graph::NodeIt >(); klao@1021: checkConcept, typename _Graph::InEdgeIt >(); klao@1021: checkConcept, typename _Graph::OutEdgeIt >(); deba@989: } deba@989: }; klao@959: klao@959: klao@1030: /// Class describing the concept of graph maps klao@1030: klao@1030: /// This class describes the common interface of the graph maps alpar@1043: /// (NodeMap, EdgeMap), that is \ref maps-pages "maps" which can be used to klao@1030: /// associate data to graph descriptors (nodes or edges). deba@989: template deba@989: class GraphMap : public ReadWriteMap { deba@989: protected: deba@989: GraphMap() {} deba@989: public: deba@989: explicit GraphMap(const Graph&) {} deba@989: GraphMap(const Graph&, const _Value&) {} deba@989: GraphMap(const GraphMap&) {} deba@989: deba@989: GraphMap& operator=(const GraphMap&) { return *this;} klao@959: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept, _Map >(); deba@989: // Construction with a graph parameter deba@989: _Map a(g); deba@989: // Constructor with a graph and a default value parameter deba@989: _Map a2(g,t); deba@989: // Copy constructor. Do we need it? deba@989: _Map b=c; deba@989: // Copy operator. Do we need it? deba@989: a=b; klao@959: deba@989: ignore_unused_variable_warning(a2); deba@989: } klao@959: deba@989: const _Map &c; deba@989: const Graph &g; deba@989: const typename GraphMap::Value &t; klao@959: }; klao@959: klao@959: }; klao@961: deba@989: /// An empty mappable base graph class. klao@959: deba@989: /// This class provides beside the core graph features deba@989: /// map interface for the graph structure. deba@989: /// This concept is part of the StaticGraphConcept. klao@959: class MappableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef MappableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: deba@989: /// ReadWrite map of the nodes. deba@989: deba@989: /// ReadWrite map of the nodes. deba@989: /// alpar@987: template deba@989: class NodeMap : public GraphMap { deba@989: private: deba@989: NodeMap(); klao@959: public: deba@989: // \todo call the right parent class constructor deba@989: explicit NodeMap(const Graph&) {} alpar@987: NodeMap(const Graph&, const _Value&) {} klao@959: NodeMap(const NodeMap&) {} klao@959: klao@959: NodeMap& operator=(const NodeMap&) { return *this;} deba@989: klao@959: }; klao@959: deba@989: /// ReadWrite map of the edges. deba@989: deba@989: /// ReadWrite map of the edges. deba@989: /// alpar@987: template deba@989: class EdgeMap : public GraphMap { deba@989: private: deba@989: EdgeMap(); klao@959: public: deba@989: // \todo call the right parent class constructor deba@989: explicit EdgeMap(const Graph&) {} alpar@987: EdgeMap(const Graph&, const _Value&) {} klao@959: EdgeMap(const EdgeMap&) {} klao@959: klao@959: EdgeMap& operator=(const EdgeMap&) { return *this;} deba@989: klao@959: }; klao@959: deba@989: template deba@989: struct Constraints { klao@959: deba@989: struct Type { deba@989: int value; deba@989: Type() : value(0) {} deba@989: Type(int _v) : value(_v) {} deba@989: }; klao@959: deba@989: void constraints() { deba@989: checkConcept(); deba@989: { // int map test deba@989: typedef typename _Graph::template NodeMap IntNodeMap; deba@989: checkConcept, IntNodeMap >(); deba@989: } { // bool map test deba@989: typedef typename _Graph::template NodeMap BoolNodeMap; deba@989: checkConcept, BoolNodeMap >(); deba@989: } { // Type map test deba@989: typedef typename _Graph::template NodeMap TypeNodeMap; deba@989: checkConcept, TypeNodeMap >(); deba@989: } deba@989: deba@989: { // int map test deba@989: typedef typename _Graph::template EdgeMap IntEdgeMap; deba@989: checkConcept, IntEdgeMap >(); deba@989: } { // bool map test deba@989: typedef typename _Graph::template EdgeMap BoolEdgeMap; deba@989: checkConcept, BoolEdgeMap >(); deba@989: } { // Type map test deba@989: typedef typename _Graph::template EdgeMap TypeEdgeMap; deba@989: checkConcept, TypeEdgeMap >(); deba@989: } deba@989: } deba@989: deba@989: _Graph& graph; klao@959: }; klao@959: }; klao@959: klao@959: klao@959: class ExtendableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef ExtendableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: Node addNode() { klao@959: return INVALID; klao@959: } klao@959: klao@959: Edge addEdge(const Node& from, const Node& to) { klao@959: return INVALID; klao@959: } klao@959: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept(); deba@989: typename _Graph::Node node_a, node_b; deba@989: node_a = graph.addNode(); deba@989: typename _Graph::Edge edge; deba@989: edge = graph.addEdge(node_a, node_b); deba@989: } deba@989: _Graph& graph; deba@989: }; klao@959: }; klao@959: class ErasableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef ErasableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: void erase(const Node&) {} klao@959: void erase(const Edge&) {} klao@959: deba@989: template deba@989: struct Constraints { deba@989: void constraints() { deba@989: checkConcept(); deba@989: typename _Graph::Node node; deba@989: graph.erase(node); deba@989: typename _Graph::Edge edge; deba@989: graph.erase(edge); deba@989: } klao@959: deba@989: _Graph& graph; deba@989: }; klao@959: }; klao@959: klao@1030: /// @} klao@1030: klao@959: } klao@959: klao@959: } klao@959: klao@959: #endif