diff -r 4cade8579363 -r 7a98fe2ed989 lemon/floyd_warshall.h --- a/lemon/floyd_warshall.h Mon Oct 24 17:03:02 2005 +0000 +++ b/lemon/floyd_warshall.h Wed Oct 26 10:50:47 2005 +0000 @@ -392,9 +392,9 @@ for (NodeIt it(*graph); it != INVALID; ++it) { for (NodeIt jt(*graph); jt != INVALID; ++jt) { _pred->set(it, jt, INVALID); - _dist->set(it, jt, it == jt ? - OperationTraits::zero() : OperationTraits::infinity()); + _dist->set(it, jt, OperationTraits::infinity()); } + _dist->set(it, it, OperationTraits::zero()); } for (EdgeIt it(*graph); it != INVALID; ++it) { Node source = graph->source(it); @@ -427,6 +427,24 @@ } } } + + /// \brief Executes the algorithm and checks the negative circles. + /// + /// This method runs the %FloydWarshall algorithm in order to compute + /// the shortest path to each node pairs. If there is a negative circle + /// in the graph it gives back false. + /// The algorithm computes + /// - The shortest path tree for each node. + /// - The distance between each node pairs. + bool checkedStart() { + start(); + for (NodeIt it(*graph); it != INVALID; ++it) { + if (OperationTraits::less((*dist)(it, it), OperationTraits::zero())) { + return false; + } + } + return true; + } /// \brief Runs %FloydWarshall algorithm. ///