lemon/bellman_ford.h
changeset 2372 7fcc0179fb21
parent 2335 27aa03cd3121
child 2376 0ed45a6c74b1
equal deleted inserted replaced
13:c7b8bfd178d6 14:0508b779569e
   522     /// in order to compute the shortest path to each node. The algorithm 
   522     /// in order to compute the shortest path to each node. The algorithm 
   523     /// computes 
   523     /// computes 
   524     /// - The shortest path tree.
   524     /// - The shortest path tree.
   525     /// - The distance of each node from the root(s).
   525     /// - The distance of each node from the root(s).
   526     bool checkedStart() {
   526     bool checkedStart() {
   527       int num = countNodes(*graph);
   527       int num = countNodes(*graph) - 1;
   528       for (int i = 0; i < num; ++i) {
   528       for (int i = 0; i < num; ++i) {
   529 	if (processNextWeakRound()) return true;
   529 	if (processNextWeakRound()) return true;
   530       }
   530       }
   531       return false;
   531       return _process.empty();
   532     }
   532     }
   533 
   533 
   534     /// \brief Executes the algorithm with path length limit.
   534     /// \brief Executes the algorithm with path length limit.
   535     ///
   535     ///
   536     /// \pre init() must be called and at least one node should be added
   536     /// \pre init() must be called and at least one node should be added
   582     /// in order to compute the shortest path with at most \c len edges 
   582     /// in order to compute the shortest path with at most \c len edges 
   583     /// to each node. The algorithm computes
   583     /// to each node. The algorithm computes
   584     /// - The shortest path tree.
   584     /// - The shortest path tree.
   585     /// - The distance of each node from the root.
   585     /// - The distance of each node from the root.
   586     ///
   586     ///
   587     /// \note d.run(s, len) is just a shortcut of the following code.
   587     /// \note d.run(s, num) is just a shortcut of the following code.
   588     ///\code
   588     ///\code
   589     ///  d.init();
   589     ///  d.init();
   590     ///  d.addSource(s);
   590     ///  d.addSource(s);
   591     ///  d.limitedStart(len);
   591     ///  d.limitedStart(num);
   592     ///\endcode
   592     ///\endcode
   593     void run(Node s, int len) {
   593     void run(Node s, int num) {
   594       init();
   594       init();
   595       addSource(s);
   595       addSource(s);
   596       limitedStart(len);
   596       limitedStart(num);
   597     }
   597     }
   598     
   598     
   599     ///@}
   599     ///@}
   600 
   600 
   601     /// \name Query Functions
   601     /// \name Query Functions
   606     
   606     
   607     ///@{
   607     ///@{
   608 
   608 
   609     /// \brief Lemon iterator for get a active nodes.
   609     /// \brief Lemon iterator for get a active nodes.
   610     ///
   610     ///
   611     /// Lemon iterator for get a active nodes. This class provides a
   611     /// Lemon iterator for get the active nodes. This class provides a
   612     /// common style lemon iterator which gives back a subset of the
   612     /// common style lemon iterator which gives back a subset of the
   613     /// nodes. The iterated nodes are active in the algorithm after
   613     /// nodes. The iterated nodes are active in the algorithm after
   614     /// the last phase so these should be checked in the next phase to
   614     /// the last phase so these should be checked in the next phase to
   615     /// find augmenting edges from these.
   615     /// find augmenting edges from these.
   616     class ActiveIt {
   616     class ActiveIt {