diff --git a/lemon/bellman_ford.h b/lemon/bellman_ford.h --- a/lemon/bellman_ford.h +++ b/lemon/bellman_ford.h @@ -23,6 +23,7 @@ /// \file /// \brief Bellman-Ford algorithm. +#include #include #include #include @@ -775,7 +776,7 @@ /// This function gives back a directed cycle with negative total /// length if the algorithm has already found one. /// Otherwise it gives back an empty path. - lemon::Path negativeCycle() { + lemon::Path negativeCycle() const { typename Digraph::template NodeMap state(*_gr, -1); lemon::Path cycle; for (int i = 0; i < int(_process.size()); ++i) { diff --git a/test/bellman_ford_test.cc b/test/bellman_ford_test.cc --- a/test/bellman_ford_test.cc +++ b/test/bellman_ford_test.cc @@ -96,6 +96,7 @@ d = const_bf_test.distMap(); p = const_bf_test.predMap(); pp = const_bf_test.path(t); + pp = const_bf_test.negativeCycle(); for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {} } @@ -132,6 +133,7 @@ s = bf_test.predNode(t); b = bf_test.reached(t); pp = bf_test.path(t); + pp = bf_test.negativeCycle(); } }