lemon/pr_bipartite_matching.h
changeset 2466 feb7974cf4ec
parent 2463 19651a04d056
child 2512 371cf309fc3c
     1.1 --- a/lemon/pr_bipartite_matching.h	Sat Aug 25 10:12:03 2007 +0000
     1.2 +++ b/lemon/pr_bipartite_matching.h	Tue Aug 28 13:58:54 2007 +0000
     1.3 @@ -59,6 +59,10 @@
     1.4  
     1.5    public:
     1.6  
     1.7 +    /// Constructor
     1.8 +
     1.9 +    /// Constructor
    1.10 +    ///
    1.11      PrBipartiteMatching(const Graph &g) :
    1.12        _g(g),
    1.13        _node_num(countBNodes(g)),
    1.14 @@ -195,14 +199,15 @@
    1.15  	  _levels.liftToTop(actlevel);
    1.16        }
    1.17        
    1.18 -      _matching_size = _node_num;
    1.19 -      for(ANodeIt n(_g);n!=INVALID;++n)
    1.20 -	if(_matching[n]==INVALID) _matching_size--;
    1.21 -	else if (_cov[_g.bNode(_matching[n])]>1) {
    1.22 +      for(ANodeIt n(_g);n!=INVALID;++n) {
    1.23 +	if (_matching[n]==INVALID)continue;
    1.24 +	if (_cov[_g.bNode(_matching[n])]>1) {
    1.25  	  _cov[_g.bNode(_matching[n])]--;
    1.26 -	  _matching_size--;
    1.27  	  _matching[n]=INVALID;
    1.28 +	} else {
    1.29 +	  ++_matching_size;
    1.30  	}
    1.31 +      }
    1.32      }
    1.33  
    1.34      ///Start the algorithm to find a perfect matching
    1.35 @@ -261,6 +266,7 @@
    1.36  	  _empty_level=actlevel;
    1.37  	  return false;
    1.38        }
    1.39 +      _matching_size = _node_num;
    1.40        return true;
    1.41      }
    1.42