diff -r 90defb96ee61 -r dc4dd5fc0e25 lemon/hao_orlin.h --- a/lemon/hao_orlin.h Mon Oct 06 15:08:17 2008 +0000 +++ b/lemon/hao_orlin.h Wed Oct 08 09:17:01 2008 +0000 @@ -21,13 +21,11 @@ #include #include -#include #include #include #include -#include -#include +#include /// \file /// \ingroup min_cut @@ -293,10 +291,11 @@ _flow->set(e, (*_capacity)[e]); _excess->set(u, (*_excess)[u] + (*_capacity)[e]); if (!(*_active)[u] && u != _source) { - activate(u); + activate(u); } } } + if ((*_active)[target]) { deactivate(target); } @@ -308,7 +307,6 @@ } } - while (true) { while (_highest != _sets.back().end()) { Node n = _first[*_highest]; @@ -462,10 +460,19 @@ { Node new_target; - if ((*_prev)[target] != INVALID) { - _last[(*_bucket)[target]] = (*_prev)[target]; - _next->set((*_prev)[target], INVALID); - new_target = (*_prev)[target]; + if ((*_prev)[target] != INVALID || (*_next)[target] != INVALID) { + if ((*_next)[target] == INVALID) { + _last[(*_bucket)[target]] = (*_prev)[target]; + new_target = (*_prev)[target]; + } else { + _prev->set((*_next)[target], (*_prev)[target]); + new_target = (*_next)[target]; + } + if ((*_prev)[target] == INVALID) { + _first[(*_bucket)[target]] = (*_next)[target]; + } else { + _next->set((*_prev)[target], (*_next)[target]); + } } else { _sets.back().pop_back(); if (_sets.back().empty()) { @@ -761,10 +768,19 @@ { Node new_target; - if ((*_prev)[target] != INVALID) { - _last[(*_bucket)[target]] = (*_prev)[target]; - _next->set((*_prev)[target], INVALID); - new_target = (*_prev)[target]; + if ((*_prev)[target] != INVALID || (*_next)[target] != INVALID) { + if ((*_next)[target] == INVALID) { + _last[(*_bucket)[target]] = (*_prev)[target]; + new_target = (*_prev)[target]; + } else { + _prev->set((*_next)[target], (*_prev)[target]); + new_target = (*_next)[target]; + } + if ((*_prev)[target] == INVALID) { + _first[(*_bucket)[target]] = (*_next)[target]; + } else { + _next->set((*_prev)[target], (*_next)[target]); + } } else { _sets.back().pop_back(); if (_sets.back().empty()) { @@ -850,10 +866,10 @@ _node_num = countNodes(_graph); - _first.resize(_node_num); - _last.resize(_node_num); + _first.resize(_node_num + 1); + _last.resize(_node_num + 1); - _dormant.resize(_node_num); + _dormant.resize(_node_num + 1); if (!_flow) { _flow = new FlowMap(_graph);