lemon/johnson.h
changeset 2335 27aa03cd3121
parent 2263 9273fe7d850c
child 2376 0ed45a6c74b1
     1.1 --- a/lemon/johnson.h	Fri Jan 05 10:59:18 2007 +0000
     1.2 +++ b/lemon/johnson.h	Mon Jan 08 10:39:59 2007 +0000
     1.3 @@ -28,6 +28,7 @@
     1.4  #include <lemon/graph_utils.h>
     1.5  #include <lemon/dijkstra.h>
     1.6  #include <lemon/bellman_ford.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 @@ -629,27 +630,15 @@
    1.12      
    1.13      ///@{
    1.14  
    1.15 -    /// \brief Copies the shortest path to \c t into \c p
    1.16 -    ///    
    1.17 -    /// This function copies the shortest path to \c t into \c p.
    1.18 -    /// If it \c t is a source itself or unreachable, then it does not
    1.19 -    /// alter \c p.
    1.20 -    /// \return Returns \c true if a path to \c t was actually copied to \c p,
    1.21 -    /// \c false otherwise.
    1.22 -    /// \sa DirPath
    1.23 -    template <typename Path>
    1.24 -    bool getPath(Path &p, Node source, Node target) {
    1.25 -      if (connected(source, target)) {
    1.26 -	p.clear();
    1.27 -	typename Path::Builder b(target);
    1.28 -	for(b.setStartNode(target); predEdge(source, target) != INVALID;
    1.29 -	    target = predNode(target)) {
    1.30 -	  b.pushFront(predEdge(source, target));
    1.31 -	}
    1.32 -	b.commit();
    1.33 -	return true;
    1.34 -      }
    1.35 -      return false;
    1.36 +    typedef PredMatrixMapPath<Graph, PredMap> Path;
    1.37 +
    1.38 +    ///Gives back the shortest path.
    1.39 +    
    1.40 +    ///Gives back the shortest path.
    1.41 +    ///\pre The \c t should be reachable from the \c t.
    1.42 +    Path path(Node s, Node t) 
    1.43 +    {
    1.44 +      return Path(*graph, *_pred, s, t);
    1.45      }
    1.46  	  
    1.47      /// \brief The distance between two nodes.