Bug fix in MinCostMaxBipartiteMatching
authordeba
Fri, 14 Jul 2006 09:37:48 +0000
changeset 21364f64d6b3e9ec
parent 2135 15355b98fb84
child 2137 54043fa66bce
Bug fix in MinCostMaxBipartiteMatching
The augmenting phase have not changed the
unreached nodes' potential which caused invalid
dual solution in some cases
lemon/bipartite_matching.h
     1.1 --- a/lemon/bipartite_matching.h	Wed Jul 12 11:40:52 2006 +0000
     1.2 +++ b/lemon/bipartite_matching.h	Fri Jul 14 09:37:48 2006 +0000
     1.3 @@ -1325,6 +1325,7 @@
     1.4            _heap->push(it, 0);
     1.5          }
     1.6        }
     1.7 +      Value bdistMax = 0;
     1.8  
     1.9        while (!_heap->empty()) {
    1.10          Node anode = _heap->top();
    1.11 @@ -1339,6 +1340,9 @@
    1.12              bdist[bnode] = bvalue;
    1.13              bpred[bnode] = jt;
    1.14            }
    1.15 +          if (bvalue > bdistMax) {
    1.16 +            bdistMax = bvalue;
    1.17 +          }
    1.18            if (bnode_matching[bnode] != INVALID) {
    1.19              Node newanode = graph->aNode(bnode_matching[bnode]);
    1.20              switch (_heap->state(newanode)) {
    1.21 @@ -1373,6 +1377,8 @@
    1.22        for (BNodeIt it(*graph); it != INVALID; ++it) {
    1.23          if (bpred[it] != INVALID) {
    1.24            bnode_potential[it] += bdist[it];
    1.25 +        } else {
    1.26 +          bnode_potential[it] += bdistMax;
    1.27          }
    1.28        }
    1.29        for (ANodeIt it(*graph); it != INVALID; ++it) {
    1.30 @@ -1380,6 +1386,8 @@
    1.31            Node bnode = graph->bNode(anode_matching[it]);
    1.32            if (bpred[bnode] != INVALID) {
    1.33              anode_potential[it] += bdist[bnode];
    1.34 +          } else {
    1.35 +            anode_potential[it] += bdistMax;
    1.36            }
    1.37          }
    1.38        }