lemon/bfs.h
changeset 1763 49045f2d28d4
parent 1761 896464fe9fbb
child 1765 f15b3c09481c
equal deleted inserted replaced
10:f063e233ca99 11:5ea96e6a517f
   618     bool getPath(P &p,Node t) 
   618     bool getPath(P &p,Node t) 
   619     {
   619     {
   620       if(reached(t)) {
   620       if(reached(t)) {
   621 	p.clear();
   621 	p.clear();
   622 	typename P::Builder b(p);
   622 	typename P::Builder b(p);
   623 	for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
   623 	for(b.setStartNode(t);predEdge(t)!=INVALID;t=predNode(t))
   624 	  b.pushFront(pred(t));
   624 	  b.pushFront(predEdge(t));
   625 	b.commit();
   625 	b.commit();
   626 	return true;
   626 	return true;
   627       }
   627       }
   628       return false;
   628       return false;
   629     }
   629     }
   646     ///shortest path tree used here is equal to the shortest path tree used in
   646     ///shortest path tree used here is equal to the shortest path tree used in
   647     ///\ref predNode().
   647     ///\ref predNode().
   648     ///\pre Either \ref run() or \ref start() must be called before using
   648     ///\pre Either \ref run() or \ref start() must be called before using
   649     ///this function.
   649     ///this function.
   650     ///\todo predEdge could be a better name.
   650     ///\todo predEdge could be a better name.
   651     Edge pred(Node v) const { return (*_pred)[v];}
   651     Edge predEdge(Node v) const { return (*_pred)[v];}
   652 
   652 
   653     ///Returns the 'previous node' of the shortest path tree.
   653     ///Returns the 'previous node' of the shortest path tree.
   654 
   654 
   655     ///For a node \c v it returns the 'previous node'
   655     ///For a node \c v it returns the 'previous node'
   656     ///of the shortest path tree,
   656     ///of the shortest path tree,
   657     ///i.e. it returns the last but one node from a shortest path from the
   657     ///i.e. it returns the last but one node from a shortest path from the
   658     ///root(a) to \c /v.
   658     ///root(a) to \c /v.
   659     ///It is INVALID if \c v is unreachable from the root(s) or
   659     ///It is INVALID if \c v is unreachable from the root(s) or
   660     ///if \c v itself a root.
   660     ///if \c v itself a root.
   661     ///The shortest path tree used here is equal to the shortest path
   661     ///The shortest path tree used here is equal to the shortest path
   662     ///tree used in \ref pred().
   662     ///tree used in \ref predEdge().
   663     ///\pre Either \ref run() or \ref start() must be called before
   663     ///\pre Either \ref run() or \ref start() must be called before
   664     ///using this function.
   664     ///using this function.
   665     Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
   665     Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
   666 				  G->source((*_pred)[v]); }
   666 				  G->source((*_pred)[v]); }
   667     
   667