lemon/dijkstra.h
changeset 2335 27aa03cd3121
parent 2269 fb1c634fff29
child 2354 3609c77b77be
     1.1 --- a/lemon/dijkstra.h	Fri Jan 05 10:59:18 2007 +0000
     1.2 +++ b/lemon/dijkstra.h	Mon Jan 08 10:39:59 2007 +0000
     1.3 @@ -27,10 +27,12 @@
     1.4  
     1.5  #include <lemon/list_graph.h>
     1.6  #include <lemon/bin_heap.h>
     1.7 +#include <lemon/bits/path_dump.h>
     1.8  #include <lemon/bits/invalid.h>
     1.9  #include <lemon/error.h>
    1.10  #include <lemon/maps.h>
    1.11  
    1.12 +
    1.13  namespace lemon {
    1.14  
    1.15    template<class T> T dijkstraZero() {return 0;}
    1.16 @@ -717,28 +719,17 @@
    1.17      
    1.18      ///@{
    1.19  
    1.20 -    ///Copies the shortest path to \c t into \c p
    1.21 +    typedef PredMapPath<Graph, PredMap> Path;
    1.22 +
    1.23 +    ///Gives back the shortest path.
    1.24      
    1.25 -    ///This function copies the shortest path to \c t into \c p.
    1.26 -    ///If it \c t is a source itself or unreachable, then it does not
    1.27 -    ///alter \c p.
    1.28 -    ///\return Returns \c true if a path to \c t was actually copied to \c p,
    1.29 -    ///\c false otherwise.
    1.30 -    ///\sa DirPath
    1.31 -    template<class P>
    1.32 -    bool getPath(P &p,Node t) 
    1.33 +    ///Gives back the shortest path.
    1.34 +    ///\pre The \c t should be reachable from the source.
    1.35 +    Path path(Node t) 
    1.36      {
    1.37 -      if(reached(t)) {
    1.38 -	p.clear();
    1.39 -	typename P::Builder b(p);
    1.40 -	for(b.setStartNode(t);predEdge(t)!=INVALID;t=predNode(t))
    1.41 -	  b.pushFront(predEdge(t));
    1.42 -	b.commit();
    1.43 -	return true;
    1.44 -      }
    1.45 -      return false;
    1.46 +      return Path(*G, *_pred, t);
    1.47      }
    1.48 -	  
    1.49 +
    1.50      ///The distance of a node from the root.
    1.51  
    1.52      ///Returns the distance of a node from the root.