[Lemon-commits] deba: r3510 - lemon/trunk/lemon
Lemon SVN
svn at lemon.cs.elte.hu
Wed Oct 8 11:17:02 CEST 2008
Author: deba
Date: Wed Oct 8 11:17:01 2008
New Revision: 3510
Modified:
lemon/trunk/lemon/hao_orlin.h
lemon/trunk/lemon/min_cost_arborescence.h
Log:
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)
Modified: lemon/trunk/lemon/hao_orlin.h
==============================================================================
--- lemon/trunk/lemon/hao_orlin.h (original)
+++ lemon/trunk/lemon/hao_orlin.h Wed Oct 8 11:17:01 2008
@@ -21,13 +21,11 @@
#include <vector>
#include <list>
-#include <ext/hash_set>
#include <limits>
#include <lemon/maps.h>
#include <lemon/graph_utils.h>
-#include <lemon/graph_adaptor.h>
-#include <lemon/iterable_maps.h>
+#include <lemon/tolerance.h>
/// \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);
Modified: lemon/trunk/lemon/min_cost_arborescence.h
==============================================================================
--- lemon/trunk/lemon/min_cost_arborescence.h (original)
+++ lemon/trunk/lemon/min_cost_arborescence.h Wed Oct 8 11:17:01 2008
@@ -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;
}
}
More information about the Lemon-commits
mailing list