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@959: ///\ingroup concept 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@959: /// An empty base graph class. klao@959: klao@959: /// This class provides the most minimal features of a graph structure. klao@959: /// All the graph concepts have to be conform to this base graph. 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: /// klao@959: class Node { klao@959: public: klao@959: klao@959: /// Default constructor. klao@959: klao@959: /// @warning The default constructor sets the iterator klao@959: /// to an undefined value. klao@959: klao@959: Node() {} klao@959: /// Copy constructor. klao@959: klao@959: /// Copy constructor. klao@959: /// klao@959: Node(const Node&) {} klao@959: klao@959: /// Invalid constructor \& conversion. klao@959: klao@959: /// This constructor initializes the iterator to be invalid. klao@959: /// \sa Invalid for more details. klao@959: Node(Invalid) {} klao@959: klao@959: klao@959: Node& operator=(const Node&) { return *this;} klao@959: klao@959: /// Equality operator. klao@959: klao@959: /// Two iterators are equal if and only if they represents the klao@959: /// same node in the graph or both are invalid. klao@959: bool operator==(const Node&) { return true;} klao@959: klao@959: klao@959: /// Inequality operator. klao@959: klao@959: /// \sa operator==(const Node& n) klao@959: /// klao@959: bool operator!=(const Node&) { return true;} klao@959: klao@959: /// Comparison operator. klao@959: klao@959: /// This is a strict ordering between the nodes. klao@959: /// klao@959: /// This ordering can be different from the iterating order of nodes. klao@959: /// \todo Possibly we don't need it. klao@959: bool operator<(const Node&) { return true;} klao@959: }; klao@959: klao@959: /// Edge class of the graph. klao@959: klao@959: /// This class represents the Edges of the graph. klao@959: /// klao@959: class Edge { klao@959: public: klao@959: klao@959: /// Default constructor. klao@959: klao@959: /// @warning The default constructor sets the iterator klao@959: /// to an undefined value. klao@959: klao@959: Edge() {} klao@959: /// Copy constructor. klao@959: klao@959: /// Copy constructor. klao@959: /// klao@959: Edge(const Edge&) {} klao@959: klao@959: /// Invalid constructor \& conversion. klao@959: klao@959: /// This constructor initializes the iterator to be invalid. klao@959: /// \sa Invalid for more details. klao@959: Edge(Invalid) {} klao@959: klao@959: klao@959: Edge& operator=(const Edge&) { return *this;} klao@959: klao@959: /// Equality operator. klao@959: klao@959: /// Two iterators are equal if and only if they represents the klao@959: /// same edge in the graph or both are invalid. klao@959: bool operator==(const Edge&) { return true;} klao@959: klao@959: klao@959: /// Inequality operator. klao@959: klao@959: /// \sa operator==(const Edge& n) klao@959: /// klao@959: bool operator!=(const Edge&) { return true;} klao@959: klao@959: /// Comparison operator. klao@959: klao@959: /// This is a strict ordering between the edges. klao@959: /// klao@959: /// This ordering can be different from the iterating order of edges. klao@959: /// \todo Possibly we don't need it. klao@959: bool operator<(const Edge&) { return true;} klao@959: }; klao@959: klao@959: ///Gives back the head node of an edge. klao@959: klao@959: ///Gives back the head node of an edge. klao@959: /// klao@959: Node head(const Edge&) const { return INVALID;} klao@959: klao@959: ///Gives back the tail node of an edge. klao@959: klao@959: ///Gives back the tail node of an edge. klao@959: /// klao@959: Node tail(const Edge&) const { return INVALID;} klao@959: }; klao@959: klao@959: /// Concept check structure for BaseGraph. klao@959: klao@959: /// Concept check structure for BaseGraph. klao@959: /// klao@959: klao@959: template klao@959: struct BaseGraphComponentConcept { klao@959: typedef typename Graph::Node Node; klao@959: typedef typename Graph::Edge Edge; klao@959: klao@959: void constraints() { klao@959: { klao@959: Node ni; klao@959: Node nj(ni); klao@959: Node nk(INVALID); klao@959: ni = nj; klao@959: bool b; b = true; klao@959: b = (ni == INVALID); b = (ni != INVALID); klao@959: b = (ni==nj); b = (ni != nj); b=( ni < nj); klao@959: } klao@959: { klao@959: Edge ei; klao@959: Edge ej(ei); klao@959: Edge ek(INVALID); klao@959: ei = ej; klao@959: bool b; b = true; klao@959: b = (ei == INVALID); b = (ei != INVALID); klao@959: b = (ei==ej); b = (ei != ej); b=( ei < ej); klao@959: } klao@959: { klao@959: const Graph& const_graph = graph; klao@959: Node n; klao@959: Edge e; klao@959: n = const_graph.tail(e); klao@959: n = const_graph.head(e); klao@959: } klao@959: } klao@959: klao@959: Graph& graph; 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: klao@959: klao@959: /// Concept check structure for IterableBaseGraph. klao@959: klao@959: /// Concept check structure for IterableBaseGraph. klao@959: /// klao@959: template klao@959: struct BaseIterableGraphComponentConcept { klao@959: klao@959: void constraints() { klao@959: const Graph& const_graph = graph; klao@959: typename Graph::Node node; klao@959: typename Graph::Edge edge; klao@959: { klao@959: const_graph.first(node); klao@959: const_graph.next(node); klao@959: } klao@959: { klao@959: const_graph.first(edge); klao@959: const_graph.next(edge); klao@959: } klao@959: { klao@959: const_graph.firstIn(edge, node); klao@959: const_graph.nextIn(edge); klao@959: } klao@959: { klao@959: const_graph.firstOut(edge, node); klao@959: const_graph.nextOut(edge); klao@959: } klao@959: } klao@959: klao@959: Graph& graph; 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: 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: }; klao@959: klao@959: klao@959: /// Concept check structure for IdableBaseGraph. klao@959: klao@959: /// Concept check structure for IdableBaseGraph. klao@959: /// klao@959: template klao@959: struct IDableGraphComponentConcept { klao@959: klao@959: void constraints() { klao@959: const Graph& const_graph = graph; klao@959: typename Graph::Node node; klao@959: int nid = const_graph.id(node); klao@959: nid = const_graph.id(node); klao@959: typename Graph::Edge edge; klao@959: int eid = const_graph.id(edge); klao@959: eid = const_graph.id(edge); klao@959: } klao@959: klao@959: Graph& graph; 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: /// klao@959: int maxEdgeId() 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: /// klao@959: int maxNodeId() const { return -1;} klao@959: }; klao@959: klao@959: /// Concept check structure for MaxIdableBaseGraph. klao@959: klao@959: /// Concept check structure for MaxIdableBaseGraph. klao@959: /// klao@959: template klao@959: struct MaxIDableGraphComponentConcept { klao@959: klao@959: void constraints() { klao@959: const Graph& const_graph = graph; klao@959: int nid = const_graph.maxEdgeId(); klao@959: ignore_unused_variable_warning(nid); klao@959: int eid = const_graph.maxNodeId(); klao@959: ignore_unused_variable_warning(eid); klao@959: } klao@959: klao@959: Graph& graph; 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: klao@959: }; klao@959: klao@959: /// Concept check structure for ExtendableBaseGraph. klao@959: klao@959: /// Concept check structure for ExtendableBaseGraph. klao@959: /// klao@959: template klao@959: struct BaseExtendableGraphComponentConcept { klao@959: void constraints() { klao@959: typename Graph::Node node_a, node_b; klao@959: node_a = graph.addNode(); klao@959: typename Graph::Edge edge; klao@959: edge = graph.addEdge(node_a, node_b); klao@959: } klao@959: klao@959: Graph& graph; 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: klao@959: }; klao@959: klao@959: /// Concept check structure for ErasableBaseGraph. klao@959: klao@959: /// Concept check structure for ErasableBaseGraph. klao@959: /// klao@959: template klao@959: struct BaseErasableGraphComponentConcept { klao@959: void constraints() { klao@959: typename Graph::Node node; klao@959: graph.erase(node); klao@959: typename Graph::Edge edge; klao@959: graph.erase(edge); klao@959: } klao@959: klao@959: Graph& graph; 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@959: class BaseClearableGraphComponent : 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() {} klao@959: }; klao@959: klao@959: /// Concept check function for ErasableBaseGraph. klao@959: klao@959: /// Concept check function for ErasableBaseGraph. klao@959: /// klao@959: template klao@959: struct BaseClearableGraphComponentConcept { klao@959: void constraints() { klao@959: graph.clear(); klao@959: } klao@959: klao@959: Graph& graph; klao@959: }; klao@959: klao@959: klao@959: 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: klao@959: class NodeIt : public Node { klao@959: public: klao@959: NodeIt() {} klao@959: NodeIt(Invalid) {} klao@959: NodeIt(const Graph&) {} klao@959: klao@959: NodeIt& operator++() { return *this; } klao@959: // Node operator*() const { return INVALID; } klao@959: klao@959: bool operator==(const NodeIt&) { return true;} klao@959: bool operator!=(const NodeIt&) { return true;} klao@959: }; klao@959: klao@959: class EdgeIt : public Edge { klao@959: public: klao@959: EdgeIt() {} klao@959: EdgeIt(Invalid) {} klao@959: EdgeIt(const Graph&) {} klao@959: klao@959: EdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@959: bool operator==(const EdgeIt&) { return true;} klao@959: bool operator!=(const EdgeIt&) { return true;} klao@959: }; klao@959: klao@959: class InEdgeIt : public Edge { klao@959: public: klao@959: InEdgeIt() {} klao@959: InEdgeIt(Invalid) {} klao@959: InEdgeIt(const Graph&, const Node&) {} klao@959: klao@959: InEdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@959: bool operator==(const InEdgeIt&) { return true;} klao@959: bool operator!=(const InEdgeIt&) { return true;} klao@959: }; klao@959: klao@959: class OutEdgeIt : public Edge { klao@959: public: klao@959: OutEdgeIt() {} klao@959: OutEdgeIt(Invalid) {} klao@959: OutEdgeIt(const Graph&, const Node&) {} klao@959: klao@959: OutEdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@959: bool operator==(const OutEdgeIt&) { return true;} klao@959: bool operator!=(const OutEdgeIt&) { return true;} klao@959: }; klao@959: klao@959: }; klao@959: klao@959: template klao@959: struct IterableGraphComponentConcept { klao@959: klao@959: void constraints() { klao@959: klao@959: typedef typename Graph::Node Node; klao@959: typedef typename Graph::NodeIt NodeIt; klao@959: typedef typename Graph::Edge Edge; klao@959: typedef typename Graph::EdgeIt EdgeIt; klao@959: typedef typename Graph::InEdgeIt InEdgeIt; klao@959: typedef typename Graph::OutEdgeIt OutEdgeIt; klao@959: klao@959: { klao@959: NodeIt it; klao@959: NodeIt jt(it); klao@959: NodeIt kt(INVALID); klao@959: NodeIt lt(graph); klao@959: it = jt; klao@959: jt = ++it; klao@959: bool b; klao@959: b = (it == INVALID); klao@959: b = (it != INVALID); klao@959: b = (it == jt); klao@959: b = (it != jt); klao@959: Node node = it; klao@959: node = it; klao@959: } klao@959: { klao@959: EdgeIt it; klao@959: EdgeIt jt(it); klao@959: EdgeIt kt(INVALID); klao@959: EdgeIt lt(graph); klao@959: it = jt; klao@959: jt = ++it; klao@959: bool b; klao@959: b = (it == INVALID); klao@959: b = (it != INVALID); klao@959: b = (it == jt); klao@959: b = (it != jt); klao@959: Edge edge = it; klao@959: edge = it; klao@959: } klao@959: { klao@959: InEdgeIt it; klao@959: InEdgeIt jt(it); klao@959: InEdgeIt kt(INVALID); klao@959: Node node; klao@959: InEdgeIt lt(graph, node); klao@959: it = jt; klao@959: jt = ++it; klao@959: bool b; klao@959: b = (it == INVALID); klao@959: b = (it != INVALID); klao@959: b = (it == jt); klao@959: b = (it != jt); klao@959: Edge edge = it; klao@959: edge = it; klao@959: } klao@959: { klao@959: OutEdgeIt it; klao@959: OutEdgeIt jt(it); klao@959: OutEdgeIt kt(INVALID); klao@959: Node node; klao@959: OutEdgeIt lt(graph, node); klao@959: it = jt; klao@959: jt = ++it; klao@959: bool b; klao@959: b = (it == INVALID); klao@959: b = (it != INVALID); klao@959: b = (it == jt); klao@959: b = (it != jt); klao@959: Edge edge = it; klao@959: edge = it; klao@959: } klao@959: } klao@959: Graph& graph; klao@959: }; klao@959: klao@959: klao@959: class IdMappableGraphComponent : virtual public BaseGraphComponent { klao@959: klao@959: typedef IdMappableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: public: klao@959: klao@959: class NodeIdMap : public ReadMap { klao@959: public: klao@959: NodeIdMap(const Graph&) {} klao@959: int maxId() const { return -1;} klao@959: }; klao@959: klao@959: class EdgeIdMap : public ReadMap { klao@959: public: klao@959: EdgeIdMap(const Graph&) {} klao@959: int maxId() const { return -1;} klao@959: }; klao@959: klao@959: }; klao@959: klao@959: template klao@959: struct IdMappableGraphComponentConcept { klao@959: void constraints() { klao@959: { klao@959: typedef typename Graph::EdgeIdMap EdgeIdMap; klao@959: function_requires >(); klao@959: EdgeIdMap edge_map(graph); klao@959: int n = edge_map.maxId(); klao@959: ignore_unused_variable_warning(n); klao@959: } klao@959: { klao@959: typedef typename Graph::NodeIdMap NodeIdMap; klao@959: function_requires >(); klao@959: NodeIdMap node_map(graph); klao@959: int n = node_map.maxId(); klao@959: ignore_unused_variable_warning(n); klao@959: } klao@959: } klao@959: Graph& graph; klao@959: }; klao@959: klao@959: 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: klao@959: template klao@959: class NodeMap : public ReferenceMap { klao@959: public: klao@959: NodeMap(const Graph&) {} klao@959: NodeMap(const Graph&, const Value&) {} klao@959: NodeMap(const NodeMap&) {} klao@959: klao@959: NodeMap& operator=(const NodeMap&) { return *this;} klao@959: klao@959: }; klao@959: klao@959: template klao@959: class EdgeMap : public ReferenceMap { klao@959: public: klao@959: EdgeMap(const Graph&) {} klao@959: EdgeMap(const Graph&, const Value&) {} klao@959: EdgeMap(const EdgeMap&) {} klao@959: klao@959: EdgeMap& operator=(const EdgeMap&) { return *this;} klao@959: klao@959: }; klao@959: klao@959: }; klao@959: klao@959: template klao@959: struct MappableGraphComponentConcept { klao@959: klao@959: struct Type { klao@959: int value; klao@959: Type() : value(0) {} klao@959: Type(int _v) : value(_v) {} klao@959: }; klao@959: klao@959: void constraints() { klao@959: { // int map test klao@959: typedef typename Graph::template NodeMap IntNodeMap; klao@959: function_requires >(); klao@959: } { // bool map test klao@959: typedef typename Graph::template NodeMap BoolNodeMap; klao@959: function_requires >(); klao@959: } { // Type map test klao@959: typedef typename Graph::template NodeMap TypeNodeMap; klao@959: function_requires >(); klao@959: } klao@959: klao@959: { // int map test klao@959: typedef typename Graph::template EdgeMap IntEdgeMap; klao@959: function_requires >(); klao@959: } { // bool map test klao@959: typedef typename Graph::template EdgeMap BoolEdgeMap; klao@959: function_requires >(); klao@959: } { // Type map test klao@959: typedef typename Graph::template EdgeMap TypeEdgeMap; klao@959: function_requires >(); klao@959: } klao@959: } klao@959: klao@959: Graph& graph; 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: klao@959: }; klao@959: klao@959: template klao@959: struct ExtendableGraphComponentConcept { klao@959: void constraints() { klao@959: typename Graph::Node node_a, node_b; klao@959: node_a = graph.addNode(); klao@959: typename Graph::Edge edge; klao@959: edge = graph.addEdge(node_a, node_b); klao@959: } klao@959: Graph& graph; klao@959: }; 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: klao@959: }; klao@959: klao@959: template klao@959: struct ErasableGraphComponentConcept { klao@959: void constraints() { klao@959: typename Graph::Node node; klao@959: graph.erase(node); klao@959: typename Graph::Edge edge; klao@959: graph.erase(edge); klao@959: } klao@959: klao@959: Graph& graph; klao@959: }; klao@959: klao@959: class ClearableGraphComponent : virtual public BaseGraphComponent { klao@959: public: klao@959: klao@959: typedef ClearableGraphComponent Graph; klao@959: klao@959: typedef BaseGraphComponent::Node Node; klao@959: typedef BaseGraphComponent::Edge Edge; klao@959: klao@959: void clear() {} klao@959: klao@959: }; klao@959: klao@959: template klao@959: struct ClearableGraphComponentConcept { klao@959: void constraints() { klao@959: graph.clear(); klao@959: } klao@959: Graph& graph; klao@959: }; klao@959: klao@959: } klao@959: klao@959: } klao@959: klao@959: #endif