# HG changeset patch # User Alpar Juttner # Date 2010-06-25 05:54:56 # Node ID f63fd24c0aea5397f745970ef7e8c6ce4fc481f8 # Parent cbf32bf9595467fe394c25fa404c7d4283e43eb6 # Parent bb70ad62c95fd75d6bd134451a406df9bd0eda12 Merge bugfix #372 to branch 1.2 diff --git a/lemon/preflow.h b/lemon/preflow.h --- a/lemon/preflow.h +++ b/lemon/preflow.h @@ -576,12 +576,18 @@ void startFirstPhase() { _phase = true; - Node n = _level->highestActive(); - int level = _level->highestActiveLevel(); - while (n != INVALID) { + while (true) { int num = _node_num; - while (num > 0 && n != INVALID) { + Node n = INVALID; + int level = -1; + + while (num > 0) { + n = _level->highestActive(); + if (n == INVALID) goto first_phase_done; + level = _level->highestActiveLevel(); + --num; + Value excess = (*_excess)[n]; int new_level = _level->maxLevel(); @@ -647,14 +653,22 @@ } else { _level->deactivate(n); } - - n = _level->highestActive(); - level = _level->highestActiveLevel(); - --num; } num = _node_num * 20; - while (num > 0 && n != INVALID) { + while (num > 0) { + while (level >= 0 && _level->activeFree(level)) { + --level; + } + if (level == -1) { + n = _level->highestActive(); + level = _level->highestActiveLevel(); + if (n == INVALID) goto first_phase_done; + } else { + n = _level->activeOn(level); + } + --num; + Value excess = (*_excess)[n]; int new_level = _level->maxLevel(); @@ -720,19 +734,9 @@ } else { _level->deactivate(n); } - - while (level >= 0 && _level->activeFree(level)) { - --level; - } - if (level == -1) { - n = _level->highestActive(); - level = _level->highestActiveLevel(); - } else { - n = _level->activeOn(level); - } - --num; } } + first_phase_done:; } /// \brief Starts the second phase of the preflow algorithm.