# HG changeset patch # User deba # Date 1223457421 0 # Node ID dc4dd5fc0e2526a23ab23cade6d8ccbd131459c2 # Parent 90defb96ee616b295e2119c46710dcef1e6aa98e Bug fixes is HaoOrlin and MinCostArborescence MinCostArborescence - proper deallocation HaoOrlin - the target needn't to be the last in its bucket - proper size of container (if each node starts in different buckets initially) 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); diff -r 90defb96ee61 -r dc4dd5fc0e25 lemon/min_cost_arborescence.h --- a/lemon/min_cost_arborescence.h Mon Oct 06 15:08:17 2008 +0000 +++ b/lemon/min_cost_arborescence.h Wed Oct 08 09:17:01 2008 +0000 @@ -643,19 +643,19 @@ if (local_pred) { delete _pred; } - if (!_edge_order) { + if (_edge_order) { delete _edge_order; } if (_node_order) { delete _node_order; } - if (!_cost_edges) { + if (_cost_edges) { delete _cost_edges; } - if (!_heap) { + if (_heap) { delete _heap; } - if (!_heap_cross_ref) { + if (_heap_cross_ref) { delete _heap_cross_ref; } }