test/matching_test.cc
changeset 874 d8ea85825e02
parent 594 d657c71db7db
child 877 141f9c0db4a3
     1.1 --- a/test/matching_test.cc	Tue Mar 16 21:18:39 2010 +0100
     1.2 +++ b/test/matching_test.cc	Tue Mar 16 21:27:35 2010 +0100
     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