Fix multiple executions in matchings (fract. mathcings) (#356)
authorBalazs Dezso <deba@inf.elte.hu>
Wed, 17 Mar 2010 12:35:52 +0100
changeset 8767f6e2bd76654
parent 875 07ec2b52e53d
child 877 141f9c0db4a3
Fix multiple executions in matchings (fract. mathcings) (#356)
lemon/fractional_matching.h
lemon/matching.h
     1.1 --- a/lemon/fractional_matching.h	Wed Mar 17 10:29:57 2010 +0100
     1.2 +++ b/lemon/fractional_matching.h	Wed Mar 17 12:35:52 2010 +0100
     1.3 @@ -1166,6 +1166,11 @@
     1.4          (*_delta3_index)[e] = _delta3->PRE_HEAP;
     1.5        }
     1.6  
     1.7 +      _delta1->clear();
     1.8 +      _delta2->clear();
     1.9 +      _delta3->clear();
    1.10 +      _tree_set->clear();
    1.11 +
    1.12        for (NodeIt n(_graph); n != INVALID; ++n) {
    1.13          Value max = 0;
    1.14          for (OutArcIt e(_graph, n); e != INVALID; ++e) {
    1.15 @@ -1905,6 +1910,10 @@
    1.16          (*_delta3_index)[e] = _delta3->PRE_HEAP;
    1.17        }
    1.18  
    1.19 +      _delta2->clear();
    1.20 +      _delta3->clear();
    1.21 +      _tree_set->clear();
    1.22 +
    1.23        for (NodeIt n(_graph); n != INVALID; ++n) {
    1.24          Value max = - std::numeric_limits<Value>::max();
    1.25          for (OutArcIt e(_graph, n); e != INVALID; ++e) {
     2.1 --- a/lemon/matching.h	Wed Mar 17 10:29:57 2010 +0100
     2.2 +++ b/lemon/matching.h	Wed Mar 17 12:35:52 2010 +0100
     2.3 @@ -1675,6 +1675,9 @@
     2.4      /// matching. This initialization is also called jumpstart heuristic.
     2.5      void fractionalInit() {
     2.6        createStructures();
     2.7 +
     2.8 +      _blossom_node_list.clear();
     2.9 +      _blossom_potential.clear();
    2.10        
    2.11        if (_fractional == 0) {
    2.12          _fractional = new FractionalMatching(_graph, _weight, false);
    2.13 @@ -1697,11 +1700,20 @@
    2.14  
    2.15        _unmatched = 0;
    2.16  
    2.17 +      _delta1->clear();
    2.18 +      _delta2->clear();
    2.19 +      _delta3->clear();
    2.20 +      _delta4->clear();
    2.21 +      _blossom_set->clear();
    2.22 +      _tree_set->clear();
    2.23 +
    2.24        int index = 0;
    2.25        for (NodeIt n(_graph); n != INVALID; ++n) {
    2.26          Value pot = _fractional->nodeValue(n);
    2.27          (*_node_index)[n] = index;
    2.28          (*_node_data)[index].pot = pot;
    2.29 +        (*_node_data)[index].heap_index.clear();
    2.30 +        (*_node_data)[index].heap.clear();
    2.31          int blossom =
    2.32            _blossom_set->insert(n, std::numeric_limits<Value>::max());
    2.33  
    2.34 @@ -3080,6 +3092,9 @@
    2.35      /// matching. This initialization is also called jumpstart heuristic.
    2.36      void fractionalInit() {
    2.37        createStructures();
    2.38 +
    2.39 +      _blossom_node_list.clear();
    2.40 +      _blossom_potential.clear();
    2.41        
    2.42        if (_fractional == 0) {
    2.43          _fractional = new FractionalMatching(_graph, _weight, false);
    2.44 @@ -3102,11 +3117,19 @@
    2.45  
    2.46        _unmatched = 0;
    2.47  
    2.48 +      _delta2->clear();
    2.49 +      _delta3->clear();
    2.50 +      _delta4->clear();
    2.51 +      _blossom_set->clear();
    2.52 +      _tree_set->clear();
    2.53 +
    2.54        int index = 0;
    2.55        for (NodeIt n(_graph); n != INVALID; ++n) {
    2.56          Value pot = _fractional->nodeValue(n);
    2.57          (*_node_index)[n] = index;
    2.58          (*_node_data)[index].pot = pot;
    2.59 +        (*_node_data)[index].heap_index.clear();
    2.60 +        (*_node_data)[index].heap.clear();
    2.61          int blossom =
    2.62            _blossom_set->insert(n, std::numeric_limits<Value>::max());
    2.63