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@961: klao@961: /**************** Graph iterator concepts ****************/ klao@961: klao@961: /// Skeleton class for graph Node and Edge klao@961: klao@961: /// \note Because Node and Edge are forbidden to inherit from the same alpar@964: /// base class, this is a template. For Node you should instantiate it klao@961: /// with character 'n' and for Edge with 'e'. klao@961: klao@961: template klao@961: class GraphItem { klao@961: public: klao@961: GraphItem() {} klao@961: GraphItem(Invalid) {} klao@961: klao@961: // We explicitely list these: klao@961: GraphItem(GraphItem const&) {} klao@961: GraphItem& operator=(GraphItem const&) { return *this; } klao@961: klao@961: bool operator==(GraphItem) const { return false; } klao@961: bool operator!=(GraphItem) const { return false; } klao@961: klao@961: // Technical requirement. Do we really need this? klao@961: bool operator<(GraphItem) const { return false; } klao@961: }; klao@961: klao@961: klao@961: template klao@961: struct GraphItemConcept { klao@961: void constraints() { klao@961: GI i1; klao@961: GI i2 = i1; klao@961: GI i3 = INVALID; klao@961: klao@961: i1 = i2 = i3; klao@961: klao@961: bool b; klao@961: b = (ia == ib) && (ia != ib) && (ia < ib); klao@961: b = (ia == INVALID) && (ib != INVALID); klao@961: } klao@961: klao@961: const GI &ia; klao@961: const GI &ib; klao@961: }; klao@961: klao@961: klao@961: template klao@961: struct GraphIteratorConcept { klao@961: void constraints() { klao@961: function_requires< GraphItemConcept >(); klao@961: Iter it1(g); klao@961: klao@961: /// \todo Do we need NodeIt(Node) kind of constructor? klao@961: // Iter it2(bj); klao@961: Iter it2; klao@961: klao@961: it2 = ++it1; klao@961: ++it2 = it1; klao@961: ++(++it1); klao@961: /// \bug This should be: is_base_and_derived klao@961: BaseItem bi = it1; klao@961: bi = it2; klao@961: } klao@961: klao@961: BaseItem bj; klao@961: Graph g; klao@961: }; klao@961: klao@961: template klao@961: struct GraphIncIteratorConcept { klao@961: typedef typename Graph::Node Node; klao@961: typedef typename Graph::Edge Edge; klao@961: void constraints() { klao@961: function_requires< GraphItemConcept >(); klao@961: Iter it1(graph, node); klao@961: /// \todo Do we need OutEdgeIt(Edge) kind of constructor? klao@961: // Iter it2(edge); klao@961: Iter it2; klao@961: klao@961: it2 = ++it1; klao@961: ++it2 = it1; klao@961: ++(++it1); klao@961: Edge e = it1; klao@961: e = it2; klao@961: } klao@961: klao@961: Edge edge; klao@961: Node node; klao@961: Graph graph; klao@961: }; klao@961: klao@961: klao@961: 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: /// 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: deba@980: /// Assign operator for nodes. deba@980: deba@980: /// The nodes are assignable. deba@980: /// 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@961: bool operator==(const Node&) const { return true;} klao@959: klao@959: klao@959: /// Inequality operator. klao@959: klao@959: /// \sa operator==(const Node& n) klao@959: /// klao@961: bool operator!=(const Node&) const { 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@961: bool operator<(const Node&) const { 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: deba@980: /// Assign operator for edges. klao@959: deba@980: /// The edges are assignable. deba@980: /// 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@961: bool operator==(const Edge&) const { return true;} klao@959: klao@959: klao@959: /// Inequality operator. klao@959: klao@959: /// \sa operator==(const Edge& n) klao@959: /// klao@961: bool operator!=(const Edge&) const { 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@961: bool operator<(const Edge&) const { 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@961: 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@961: function_requires< GraphItemConcept >(); klao@961: function_requires< GraphItemConcept >(); klao@959: { klao@959: Node n; klao@959: Edge e; klao@962: n = graph.tail(e); klao@962: n = graph.head(e); klao@959: } klao@959: } klao@959: klao@962: const 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@961: void constraints() { klao@961: function_requires< BaseGraphComponentConcept >(); klao@959: typename Graph::Node node; klao@959: typename Graph::Edge edge; klao@959: { klao@961: graph.first(node); klao@961: graph.next(node); klao@959: } klao@959: { klao@961: graph.first(edge); klao@961: graph.next(edge); klao@959: } klao@959: { klao@961: graph.firstIn(edge, node); klao@961: graph.nextIn(edge); klao@959: } klao@959: { klao@961: graph.firstOut(edge, node); klao@961: graph.nextOut(edge); klao@959: } klao@959: } klao@959: klao@961: const 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@961: function_requires< BaseGraphComponentConcept >(); klao@959: typename Graph::Node node; klao@961: int nid = graph.id(node); klao@961: nid = graph.id(node); klao@959: typename Graph::Edge edge; klao@961: int eid = graph.id(edge); klao@961: eid = graph.id(edge); klao@959: } klao@959: klao@961: const 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: /// 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: }; 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@961: function_requires< BaseGraphComponentConcept >(); deba@980: int nid = graph.maxId(typename Graph::Node()); klao@959: ignore_unused_variable_warning(nid); deba@980: int eid = graph.maxId(typename Graph::Edge()); klao@959: ignore_unused_variable_warning(eid); klao@959: } klao@959: klao@961: const 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@961: function_requires< BaseGraphComponentConcept >(); 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@961: function_requires< BaseGraphComponentConcept >(); 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@961: function_requires< BaseGraphComponentConcept >(); klao@959: graph.clear(); klao@959: } klao@959: klao@959: Graph& graph; klao@959: }; klao@959: klao@959: klao@961: class IterableGraphComponent : klao@961: virtual public BaseIterableGraphComponent { 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@961: // explicit NodeIt(Node) {} klao@961: explicit NodeIt(const Graph&) {} klao@959: klao@959: NodeIt& operator++() { return *this; } klao@959: // Node operator*() const { return INVALID; } klao@959: klao@961: bool operator==(const NodeIt&) const { return true;} klao@961: bool operator!=(const NodeIt&) const { return true;} klao@959: }; klao@959: klao@959: class EdgeIt : public Edge { klao@959: public: klao@959: EdgeIt() {} klao@959: EdgeIt(Invalid) {} klao@961: // explicit EdgeIt(Edge) {} klao@961: explicit EdgeIt(const Graph&) {} klao@959: klao@959: EdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@961: bool operator==(const EdgeIt&) const { return true;} klao@961: bool operator!=(const EdgeIt&) const { return true;} klao@959: }; klao@959: klao@959: class InEdgeIt : public Edge { klao@959: public: klao@959: InEdgeIt() {} klao@959: InEdgeIt(Invalid) {} klao@961: // explicit InEdgeIt(Edge) {} klao@961: explicit InEdgeIt(const Graph&, const Node&) {} klao@959: klao@959: InEdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@961: bool operator==(const InEdgeIt&) const { return true;} klao@961: bool operator!=(const InEdgeIt&) const { return true;} klao@959: }; klao@959: klao@959: class OutEdgeIt : public Edge { klao@959: public: klao@959: OutEdgeIt() {} klao@959: OutEdgeIt(Invalid) {} klao@961: // explicit OutEdgeIt(Edge) {} klao@961: explicit OutEdgeIt(const Graph&, const Node&) {} klao@959: klao@959: OutEdgeIt& operator++() { return *this; } klao@959: // Edge operator*() const { return INVALID; } klao@959: klao@961: bool operator==(const OutEdgeIt&) const { return true;} klao@961: bool operator!=(const OutEdgeIt&) const { return true;} klao@959: }; klao@959: klao@959: }; klao@959: klao@959: template klao@959: struct IterableGraphComponentConcept { klao@959: void constraints() { klao@961: function_requires< BaseIterableGraphComponentConcept >(); klao@961: 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@961: function_requires< GraphIteratorConcept >(); klao@961: function_requires< GraphIteratorConcept >(); klao@961: function_requires< GraphIncIteratorConcept >(); klao@961: function_requires< GraphIncIteratorConcept >(); klao@959: } 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@961: function_requires< BaseGraphComponentConcept >(); 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@961: function_requires< BaseGraphComponentConcept >(); 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@961: function_requires< BaseGraphComponentConcept >(); 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@961: function_requires< BaseGraphComponentConcept >(); 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