diff -r 81e89e2b90d1 -r fc20371677b9 src/lemon/dfs.h --- a/src/lemon/dfs.h Thu Mar 31 13:30:27 2005 +0000 +++ b/src/lemon/dfs.h Thu Mar 31 13:31:39 2005 +0000 @@ -660,6 +660,29 @@ ///@{ + ///Copies the path to \c t on the DFS tree into \c p + + ///This function copies the path on the DFS tree to \c t into \c p. + ///If it \c \t is a source itself or unreachable, then it does not + ///alter \c p. + ///\todo Is it the right way to handle unreachable nodes? + ///\return Returns \c true if a path to \c t was actually copied to \c p, + ///\c false otherwise. + ///\sa DirPath + template + bool getPath(P &p,Node t) + { + if(reached(t)) { + p.clear(); + typename P::Builder b(p); + for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t)) + b.pushFront(pred(t)); + b.commit(); + return true; + } + return false; + } + ///The distance of a node from the root(s). ///Returns the distance of a node from the root(s).