Small fixes related to BellmanFord (#51)
authorPeter Kovacs <kpeter@inf.elte.hu>
Mon, 28 Sep 2009 15:53:20 +0200
changeset 7816f10c6ec5a21
parent 731 0977046c60d2
child 782 ceb2756dea2a
Small fixes related to BellmanFord (#51)

- Add a missing #include.
- Add a missing const keyword for negativeCycle().
- Test if negativeCycle() is const function.
lemon/bellman_ford.h
test/bellman_ford_test.cc
     1.1 --- a/lemon/bellman_ford.h	Sat Sep 26 07:21:54 2009 +0200
     1.2 +++ b/lemon/bellman_ford.h	Mon Sep 28 15:53:20 2009 +0200
     1.3 @@ -23,6 +23,7 @@
     1.4  /// \file
     1.5  /// \brief Bellman-Ford algorithm.
     1.6  
     1.7 +#include <lemon/list_graph.h>
     1.8  #include <lemon/bits/path_dump.h>
     1.9  #include <lemon/core.h>
    1.10  #include <lemon/error.h>
    1.11 @@ -775,7 +776,7 @@
    1.12      /// This function gives back a directed cycle with negative total
    1.13      /// length if the algorithm has already found one.
    1.14      /// Otherwise it gives back an empty path.
    1.15 -    lemon::Path<Digraph> negativeCycle() {
    1.16 +    lemon::Path<Digraph> negativeCycle() const {
    1.17        typename Digraph::template NodeMap<int> state(*_gr, -1);
    1.18        lemon::Path<Digraph> cycle;
    1.19        for (int i = 0; i < int(_process.size()); ++i) {
     2.1 --- a/test/bellman_ford_test.cc	Sat Sep 26 07:21:54 2009 +0200
     2.2 +++ b/test/bellman_ford_test.cc	Mon Sep 28 15:53:20 2009 +0200
     2.3 @@ -96,6 +96,7 @@
     2.4      d  = const_bf_test.distMap();
     2.5      p  = const_bf_test.predMap();
     2.6      pp = const_bf_test.path(t);
     2.7 +    pp = const_bf_test.negativeCycle();
     2.8      
     2.9      for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {}
    2.10    }
    2.11 @@ -132,6 +133,7 @@
    2.12      s  = bf_test.predNode(t);
    2.13      b  = bf_test.reached(t);
    2.14      pp = bf_test.path(t);
    2.15 +    pp = bf_test.negativeCycle();
    2.16    }
    2.17  }
    2.18