src/lemon/concept/graph_component.h
changeset 981 2e34b796d532
parent 964 2c0c20e90116
child 986 e997802b855c
equal deleted inserted replaced
3:465093361bd9 4:06c57b251ce2
   159 	/// This constructor initializes the iterator to be invalid.
   159 	/// This constructor initializes the iterator to be invalid.
   160 	/// \sa Invalid for more details.
   160 	/// \sa Invalid for more details.
   161 	Node(Invalid) {}
   161 	Node(Invalid) {}
   162 
   162 
   163 
   163 
       
   164 	/// Assign operator for nodes.
       
   165 
       
   166 	/// The nodes are assignable. 
       
   167 	///
   164 	Node& operator=(const Node&) { return *this;}
   168 	Node& operator=(const Node&) { return *this;}
   165 
   169 
   166 	/// Equality operator.
   170 	/// Equality operator.
   167 
   171 
   168 	/// Two iterators are equal if and only if they represents the
   172 	/// Two iterators are equal if and only if they represents the
   208 
   212 
   209 	/// This constructor initializes the iterator to be invalid.
   213 	/// This constructor initializes the iterator to be invalid.
   210 	/// \sa Invalid for more details.
   214 	/// \sa Invalid for more details.
   211 	Edge(Invalid) {}
   215 	Edge(Invalid) {}
   212 
   216 
   213 
   217 	/// Assign operator for edges.
       
   218 
       
   219 	/// The edges are assignable. 
       
   220 	///
   214 	Edge& operator=(const Edge&) { return *this;}
   221 	Edge& operator=(const Edge&) { return *this;}
   215 
   222 
   216 	/// Equality operator.
   223 	/// Equality operator.
   217 
   224 
   218 	/// Two iterators are equal if and only if they represents the
   225 	/// Two iterators are equal if and only if they represents the
   427 
   434 
   428       /// Gives back an integer greater or equal to the maximum Node id. 
   435       /// Gives back an integer greater or equal to the maximum Node id. 
   429 
   436 
   430       /// Gives back an integer greater or equal to the maximum Node id. 
   437       /// Gives back an integer greater or equal to the maximum Node id. 
   431       ///
   438       ///
   432       int maxEdgeId() const { return -1;}
   439       int maxId(Node = INVALID) const { return -1;}
   433 
   440 
   434       /// Gives back an integer greater or equal to the maximum Edge id. 
   441       /// Gives back an integer greater or equal to the maximum Edge id. 
   435 
   442 
   436       /// Gives back an integer greater or equal to the maximum Edge id. 
   443       /// Gives back an integer greater or equal to the maximum Edge id. 
   437       ///
   444       ///
   438       int maxNodeId() const { return -1;}
   445       int maxId(Edge = INVALID) const { return -1;}
   439     };
   446     };
   440 
   447 
   441     /// Concept check structure for MaxIdableBaseGraph.
   448     /// Concept check structure for MaxIdableBaseGraph.
   442 
   449 
   443     /// Concept check structure for MaxIdableBaseGraph.
   450     /// Concept check structure for MaxIdableBaseGraph.
   445     template <typename Graph>
   452     template <typename Graph>
   446     struct MaxIDableGraphComponentConcept {
   453     struct MaxIDableGraphComponentConcept {
   447 
   454 
   448       void constraints() {
   455       void constraints() {
   449 	function_requires< BaseGraphComponentConcept<Graph> >();
   456 	function_requires< BaseGraphComponentConcept<Graph> >();
   450 	int nid = graph.maxEdgeId();
   457 	int nid = graph.maxId(typename Graph::Node());
   451 	ignore_unused_variable_warning(nid);
   458 	ignore_unused_variable_warning(nid);
   452 	int eid = graph.maxNodeId();
   459 	int eid = graph.maxId(typename Graph::Edge());
   453 	ignore_unused_variable_warning(eid);
   460 	ignore_unused_variable_warning(eid);
   454       }
   461       }
   455 
   462 
   456       const Graph& graph;
   463       const Graph& graph;
   457     };
   464     };
   660 	function_requires< GraphIncIteratorConcept<InEdgeIt, Graph> >();
   667 	function_requires< GraphIncIteratorConcept<InEdgeIt, Graph> >();
   661       }
   668       }
   662     };
   669     };
   663 
   670 
   664 
   671 
   665     class IdMappableGraphComponent : virtual public BaseGraphComponent {
       
   666 
       
   667       typedef IdMappableGraphComponent Graph;
       
   668 
       
   669     public:
       
   670 
       
   671       typedef BaseGraphComponent::Node Node;
       
   672       typedef BaseGraphComponent::Edge Edge;
       
   673 
       
   674       class NodeIdMap : public ReadMap<Node, int> {
       
   675       public:
       
   676 	NodeIdMap(const Graph&) {}
       
   677 	int maxId() const { return -1;}
       
   678       };
       
   679 
       
   680       class EdgeIdMap : public ReadMap<Edge, int> {
       
   681       public:
       
   682 	EdgeIdMap(const Graph&) {}
       
   683 	int maxId() const { return -1;}
       
   684       };
       
   685 
       
   686     };
       
   687     
       
   688     template <typename Graph>
       
   689     struct IdMappableGraphComponentConcept {
       
   690       void constraints() {	
       
   691 	function_requires< BaseGraphComponentConcept<Graph> >();
       
   692 	{
       
   693 	  typedef typename Graph::EdgeIdMap EdgeIdMap;
       
   694 	  function_requires<ReadMapConcept<EdgeIdMap> >();
       
   695 	  EdgeIdMap edge_map(graph);
       
   696 	  int n = edge_map.maxId();
       
   697 	  ignore_unused_variable_warning(n);
       
   698 	}
       
   699 	{
       
   700 	  typedef typename Graph::NodeIdMap NodeIdMap;
       
   701 	  function_requires<ReadMapConcept<NodeIdMap> >();
       
   702 	  NodeIdMap node_map(graph);
       
   703 	  int n = node_map.maxId();
       
   704 	  ignore_unused_variable_warning(n);
       
   705 	}
       
   706       }
       
   707       Graph& graph;
       
   708     };
       
   709 
       
   710 
       
   711     class MappableGraphComponent : virtual public BaseGraphComponent {
   672     class MappableGraphComponent : virtual public BaseGraphComponent {
   712     public:
   673     public:
   713 
   674 
   714       typedef MappableGraphComponent Graph;
   675       typedef MappableGraphComponent Graph;
   715 
   676