diff -r 81e89e2b90d1 -r fc20371677b9 src/lemon/dijkstra.h --- a/src/lemon/dijkstra.h Thu Mar 31 13:30:27 2005 +0000 +++ b/src/lemon/dijkstra.h Thu Mar 31 13:31:39 2005 +0000 @@ -20,6 +20,8 @@ ///\ingroup flowalgs ///\file ///\brief Dijkstra algorithm. +/// +///\todo getPath() should be implemented! (also for BFS and DFS) #include #include @@ -655,6 +657,29 @@ ///@{ + ///Copies the shortest path to \c t into \c p + + ///This function copies the shortest path 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. ///Returns the distance of a node from the root.