klao@946: /* -*- C++ -*- klao@946: * src/lemon/skeletons/graph_component.h - Part of LEMON, a generic C++ optimization library klao@946: * klao@946: * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport klao@946: * (Egervary Combinatorial Optimization Research Group, EGRES). klao@946: * klao@946: * Permission to use, modify and distribute this software is granted klao@946: * provided that this copyright notice appears in all copies. For klao@946: * precise terms see the accompanying LICENSE file. klao@946: * klao@946: * This software is provided "AS IS" with no warranty of any kind, klao@946: * express or implied, and with no claim as to its suitability for any klao@946: * purpose. klao@946: * klao@946: */ klao@946: klao@946: ///\ingroup skeletons klao@946: ///\file klao@946: ///\brief The graph components. klao@946: klao@946: klao@946: #ifndef LEMON_SKELETON_GRAPH_COMPONENT_H klao@946: #define LEMON_SKELETON_GRAPH_COMPONENT_H klao@946: klao@946: #include klao@946: #include klao@946: klao@946: namespace lemon { klao@946: namespace skeleton { klao@946: klao@946: /// An empty base graph class. klao@946: klao@946: /// This class provides the most minimal features of a graph structure. klao@946: /// All the graph concepts have to be conform to this base graph. klao@946: klao@946: class BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef BaseGraphComponent Graph; klao@946: klao@946: /// Node class of the graph. klao@946: klao@946: /// This class represents the Nodes of the graph. klao@946: /// klao@946: class Node { klao@946: public: klao@946: klao@946: /// Default constructor. klao@946: klao@946: /// @warning The default constructor sets the iterator klao@946: /// to an undefined value. klao@946: klao@946: Node() {} klao@946: /// Copy constructor. klao@946: klao@946: /// Copy constructor. klao@946: /// klao@946: Node(const Node&) {} klao@946: klao@946: /// Invalid constructor \& conversion. klao@946: klao@946: /// This constructor initializes the iterator to be invalid. klao@946: /// \sa Invalid for more details. klao@946: Node(Invalid) {} klao@946: klao@946: klao@946: Node& operator=(const Node&) { return *this;} klao@946: klao@946: /// Equality operator. klao@946: klao@946: /// Two iterators are equal if and only if they represents the klao@946: /// same node in the graph or both are invalid. klao@946: bool operator==(const Node&) { return true;} klao@946: klao@946: klao@946: /// Inequality operator. klao@946: klao@946: /// \sa operator==(const Node& n) klao@946: /// klao@946: bool operator!=(const Node&) { return true;} klao@946: klao@946: /// Comparison operator. klao@946: klao@946: /// This is a strict ordering between the nodes. klao@946: /// klao@946: /// This ordering can be different from the iterating order of nodes. klao@946: /// \todo Possibly we don't need it. klao@946: bool operator<(const Node&) { return true;} klao@946: }; klao@946: klao@946: /// Edge class of the graph. klao@946: klao@946: /// This class represents the Edges of the graph. klao@946: /// klao@946: class Edge { klao@946: public: klao@946: klao@946: /// Default constructor. klao@946: klao@946: /// @warning The default constructor sets the iterator klao@946: /// to an undefined value. klao@946: klao@946: Edge() {} klao@946: /// Copy constructor. klao@946: klao@946: /// Copy constructor. klao@946: /// klao@946: Edge(const Edge&) {} klao@946: klao@946: /// Invalid constructor \& conversion. klao@946: klao@946: /// This constructor initializes the iterator to be invalid. klao@946: /// \sa Invalid for more details. klao@946: Edge(Invalid) {} klao@946: klao@946: klao@946: Edge& operator=(const Edge&) { return *this;} klao@946: klao@946: /// Equality operator. klao@946: klao@946: /// Two iterators are equal if and only if they represents the klao@946: /// same edge in the graph or both are invalid. klao@946: bool operator==(const Edge&) { return true;} klao@946: klao@946: klao@946: /// Inequality operator. klao@946: klao@946: /// \sa operator==(const Edge& n) klao@946: /// klao@946: bool operator!=(const Edge&) { return true;} klao@946: klao@946: /// Comparison operator. klao@946: klao@946: /// This is a strict ordering between the edges. klao@946: /// klao@946: /// This ordering can be different from the iterating order of edges. klao@946: /// \todo Possibly we don't need it. klao@946: bool operator<(const Edge&) { return true;} klao@946: }; klao@946: klao@946: ///Gives back the head node of an edge. klao@946: klao@946: ///Gives back the head node of an edge. klao@946: /// klao@946: Node head(const Edge&) const { return INVALID;} klao@946: klao@946: ///Gives back the tail node of an edge. klao@946: klao@946: ///Gives back the tail node of an edge. klao@946: /// klao@946: Node tail(const Edge&) const { return INVALID;} klao@946: }; klao@946: klao@946: /// Concept check structure for BaseGraph. klao@946: klao@946: /// Concept check structure for BaseGraph. klao@946: /// klao@946: klao@946: template klao@946: struct BaseGraphComponentConcept { klao@946: typedef typename Graph::Node Node; klao@946: typedef typename Graph::Edge Edge; klao@946: klao@946: void constraints() { klao@946: { klao@946: Node ni; klao@946: Node nj(ni); klao@946: Node nk(INVALID); klao@946: ni = nj; klao@946: bool b; b = true; klao@946: b = (ni == INVALID); b = (ni != INVALID); klao@946: b = (ni==nj); b = (ni != nj); b=( ni < nj); klao@946: } klao@946: { klao@946: Edge ei; klao@946: Edge ej(ei); klao@946: Edge ek(INVALID); klao@946: ei = ej; klao@946: bool b; b = true; klao@946: b = (ei == INVALID); b = (ei != INVALID); klao@946: b = (ei==ej); b = (ei != ej); b=( ei < ej); klao@946: } klao@946: { klao@946: const Graph& const_graph = graph; klao@946: Node n; klao@946: Edge e; klao@946: n = const_graph.tail(e); klao@946: n = const_graph.head(e); klao@946: } klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: /// An empty iterable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core iterable interface for the graph structure. alpar@950: /// Most of the base graphs should be conform to this concept. klao@946: klao@946: class BaseIterableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: /// Gives back the first Node in the iterating order. klao@946: klao@946: /// Gives back the first Node in the iterating order. klao@946: /// klao@946: void first(Node&) const {} klao@946: klao@946: /// Gives back the next Node in the iterating order. klao@946: klao@946: /// Gives back the next Node in the iterating order. klao@946: /// klao@946: void next(Node&) const {} klao@946: klao@946: /// Gives back the first Edge in the iterating order. klao@946: klao@946: /// Gives back the first Edge in the iterating order. klao@946: /// klao@946: void first(Edge&) const {} klao@946: /// Gives back the next Edge in the iterating order. klao@946: klao@946: /// Gives back the next Edge in the iterating order. klao@946: /// klao@946: void next(Edge&) const {} klao@946: klao@946: klao@946: /// Gives back the first of the Edges point to the given Node. klao@946: klao@946: /// Gives back the first of the Edges point to the given Node. klao@946: /// klao@946: void firstIn(Edge&, const Node&) const {} klao@946: klao@946: /// Gives back the next of the Edges points to the given Node. klao@946: klao@946: klao@946: /// Gives back the next of the Edges points to the given Node. klao@946: /// klao@946: void nextIn(Edge&) const {} klao@946: klao@946: /// Gives back the first of the Edges start from the given Node. klao@946: klao@946: /// Gives back the first of the Edges start from the given Node. klao@946: /// klao@946: void firstOut(Edge&, const Node&) const {} klao@946: klao@946: /// Gives back the next of the Edges start from the given Node. klao@946: klao@946: /// Gives back the next of the Edges start from the given Node. klao@946: /// klao@946: void nextOut(Edge&) const {} klao@946: }; klao@946: klao@946: klao@946: /// Concept check structure for IterableBaseGraph. klao@946: klao@946: /// Concept check structure for IterableBaseGraph. klao@946: /// klao@946: template klao@946: struct BaseIterableGraphComponentConcept { klao@946: klao@946: void constraints() { klao@946: const Graph& const_graph = graph; klao@946: typename Graph::Node node; klao@946: typename Graph::Edge edge; klao@946: { klao@946: const_graph.first(node); klao@946: const_graph.next(node); klao@946: } klao@946: { klao@946: const_graph.first(edge); klao@946: const_graph.next(edge); klao@946: } klao@946: { klao@946: const_graph.firstIn(edge, node); klao@946: const_graph.nextIn(edge); klao@946: } klao@946: { klao@946: const_graph.firstOut(edge, node); klao@946: const_graph.nextOut(edge); klao@946: } klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: /// An empty idable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core id functions for the graph structure. klao@946: /// The most of the base graphs should be conform to this concept. klao@946: /// The id's are unique and immutable. klao@946: klao@946: class IDableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: /// Gives back an unique integer id for the Node. klao@946: klao@946: /// Gives back an unique integer id for the Node. klao@946: /// klao@946: int id(const Node&) const { return -1;} klao@946: klao@946: /// Gives back an unique integer id for the Edge. klao@946: klao@946: /// Gives back an unique integer id for the Edge. klao@946: /// klao@946: int id(const Edge&) const { return -1;} klao@946: }; klao@946: klao@946: klao@946: /// Concept check structure for IdableBaseGraph. klao@946: klao@946: /// Concept check structure for IdableBaseGraph. klao@946: /// klao@946: template klao@946: struct IDableGraphComponentConcept { klao@946: klao@946: void constraints() { klao@946: const Graph& const_graph = graph; klao@946: typename Graph::Node node; klao@946: int nid = const_graph.id(node); klao@946: nid = const_graph.id(node); klao@946: typename Graph::Edge edge; klao@946: int eid = const_graph.id(edge); klao@946: eid = const_graph.id(edge); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: klao@946: /// An empty max-idable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core max id functions for the graph structure. klao@946: /// The most of the base graphs should be conform to this concept. klao@946: /// The id's are unique and immutable. klao@946: class MaxIDableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: /// Gives back an integer greater or equal to the maximum Node id. klao@946: klao@946: /// Gives back an integer greater or equal to the maximum Node id. klao@946: /// klao@946: int maxEdgeId() const { return -1;} klao@946: klao@946: /// Gives back an integer greater or equal to the maximum Edge id. klao@946: klao@946: /// Gives back an integer greater or equal to the maximum Edge id. klao@946: /// klao@946: int maxNodeId() const { return -1;} klao@946: }; klao@946: klao@946: /// Concept check structure for MaxIdableBaseGraph. klao@946: klao@946: /// Concept check structure for MaxIdableBaseGraph. klao@946: /// klao@946: template klao@946: struct MaxIDableGraphComponentConcept { klao@946: klao@946: void constraints() { klao@946: const Graph& const_graph = graph; klao@946: int nid = const_graph.maxEdgeId(); klao@946: ignore_unused_variable_warning(nid); klao@946: int eid = const_graph.maxNodeId(); klao@946: ignore_unused_variable_warning(eid); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: /// An empty extendable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core graph extend interface for the graph structure. klao@946: /// The most of the base graphs should be conform to this concept. klao@946: class BaseExtendableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: /// Adds a new Node to the graph. klao@946: klao@946: /// Adds a new Node to the graph. klao@946: /// klao@946: Node addNode() { klao@946: return INVALID; klao@946: } klao@946: klao@946: /// Adds a new Edge connects the two Nodes to the graph. klao@946: klao@946: /// Adds a new Edge connects the two Nodes to the graph. klao@946: /// klao@946: Edge addEdge(const Node& from, const Node& to) { klao@946: return INVALID; klao@946: } klao@946: klao@946: }; klao@946: klao@946: /// Concept check structure for ExtendableBaseGraph. klao@946: klao@946: /// Concept check structure for ExtendableBaseGraph. klao@946: /// klao@946: template klao@946: struct BaseExtendableGraphComponentConcept { klao@946: void constraints() { klao@946: typename Graph::Node node_a, node_b; klao@946: node_a = graph.addNode(); klao@946: typename Graph::Edge edge; klao@946: edge = graph.addEdge(node_a, node_b); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: /// An empty erasable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core erase functions for the graph structure. klao@946: /// The most of the base graphs should be conform to this concept. klao@946: class BaseErasableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: /// Erase a Node from the graph. klao@946: klao@946: /// Erase a Node from the graph. This function should not klao@946: /// erase edges connecting to the Node. klao@946: void erase(const Node&) {} klao@946: klao@946: /// Erase an Edge from the graph. klao@946: klao@946: /// Erase an Edge from the graph. klao@946: /// klao@946: void erase(const Edge&) {} klao@946: klao@946: }; klao@946: klao@946: /// Concept check structure for ErasableBaseGraph. klao@946: klao@946: /// Concept check structure for ErasableBaseGraph. klao@946: /// klao@946: template klao@946: struct BaseErasableGraphComponentConcept { klao@946: void constraints() { klao@946: typename Graph::Node node; klao@946: graph.erase(node); klao@946: typename Graph::Edge edge; klao@946: graph.erase(edge); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: /// An empty clearable base graph class. klao@946: klao@946: /// This class provides beside the core graph features klao@946: /// core clear functions for the graph structure. klao@946: /// The most of the base graphs should be conform to this concept. klao@946: class BaseClearableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: /// Erase all the Nodes and Edges from the graph. klao@946: klao@946: /// Erase all the Nodes and Edges from the graph. klao@946: /// klao@946: void clear() {} klao@946: }; klao@946: klao@946: /// Concept check function for ErasableBaseGraph. klao@946: klao@946: /// Concept check function for ErasableBaseGraph. klao@946: /// klao@946: template klao@946: struct BaseClearableGraphComponentConcept { klao@946: void constraints() { klao@946: graph.clear(); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: klao@946: class IterableGraphComponent : virtual public BaseGraphComponent { klao@946: klao@946: public: klao@946: klao@946: typedef IterableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: class NodeIt : public Node { klao@946: public: klao@946: NodeIt() {} klao@946: NodeIt(Invalid) {} klao@946: NodeIt(const Graph&) {} klao@946: klao@946: NodeIt& operator++() { return *this; } klao@946: // Node operator*() const { return INVALID; } klao@946: klao@946: bool operator==(const NodeIt&) { return true;} klao@946: bool operator!=(const NodeIt&) { return true;} klao@946: }; klao@946: klao@946: class EdgeIt : public Edge { klao@946: public: klao@946: EdgeIt() {} klao@946: EdgeIt(Invalid) {} klao@946: EdgeIt(const Graph&) {} klao@946: klao@946: EdgeIt& operator++() { return *this; } klao@946: // Edge operator*() const { return INVALID; } klao@946: klao@946: bool operator==(const EdgeIt&) { return true;} klao@946: bool operator!=(const EdgeIt&) { return true;} klao@946: }; klao@946: klao@946: class InEdgeIt : public Edge { klao@946: public: klao@946: InEdgeIt() {} klao@946: InEdgeIt(Invalid) {} klao@946: InEdgeIt(const Graph&, const Node&) {} klao@946: klao@946: InEdgeIt& operator++() { return *this; } klao@946: // Edge operator*() const { return INVALID; } klao@946: klao@946: bool operator==(const InEdgeIt&) { return true;} klao@946: bool operator!=(const InEdgeIt&) { return true;} klao@946: }; klao@946: klao@946: class OutEdgeIt : public Edge { klao@946: public: klao@946: OutEdgeIt() {} klao@946: OutEdgeIt(Invalid) {} klao@946: OutEdgeIt(const Graph&, const Node&) {} klao@946: klao@946: OutEdgeIt& operator++() { return *this; } klao@946: // Edge operator*() const { return INVALID; } klao@946: klao@946: bool operator==(const OutEdgeIt&) { return true;} klao@946: bool operator!=(const OutEdgeIt&) { return true;} klao@946: }; klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct IterableGraphComponentConcept { klao@946: klao@946: void constraints() { klao@946: klao@946: typedef typename Graph::Node Node; klao@946: typedef typename Graph::NodeIt NodeIt; klao@946: typedef typename Graph::Edge Edge; klao@946: typedef typename Graph::EdgeIt EdgeIt; klao@946: typedef typename Graph::InEdgeIt InEdgeIt; klao@946: typedef typename Graph::OutEdgeIt OutEdgeIt; klao@946: klao@946: { klao@946: NodeIt it; klao@946: NodeIt jt(it); klao@946: NodeIt kt(INVALID); klao@946: NodeIt lt(graph); klao@946: it = jt; klao@946: jt = ++it; klao@946: bool b; klao@946: b = (it == INVALID); klao@946: b = (it != INVALID); klao@946: b = (it == jt); klao@946: b = (it != jt); klao@946: Node node = it; klao@946: node = it; klao@946: } klao@946: { klao@946: EdgeIt it; klao@946: EdgeIt jt(it); klao@946: EdgeIt kt(INVALID); klao@946: EdgeIt lt(graph); klao@946: it = jt; klao@946: jt = ++it; klao@946: bool b; klao@946: b = (it == INVALID); klao@946: b = (it != INVALID); klao@946: b = (it == jt); klao@946: b = (it != jt); klao@946: Edge edge = it; klao@946: edge = it; klao@946: } klao@946: { klao@946: InEdgeIt it; klao@946: InEdgeIt jt(it); klao@946: InEdgeIt kt(INVALID); klao@946: Node node; klao@946: InEdgeIt lt(graph, node); klao@946: it = jt; klao@946: jt = ++it; klao@946: bool b; klao@946: b = (it == INVALID); klao@946: b = (it != INVALID); klao@946: b = (it == jt); klao@946: b = (it != jt); klao@946: Edge edge = it; klao@946: edge = it; klao@946: } klao@946: { klao@946: OutEdgeIt it; klao@946: OutEdgeIt jt(it); klao@946: OutEdgeIt kt(INVALID); klao@946: Node node; klao@946: OutEdgeIt lt(graph, node); klao@946: it = jt; klao@946: jt = ++it; klao@946: bool b; klao@946: b = (it == INVALID); klao@946: b = (it != INVALID); klao@946: b = (it == jt); klao@946: b = (it != jt); klao@946: Edge edge = it; klao@946: edge = it; klao@946: } klao@946: } klao@946: Graph& graph; klao@946: }; klao@946: klao@946: klao@946: class IdMappableGraphComponent : virtual public BaseGraphComponent { klao@946: klao@946: typedef IdMappableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: public: klao@946: klao@946: class NodeIdMap : public ReadMap { klao@946: public: klao@946: NodeIdMap(const Graph&) {} klao@946: int maxId() const { return -1;} klao@946: }; klao@946: klao@946: class EdgeIdMap : public ReadMap { klao@946: public: klao@946: EdgeIdMap(const Graph&) {} klao@946: int maxId() const { return -1;} klao@946: }; klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct IdMappableGraphComponentConcept { klao@946: void constraints() { klao@946: { klao@946: typedef typename Graph::EdgeIdMap EdgeIdMap; klao@946: function_requires >(); klao@946: EdgeIdMap edge_map(graph); klao@946: int n = edge_map.maxId(); klao@946: ignore_unused_variable_warning(n); klao@946: } klao@946: { klao@946: typedef typename Graph::NodeIdMap NodeIdMap; klao@946: function_requires >(); klao@946: NodeIdMap node_map(graph); klao@946: int n = node_map.maxId(); klao@946: ignore_unused_variable_warning(n); klao@946: } klao@946: } klao@946: Graph& graph; klao@946: }; klao@946: klao@946: klao@946: class MappableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef MappableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: template klao@946: class NodeMap : public ReferenceMap { klao@946: public: klao@946: NodeMap(const Graph&) {} klao@946: NodeMap(const Graph&, const Value&) {} klao@946: NodeMap(const NodeMap&) {} klao@946: klao@946: NodeMap& operator=(const NodeMap&) { return *this;} klao@946: klao@946: }; klao@946: klao@946: template klao@946: class EdgeMap : public ReferenceMap { klao@946: public: klao@946: EdgeMap(const Graph&) {} klao@946: EdgeMap(const Graph&, const Value&) {} klao@946: EdgeMap(const EdgeMap&) {} klao@946: klao@946: EdgeMap& operator=(const EdgeMap&) { return *this;} klao@946: klao@946: }; klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct MappableGraphComponentConcept { klao@946: klao@946: struct Type { klao@946: int value; klao@946: Type() : value(0) {} klao@946: Type(int _v) : value(_v) {} klao@946: }; klao@946: klao@946: void constraints() { klao@946: { // int map test klao@946: typedef typename Graph::template NodeMap IntNodeMap; klao@946: function_requires >(); klao@946: } { // bool map test klao@946: typedef typename Graph::template NodeMap BoolNodeMap; klao@946: function_requires >(); klao@946: } { // Type map test klao@946: typedef typename Graph::template NodeMap TypeNodeMap; klao@946: function_requires >(); klao@946: } klao@946: klao@946: { // int map test klao@946: typedef typename Graph::template EdgeMap IntEdgeMap; klao@946: function_requires >(); klao@946: } { // bool map test klao@946: typedef typename Graph::template EdgeMap BoolEdgeMap; klao@946: function_requires >(); klao@946: } { // Type map test klao@946: typedef typename Graph::template EdgeMap TypeEdgeMap; klao@946: function_requires >(); klao@946: } klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: klao@946: class ExtendableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef ExtendableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: Node addNode() { klao@946: return INVALID; klao@946: } klao@946: klao@946: Edge addEdge(const Node& from, const Node& to) { klao@946: return INVALID; klao@946: } klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct ExtendableGraphComponentConcept { klao@946: void constraints() { klao@946: typename Graph::Node node_a, node_b; klao@946: node_a = graph.addNode(); klao@946: typename Graph::Edge edge; klao@946: edge = graph.addEdge(node_a, node_b); klao@946: } klao@946: Graph& graph; klao@946: }; klao@946: klao@946: class ErasableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef ErasableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: void erase(const Node&) {} klao@946: void erase(const Edge&) {} klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct ErasableGraphComponentConcept { klao@946: void constraints() { klao@946: typename Graph::Node node; klao@946: graph.erase(node); klao@946: typename Graph::Edge edge; klao@946: graph.erase(edge); klao@946: } klao@946: klao@946: Graph& graph; klao@946: }; klao@946: klao@946: class ClearableGraphComponent : virtual public BaseGraphComponent { klao@946: public: klao@946: klao@946: typedef ClearableGraphComponent Graph; klao@946: klao@946: typedef BaseGraphComponent::Node Node; klao@946: typedef BaseGraphComponent::Edge Edge; klao@946: klao@946: void clear() {} klao@946: klao@946: }; klao@946: klao@946: template klao@946: struct ClearableGraphComponentConcept { klao@946: void constraints() { klao@946: graph.clear(); klao@946: } klao@946: Graph& graph; klao@946: }; klao@946: klao@946: } klao@946: klao@946: } klao@946: klao@946: #endif