belmann_ford:
authorklao
Sat, 10 Dec 2005 19:38:53 +0000
changeset 18572e3a4481901e
parent 1856 3f0558065bcd
child 1858 a5b6d941ed52
belmann_ford:
* run() with length limit
* bugfix in processNextRound()
lemon/belmann_ford.h
     1.1 --- a/lemon/belmann_ford.h	Thu Dec 08 14:16:08 2005 +0000
     1.2 +++ b/lemon/belmann_ford.h	Sat Dec 10 19:38:53 2005 +0000
     1.3 @@ -430,7 +430,7 @@
     1.4        std::vector<Node> nextProcess;
     1.5        std::vector<Value> values(_process.size());
     1.6        for (int i = 0; i < (int)_process.size(); ++i) {
     1.7 -	values[i] = _dist[_process[i]];
     1.8 +	values[i] = (*_dist)[_process[i]];
     1.9        }
    1.10        for (int i = 0; i < (int)_process.size(); ++i) {
    1.11  	for (OutEdgeIt it(*graph, _process[i]); it != INVALID; ++it) {
    1.12 @@ -555,6 +555,27 @@
    1.13        start();
    1.14      }
    1.15      
    1.16 +    /// \brief Runs %BelmannFord algorithm with limited path length 
    1.17 +    /// from node \c s.
    1.18 +    ///    
    1.19 +    /// This method runs the %BelmannFord algorithm from a root node \c s
    1.20 +    /// in order to compute the shortest path with at most \c len edges 
    1.21 +    /// to each node. The algorithm computes
    1.22 +    /// - The shortest path tree.
    1.23 +    /// - The distance of each node from the root.
    1.24 +    ///
    1.25 +    /// \note d.run(s, len) is just a shortcut of the following code.
    1.26 +    /// \code
    1.27 +    ///  d.init();
    1.28 +    ///  d.addSource(s);
    1.29 +    ///  d.limitedStart(len);
    1.30 +    /// \endcode
    1.31 +    void run(Node s, int len) {
    1.32 +      init();
    1.33 +      addSource(s);
    1.34 +      limitedStart(len);
    1.35 +    }
    1.36 +    
    1.37      ///@}
    1.38  
    1.39      /// \name Query Functions