src/lemon/concept/graph_component.h
changeset 1021 fd1d073b6557
parent 989 ca95f8b5c931
child 1022 567f392d1d2e
equal deleted inserted replaced
7:4ff57dbf10c1 8:7b696ca4cfb2
   503 
   503 
   504     /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
   504     /// \note Because InEdgeIt and OutEdgeIt may not inherit from the same
   505     /// base class, the _selector is a additional template parameter. For 
   505     /// base class, the _selector is a additional template parameter. For 
   506     /// InEdgeIt you should instantiate it with character 'i' and for 
   506     /// InEdgeIt you should instantiate it with character 'i' and for 
   507     /// OutEdgeIt with 'o'.
   507     /// OutEdgeIt with 'o'.
   508     /// \todo check the name of the concept GraphIncEdgeIterator
   508     /// \todo Is this a good name for this concept?
   509     template <typename _Graph, char _selector>
   509     template <typename Graph,
   510     class GraphIncEdgeIterator : public _Graph::Edge {
   510 	      typename Edge = typename Graph::Edge,
       
   511 	      char _selector = '0'>
       
   512     class GraphIncIterator : public Edge {
   511     public:
   513     public:
   512       /// Default constructor.
   514       /// Default constructor.
   513       
   515       
   514       /// @warning The default constructor sets the iterator
   516       /// @warning The default constructor sets the iterator
   515       /// to an undefined value.
   517       /// to an undefined value.
   516       GraphIncEdgeIterator() {}
   518       GraphIncIterator() {}
   517       /// Copy constructor.
   519       /// Copy constructor.
   518       
   520       
   519       /// Copy constructor.
   521       /// Copy constructor.
   520       ///
   522       ///
   521       GraphIncEdgeIterator(GraphIncEdgeIterator const&) {}
   523       GraphIncIterator(GraphIncIterator const&) {}
   522       /// Sets the iterator to the first edge incoming into or outgoing from the node.
   524       /// Sets the iterator to the first edge incoming into or outgoing from the node.
   523       
   525       
   524       /// Sets the iterator to the first edge incoming into or outgoing from the node.
   526       /// Sets the iterator to the first edge incoming into or outgoing from the node.
   525       ///
   527       ///
   526       explicit GraphIncEdgeIterator(const _Graph&, const typename _Graph::Node&) {}
   528       explicit GraphIncIterator(const Graph&, const typename Graph::Node&) {}
   527       /// Invalid constructor \& conversion.
   529       /// Invalid constructor \& conversion.
   528 
   530 
   529       /// This constructor initializes the item to be invalid.
   531       /// This constructor initializes the item to be invalid.
   530       /// \sa Invalid for more details.
   532       /// \sa Invalid for more details.
   531       GraphIncEdgeIterator(Invalid) {}
   533       GraphIncIterator(Invalid) {}
   532       /// Assign operator for nodes.
   534       /// Assign operator for nodes.
   533 
   535 
   534       /// The nodes are assignable. 
   536       /// The nodes are assignable. 
   535       ///
   537       ///
   536       GraphIncEdgeIterator& operator=(GraphIncEdgeIterator const&) { return *this; }      
   538       GraphIncIterator& operator=(GraphIncIterator const&) { return *this; }      
   537       /// Next edge.
   539       /// Next edge.
   538 
   540 
   539       /// Assign the iterator to the next node.
   541       /// Assign the iterator to the next node.
   540       ///
   542       ///
   541       GraphIncEdgeIterator& operator++() { return *this; }
   543       GraphIncIterator& operator++() { return *this; }
       
   544 
   542       //	Node operator*() const { return INVALID; }
   545       //	Node operator*() const { return INVALID; }
       
   546 
   543       /// Equality operator
   547       /// Equality operator
   544 
   548 
   545       /// Two iterators are equal if and only if they point to the
   549       /// Two iterators are equal if and only if they point to the
   546       /// same object or both are invalid.
   550       /// same object or both are invalid.
   547       bool operator==(const GraphIncEdgeIterator&) const { return true;}
   551       bool operator==(const GraphIncIterator&) const { return true;}
       
   552 
   548       /// Inequality operator
   553       /// Inequality operator
   549 	
   554 	
   550       /// \sa operator==(Node n)
   555       /// \sa operator==(Node n)
   551       ///
   556       ///
   552       bool operator!=(const GraphIncEdgeIterator&) const { return true;}
   557       bool operator!=(const GraphIncIterator&) const { return true;}
   553 
   558 
   554       template <typename _GraphIncEdgeIterator>
   559       template <typename _GraphIncIterator>
   555       struct Constraints {
   560       struct Constraints {
   556 	typedef typename _Graph::Node Node;
   561 	typedef typename Graph::Node Node;
   557 	typedef typename _Graph::Edge Edge;
   562 	void constraints() {
   558 	void constraints() {
   563 	  checkConcept<GraphItem<'e'>, _GraphIncIterator>();
   559 	  checkConcept<GraphItem<'e'>, _GraphIncEdgeIterator>();
   564 	  _GraphIncIterator it1(graph, node);
   560 	  _GraphIncEdgeIterator it1(graph, node);
       
   561 	  /// \todo Do we need OutEdgeIt(Edge) kind of constructor?
   565 	  /// \todo Do we need OutEdgeIt(Edge) kind of constructor?
   562 	  //	_GraphIncEdgeIterator it2(edge);
   566 	  //	_GraphIncIterator it2(edge);
   563 	  _GraphIncEdgeIterator it2;
   567 	  _GraphIncIterator it2;
   564 
   568 
   565 	  it2 = ++it1;
   569 	  it2 = ++it1;
   566 	  ++it2 = it1;
   570 	  ++it2 = it1;
   567 	  ++(++it1);
   571 	  ++(++it1);
   568 	  Edge e = it1;
   572 	  Edge e = it1;
   569 	  e = it2;
   573 	  e = it2;
   570 	}
   574 	}
   571 
   575 
   572 	Edge& edge;
   576 	Edge& edge;
   573 	Node& node;
   577 	Node& node;
   574 	_Graph& graph;
   578 	Graph& graph;
   575       };
   579       };
   576     };
   580     };
       
   581 
       
   582 
   577     /// An empty iterable base graph class.
   583     /// An empty iterable base graph class.
   578   
   584   
   579     /// This class provides beside the core graph features
   585     /// This class provides beside the core graph features
   580     /// iterator based iterable interface for the graph structure.
   586     /// iterator based iterable interface for the graph structure.
   581     /// This concept is part of the StaticGraphConcept.
   587     /// This concept is part of the StaticGraphConcept.
   600       typedef GraphIterator<Graph, Edge> EdgeIt;
   606       typedef GraphIterator<Graph, Edge> EdgeIt;
   601       /// This iterator goes trough the incoming edges of a node.
   607       /// This iterator goes trough the incoming edges of a node.
   602 
   608 
   603       /// This iterator goes trough the \e inccoming edges of a certain node
   609       /// This iterator goes trough the \e inccoming edges of a certain node
   604       /// of a graph.
   610       /// of a graph.
   605       typedef GraphIncEdgeIterator<Graph, 'i'> InEdgeIt;
   611       typedef GraphIncIterator<Graph, Edge, 'i'> InEdgeIt;
   606       /// This iterator goes trough the outgoing edges of a node.
   612       /// This iterator goes trough the outgoing edges of a node.
   607 
   613 
   608       /// This iterator goes trough the \e outgoing edges of a certain node
   614       /// This iterator goes trough the \e outgoing edges of a certain node
   609       /// of a graph.
   615       /// of a graph.
   610       typedef GraphIncEdgeIterator<Graph, 'o'> OutEdgeIt;
   616       typedef GraphIncIterator<Graph, Edge, 'o'> OutEdgeIt;
   611     };
   617     };
   612     
   618     
   613     template <typename _Graph> 
   619     template <typename _Graph> 
   614     struct Constraints {
   620     struct Constraints {
   615       void constraints() {
   621       void constraints() {
   616   	checkConcept< BaseGraphComponent, _Graph>();
   622   	checkConcept< BaseGraphComponent, _Graph>();
   617 
   623 
   618 	checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >();
   624 	checkConcept<GraphIterator<_Graph, typename _Graph::Edge>, typename _Graph::EdgeIt >();
   619 	checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >();
   625 	checkConcept<GraphIterator<_Graph, typename _Graph::Node>, typename _Graph::NodeIt >();
   620 	checkConcept<GraphIncEdgeIterator<_Graph, 'i'>, typename _Graph::InEdgeIt >();
   626 	checkConcept<GraphIncIterator<_Graph>, typename _Graph::InEdgeIt >();
   621 	checkConcept<GraphIncEdgeIterator<_Graph, 'o'>, typename _Graph::OutEdgeIt >();
   627 	checkConcept<GraphIncIterator<_Graph>, typename _Graph::OutEdgeIt >();
   622       }
   628       }
   623     };
   629     };
   624 
   630 
   625 
   631 
   626     template <typename Graph, typename Item, typename _Value>
   632     template <typename Graph, typename Item, typename _Value>