lemon/dag_shortest_path.h
changeset 2346 c06a956a92fa
parent 2260 4274224f8a7d
child 2391 14a343be7a5a
equal deleted inserted replaced
7:27867efbfba8 8:3a7014d4342a
   720     /// Before the use of these functions,
   720     /// Before the use of these functions,
   721     /// either run() or start() must be called.
   721     /// either run() or start() must be called.
   722     
   722     
   723     ///@{
   723     ///@{
   724 
   724 
   725     /// \brief Copies the shortest path to \c t into \c p
   725     typedef PredMapPath<Graph, PredMap> Path;
   726     ///    
   726 
   727     /// This function copies the shortest path to \c t into \c p.
   727     ///Gives back the shortest path.
   728     /// If it \c t is a source itself or unreachable, then it does not
   728     
   729     /// alter \c p.
   729     ///Gives back the shortest path.
   730     ///
   730     ///\pre The \c t should be reachable from the source.
   731     /// \return Returns \c true if a path to \c t was actually copied to \c p,
   731     Path path(Node t) 
   732     /// \c false otherwise.
   732     {
   733     /// \sa DirPath
   733       return Path(*graph, *_pred, t);
   734     template <typename Path>
       
   735     bool getPath(Path &p, Node t) {
       
   736       if(reached(t)) {
       
   737 	p.clear();
       
   738 	typename Path::Builder b(p);
       
   739 	for(b.setStartNode(t);predEdge(t)!=INVALID;t=predNode(t))
       
   740 	  b.pushFront(predEdge(t));
       
   741 	b.commit();
       
   742 	return true;
       
   743       }
       
   744       return false;
       
   745     }
   734     }
   746 	  
   735 	  
   747     /// \brief The distance of a node from the root.
   736     /// \brief The distance of a node from the root.
   748     ///
   737     ///
   749     /// Returns the distance of a node from the root.
   738     /// Returns the distance of a node from the root.