1.1 --- a/lemon/preflow.h Wed Sep 22 09:32:53 2010 +0200
1.2 +++ b/lemon/preflow.h Mon Feb 28 09:58:07 2011 +0100
1.3 @@ -543,9 +543,6 @@
1.4 if ((*_level)[u] == _level->maxLevel()) continue;
1.5 _flow->set(e, (*_capacity)[e]);
1.6 (*_excess)[u] += rem;
1.7 - if (u != _target && !_level->active(u)) {
1.8 - _level->activate(u);
1.9 - }
1.10 }
1.11 }
1.12 for (InArcIt e(_graph, _source); e != INVALID; ++e) {
1.13 @@ -555,11 +552,12 @@
1.14 if ((*_level)[v] == _level->maxLevel()) continue;
1.15 _flow->set(e, 0);
1.16 (*_excess)[v] += rem;
1.17 - if (v != _target && !_level->active(v)) {
1.18 - _level->activate(v);
1.19 - }
1.20 }
1.21 }
1.22 + for (NodeIt n(_graph); n != INVALID; ++n)
1.23 + if(n!=_source && n!=_target && _tolerance.positive((*_excess)[n]))
1.24 + _level->activate(n);
1.25 +
1.26 return true;
1.27 }
1.28
2.1 --- a/test/preflow_test.cc Wed Sep 22 09:32:53 2010 +0200
2.2 +++ b/test/preflow_test.cc Mon Feb 28 09:58:07 2011 +0100
2.3 @@ -156,6 +156,30 @@
2.4 return true;
2.5 }
2.6
2.7 +void initFlowTest()
2.8 +{
2.9 + DIGRAPH_TYPEDEFS(SmartDigraph);
2.10 +
2.11 + SmartDigraph g;
2.12 + SmartDigraph::ArcMap<int> cap(g),iflow(g);
2.13 + Node s=g.addNode(); Node t=g.addNode();
2.14 + Node n1=g.addNode(); Node n2=g.addNode();
2.15 + Arc a;
2.16 + a=g.addArc(s,n1); cap[a]=20; iflow[a]=20;
2.17 + a=g.addArc(n1,n2); cap[a]=10; iflow[a]=0;
2.18 + a=g.addArc(n2,t); cap[a]=20; iflow[a]=0;
2.19 +
2.20 + Preflow<SmartDigraph> pre(g,cap,s,t);
2.21 + pre.init(iflow);
2.22 + pre.startFirstPhase();
2.23 + check(pre.flowValue() == 10, "The incorrect max flow value.");
2.24 + check(pre.minCut(s), "Wrong min cut (Node s).");
2.25 + check(pre.minCut(n1), "Wrong min cut (Node n1).");
2.26 + check(!pre.minCut(n2), "Wrong min cut (Node n2).");
2.27 + check(!pre.minCut(t), "Wrong min cut (Node t).");
2.28 +}
2.29 +
2.30 +
2.31 int main() {
2.32
2.33 typedef SmartDigraph Digraph;
2.34 @@ -246,5 +270,7 @@
2.35 check(preflow_test.flowValue() == min_cut_value,
2.36 "The max flow value or the three min cut values are incorrect.");
2.37
2.38 + initFlowTest();
2.39 +
2.40 return 0;
2.41 }