test/matching_test.cc
changeset 870 61120524af27
parent 594 d657c71db7db
child 877 141f9c0db4a3
     1.1 --- a/test/matching_test.cc	Fri Sep 25 21:51:36 2009 +0200
     1.2 +++ b/test/matching_test.cc	Sat Sep 26 10:17:31 2009 +0200
     1.3 @@ -401,22 +401,46 @@
     1.4      graphReader(graph, lgfs).
     1.5        edgeMap("weight", weight).run();
     1.6  
     1.7 -    MaxMatching<SmartGraph> mm(graph);
     1.8 -    mm.run();
     1.9 -    checkMatching(graph, mm);
    1.10 +    bool perfect;
    1.11 +    {
    1.12 +      MaxMatching<SmartGraph> mm(graph);
    1.13 +      mm.run();
    1.14 +      checkMatching(graph, mm);
    1.15 +      perfect = 2 * mm.matchingSize() == countNodes(graph);
    1.16 +    }
    1.17  
    1.18 -    MaxWeightedMatching<SmartGraph> mwm(graph, weight);
    1.19 -    mwm.run();
    1.20 -    checkWeightedMatching(graph, weight, mwm);
    1.21 +    {
    1.22 +      MaxWeightedMatching<SmartGraph> mwm(graph, weight);
    1.23 +      mwm.run();
    1.24 +      checkWeightedMatching(graph, weight, mwm);
    1.25 +    }
    1.26  
    1.27 -    MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
    1.28 -    bool perfect = mwpm.run();
    1.29 +    {
    1.30 +      MaxWeightedMatching<SmartGraph> mwm(graph, weight);
    1.31 +      mwm.init();
    1.32 +      mwm.start();
    1.33 +      checkWeightedMatching(graph, weight, mwm);
    1.34 +    }
    1.35  
    1.36 -    check(perfect == (mm.matchingSize() * 2 == countNodes(graph)),
    1.37 -          "Perfect matching found");
    1.38 +    {
    1.39 +      MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
    1.40 +      bool result = mwpm.run();
    1.41 +      
    1.42 +      check(result == perfect, "Perfect matching found");
    1.43 +      if (perfect) {
    1.44 +        checkWeightedPerfectMatching(graph, weight, mwpm);
    1.45 +      }
    1.46 +    }
    1.47  
    1.48 -    if (perfect) {
    1.49 -      checkWeightedPerfectMatching(graph, weight, mwpm);
    1.50 +    {
    1.51 +      MaxWeightedPerfectMatching<SmartGraph> mwpm(graph, weight);
    1.52 +      mwpm.init();
    1.53 +      bool result = mwpm.start();
    1.54 +      
    1.55 +      check(result == perfect, "Perfect matching found");
    1.56 +      if (perfect) {
    1.57 +        checkWeightedPerfectMatching(graph, weight, mwpm);
    1.58 +      }
    1.59      }
    1.60    }
    1.61