1.1 --- a/src/lemon/dijkstra.h Thu Mar 31 13:30:27 2005 +0000
1.2 +++ b/src/lemon/dijkstra.h Thu Mar 31 13:31:39 2005 +0000
1.3 @@ -20,6 +20,8 @@
1.4 ///\ingroup flowalgs
1.5 ///\file
1.6 ///\brief Dijkstra algorithm.
1.7 +///
1.8 +///\todo getPath() should be implemented! (also for BFS and DFS)
1.9
1.10 #include <lemon/list_graph.h>
1.11 #include <lemon/bin_heap.h>
1.12 @@ -655,6 +657,29 @@
1.13
1.14 ///@{
1.15
1.16 + ///Copies the shortest path to \c t into \c p
1.17 +
1.18 + ///This function copies the shortest path to \c t into \c p.
1.19 + ///If it \c \t is a source itself or unreachable, then it does not
1.20 + ///alter \c p.
1.21 + ///\todo Is it the right way to handle unreachable nodes?
1.22 + ///\return Returns \c true if a path to \c t was actually copied to \c p,
1.23 + ///\c false otherwise.
1.24 + ///\sa DirPath
1.25 + template<class P>
1.26 + bool getPath(P &p,Node t)
1.27 + {
1.28 + if(reached(t)) {
1.29 + p.clear();
1.30 + typename P::Builder b(p);
1.31 + for(b.setStartNode(t);pred(t)!=INVALID;t=predNode(t))
1.32 + b.pushFront(pred(t));
1.33 + b.commit();
1.34 + return true;
1.35 + }
1.36 + return false;
1.37 + }
1.38 +
1.39 ///The distance of a node from the root.
1.40
1.41 ///Returns the distance of a node from the root.