lemon/bits/iterable_graph_extender.h
changeset 1778 4ba7965386fb
parent 1627 3fd1ba6e9872
child 1820 22099ef840d7
equal deleted inserted replaced
3:57ad33aca0cf 4:c80879d4331e
   214 
   214 
   215     };
   215     };
   216 
   216 
   217     class IncEdgeIt : public Parent::UndirEdge { 
   217     class IncEdgeIt : public Parent::UndirEdge { 
   218       const Graph* graph;
   218       const Graph* graph;
   219       bool forward;
   219       bool direction;
   220       friend class IterableUndirGraphExtender;
   220       friend class IterableUndirGraphExtender;
   221       template <typename G>
       
   222       friend class UndirGraphExtender;
       
   223     public:
   221     public:
   224 
   222 
   225       IncEdgeIt() { }
   223       IncEdgeIt() { }
   226 
   224 
   227       IncEdgeIt(Invalid i) : UndirEdge(i), forward(false) { }
   225       IncEdgeIt(Invalid i) : UndirEdge(i), direction(false) { }
   228 
   226 
   229       IncEdgeIt(const Graph& _graph, const Node &n)
   227       IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) {
   230 	: graph(&_graph)
   228 	_graph.firstInc(*this, direction, n);
   231       {
       
   232 	_graph._dirFirstOut(*this, n);
       
   233       }
   229       }
   234 
   230 
   235       IncEdgeIt(const Graph& _graph, const UndirEdge &ue, const Node &n)
   231       IncEdgeIt(const Graph& _graph, const UndirEdge &ue, const Node &n)
   236 	: graph(&_graph), UndirEdge(ue)
   232 	: graph(&_graph), UndirEdge(ue) {
   237       {
   233 	direction = (_graph.source(ue) == n);
   238 	forward = (_graph.source(ue) == n);
       
   239       }
   234       }
   240 
   235 
   241       IncEdgeIt& operator++() {
   236       IncEdgeIt& operator++() {
   242 	graph->_dirNextOut(*this);
   237 	graph->nextInc(*this, direction);
   243 	return *this; 
   238 	return *this; 
   244       }
   239       }
   245     };
   240     };
   246 
   241 
   247     using Parent::baseNode;
   242     using Parent::baseNode;
   249 
   244 
   250     /// Base node of the iterator
   245     /// Base node of the iterator
   251     ///
   246     ///
   252     /// Returns the base node of the iterator
   247     /// Returns the base node of the iterator
   253     Node baseNode(const IncEdgeIt &e) const {
   248     Node baseNode(const IncEdgeIt &e) const {
   254       return _dirSource(e);
   249       return e.direction ? source(e) : target(e);
   255     }
   250     }
   256     /// Running node of the iterator
   251     /// Running node of the iterator
   257     ///
   252     ///
   258     /// Returns the running node of the iterator
   253     /// Returns the running node of the iterator
   259     Node runningNode(const IncEdgeIt &e) const {
   254     Node runningNode(const IncEdgeIt &e) const {
   260       return _dirTarget(e);
   255       return e.direction ? target(e) : source(e);
   261     }
   256     }
   262 
   257 
   263     /// \brief The opposite node on the given undirected edge.
   258     /// \brief The opposite node on the given undirected edge.
   264     ///
   259     ///
   265     /// Gives back the opposite on the given undirected edge.
   260     /// Gives back the opposite on the given undirected edge.