gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Small fixes related to BellmanFord (#51) - Add a missing #include. - Add a missing const keyword for negativeCycle(). - Test if negativeCycle() is const function.
0 2 0
default
2 files changed with 4 insertions and 1 deletions:
↑ Collapse diff ↑
Ignore white space 6 line context
... ...
@@ -20,12 +20,13 @@
20 20
#define LEMON_BELLMAN_FORD_H
21 21

	
22 22
/// \ingroup shortest_path
23 23
/// \file
24 24
/// \brief Bellman-Ford algorithm.
25 25

	
26
#include <lemon/list_graph.h>
26 27
#include <lemon/bits/path_dump.h>
27 28
#include <lemon/core.h>
28 29
#include <lemon/error.h>
29 30
#include <lemon/maps.h>
30 31
#include <lemon/path.h>
31 32

	
... ...
@@ -772,13 +773,13 @@
772 773

	
773 774
    /// \brief Gives back a negative cycle.
774 775
    ///    
775 776
    /// This function gives back a directed cycle with negative total
776 777
    /// length if the algorithm has already found one.
777 778
    /// Otherwise it gives back an empty path.
778
    lemon::Path<Digraph> negativeCycle() {
779
    lemon::Path<Digraph> negativeCycle() const {
779 780
      typename Digraph::template NodeMap<int> state(*_gr, -1);
780 781
      lemon::Path<Digraph> cycle;
781 782
      for (int i = 0; i < int(_process.size()); ++i) {
782 783
        if (state[_process[i]] != -1) continue;
783 784
        for (Node v = _process[i]; (*_pred)[v] != INVALID;
784 785
             v = _gr->source((*_pred)[v])) {
Ignore white space 12 line context
... ...
@@ -93,12 +93,13 @@
93 93
    e  = const_bf_test.predArc(t);
94 94
    s  = const_bf_test.predNode(t);
95 95
    b  = const_bf_test.reached(t);
96 96
    d  = const_bf_test.distMap();
97 97
    p  = const_bf_test.predMap();
98 98
    pp = const_bf_test.path(t);
99
    pp = const_bf_test.negativeCycle();
99 100
    
100 101
    for (BF::ActiveIt it(const_bf_test); it != INVALID; ++it) {}
101 102
  }
102 103
  {
103 104
    BF::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
104 105
      ::SetDistMap<concepts::ReadWriteMap<Node,Value> >
... ...
@@ -129,12 +130,13 @@
129 130

	
130 131
    l  = bf_test.dist(t);
131 132
    e  = bf_test.predArc(t);
132 133
    s  = bf_test.predNode(t);
133 134
    b  = bf_test.reached(t);
134 135
    pp = bf_test.path(t);
136
    pp = bf_test.negativeCycle();
135 137
  }
136 138
}
137 139

	
138 140
void checkBellmanFordFunctionCompile()
139 141
{
140 142
  typedef int Value;
0 comments (0 inline)