src/lemon/dfs.h
changeset 1286 692948b894e8
parent 1236 fd24f16e0d73
child 1359 1581f961cfaa
equal deleted inserted replaced
7:9fc7f448cd5c 8:3406311d7e27
   658     ///Before the use of these functions,
   658     ///Before the use of these functions,
   659     ///either run() or start() must be called.
   659     ///either run() or start() must be called.
   660     
   660     
   661     ///@{
   661     ///@{
   662 
   662 
       
   663     ///Copies the path to \c t on the DFS tree into \c p
       
   664     
       
   665     ///This function copies the path on the DFS tree to \c t into \c p.
       
   666     ///If it \c \t is a source itself or unreachable, then it does not
       
   667     ///alter \c p.
       
   668     ///\todo Is it the right way to handle unreachable nodes?
       
   669     ///\return Returns \c true if a path to \c t was actually copied to \c p,
       
   670     ///\c false otherwise.
       
   671     ///\sa DirPath
       
   672     template<class P>
       
   673     bool getPath(P &p,Node t) 
       
   674     {
       
   675       if(reached(t)) {
       
   676 	p.clear();
       
   677 	typename P::Builder b(p);
       
   678 	for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
       
   679 	  b.pushFront(pred(t));
       
   680 	b.commit();
       
   681 	return true;
       
   682       }
       
   683       return false;
       
   684     }
       
   685 
   663     ///The distance of a node from the root(s).
   686     ///The distance of a node from the root(s).
   664 
   687 
   665     ///Returns the distance of a node from the root(s).
   688     ///Returns the distance of a node from the root(s).
   666     ///\pre \ref run() must be called before using this function.
   689     ///\pre \ref run() must be called before using this function.
   667     ///\warning If node \c v in unreachable from the root(s) the return value
   690     ///\warning If node \c v in unreachable from the root(s) the return value