1.1 --- a/src/lemon/dfs.h Thu Mar 31 13:30:27 2005 +0000
1.2 +++ b/src/lemon/dfs.h Thu Mar 31 13:31:39 2005 +0000
1.3 @@ -660,6 +660,29 @@
1.4
1.5 ///@{
1.6
1.7 + ///Copies the path to \c t on the DFS tree into \c p
1.8 +
1.9 + ///This function copies the path on the DFS tree to \c t into \c p.
1.10 + ///If it \c \t is a source itself or unreachable, then it does not
1.11 + ///alter \c p.
1.12 + ///\todo Is it the right way to handle unreachable nodes?
1.13 + ///\return Returns \c true if a path to \c t was actually copied to \c p,
1.14 + ///\c false otherwise.
1.15 + ///\sa DirPath
1.16 + template<class P>
1.17 + bool getPath(P &p,Node t)
1.18 + {
1.19 + if(reached(t)) {
1.20 + p.clear();
1.21 + typename P::Builder b(p);
1.22 + for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
1.23 + b.pushFront(pred(t));
1.24 + b.commit();
1.25 + return true;
1.26 + }
1.27 + return false;
1.28 + }
1.29 +
1.30 ///The distance of a node from the root(s).
1.31
1.32 ///Returns the distance of a node from the root(s).