src/lemon/bfs.h
changeset 1347 c0f6f251e893
parent 1270 806451fd084b
child 1359 1581f961cfaa
equal deleted inserted replaced
7:ca9a90d96962 8:42793fe81212
   651     ///Before the use of these functions,
   651     ///Before the use of these functions,
   652     ///either run() or start() must be called.
   652     ///either run() or start() must be called.
   653     
   653     
   654     ///@{
   654     ///@{
   655 
   655 
       
   656     ///Copies the shortest path to \c t into \c p
       
   657     
       
   658     ///This function copies the shortest path to \c t into \c p.
       
   659     ///If it \c \t is a source itself or unreachable, then it does not
       
   660     ///alter \c p.
       
   661     ///\todo Is it the right way to handle unreachable nodes?
       
   662     ///\return Returns \c true if a path to \c t was actually copied to \c p,
       
   663     ///\c false otherwise.
       
   664     ///\sa DirPath
       
   665     template<class P>
       
   666     bool getPath(P &p,Node t) 
       
   667     {
       
   668       if(reached(t)) {
       
   669 	p.clear();
       
   670 	typename P::Builder b(p);
       
   671 	for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
       
   672 	  b.pushFront(pred(t));
       
   673 	b.commit();
       
   674 	return true;
       
   675       }
       
   676       return false;
       
   677     }
       
   678 
   656     ///The distance of a node from the root(s).
   679     ///The distance of a node from the root(s).
   657 
   680 
   658     ///Returns the distance of a node from the root(s).
   681     ///Returns the distance of a node from the root(s).
   659     ///\pre \ref run() must be called before using this function.
   682     ///\pre \ref run() must be called before using this function.
   660     ///\warning If node \c v in unreachable from the root(s) the return value
   683     ///\warning If node \c v in unreachable from the root(s) the return value