# HG changeset patch # User Alpar Juttner # Date 2010-06-25 05:48:27 # Node ID 949510b70df9fce40378825d07f2ff809bb342c5 # Parent 4f8b22521b4ab67bae3bd7daad08675da0719cc0 # Parent bb70ad62c95fd75d6bd134451a406df9bd0eda12 Merge bugfix #372 to branch 1.1 diff --git a/lemon/preflow.h b/lemon/preflow.h --- a/lemon/preflow.h +++ b/lemon/preflow.h @@ -558,12 +558,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(); @@ -629,14 +635,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(); @@ -702,19 +716,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.