test/max_clique_test.cc
changeset 1026 9312d6c89d02
parent 999 c279b19abc62
child 1270 dceba191c00d
     1.1 --- a/test/max_clique_test.cc	Sat Jan 08 16:11:48 2011 +0100
     1.2 +++ b/test/max_clique_test.cc	Mon Jan 10 09:34:50 2011 +0100
     1.3 @@ -58,7 +58,7 @@
     1.4  
     1.5  // Check with general graphs
     1.6  template <typename Param>
     1.7 -void checkMaxCliqueGeneral(int max_sel, Param rule) {
     1.8 +void checkMaxCliqueGeneral(Param rule) {
     1.9    typedef ListGraph GR;
    1.10    typedef GrossoLocatelliPullanMc<GR> McAlg;
    1.11    typedef McAlg::CliqueNodeIt CliqueIt;
    1.12 @@ -68,12 +68,13 @@
    1.13      GR g;
    1.14      GR::NodeMap<bool> map(g);
    1.15      McAlg mc(g);
    1.16 -    check(mc.run(max_sel, rule) == 0, "Wrong clique size");
    1.17 +    mc.iterationLimit(50);
    1.18 +    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    1.19      check(mc.cliqueSize() == 0, "Wrong clique size");
    1.20      check(CliqueIt(mc) == INVALID, "Wrong CliqueNodeIt");
    1.21  
    1.22      GR::Node u = g.addNode();
    1.23 -    check(mc.run(max_sel, rule) == 1, "Wrong clique size");
    1.24 +    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    1.25      check(mc.cliqueSize() == 1, "Wrong clique size");
    1.26      mc.cliqueMap(map);
    1.27      check(map[u], "Wrong clique map");
    1.28 @@ -82,7 +83,7 @@
    1.29            "Wrong CliqueNodeIt");
    1.30      
    1.31      GR::Node v = g.addNode();
    1.32 -    check(mc.run(max_sel, rule) == 1, "Wrong clique size");
    1.33 +    check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause");
    1.34      check(mc.cliqueSize() == 1, "Wrong clique size");
    1.35      mc.cliqueMap(map);
    1.36      check((map[u] && !map[v]) || (map[v] && !map[u]), "Wrong clique map");
    1.37 @@ -90,7 +91,7 @@
    1.38      check(it2 != INVALID && ++it2 == INVALID, "Wrong CliqueNodeIt");
    1.39  
    1.40      g.addEdge(u, v);
    1.41 -    check(mc.run(max_sel, rule) == 2, "Wrong clique size");
    1.42 +    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    1.43      check(mc.cliqueSize() == 2, "Wrong clique size");
    1.44      mc.cliqueMap(map);
    1.45      check(map[u] && map[v], "Wrong clique map");
    1.46 @@ -110,7 +111,8 @@
    1.47        .run();
    1.48      
    1.49      McAlg mc(g);
    1.50 -    check(mc.run(max_sel, rule) == 4, "Wrong clique size");
    1.51 +    mc.iterationLimit(50);
    1.52 +    check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause");
    1.53      check(mc.cliqueSize() == 4, "Wrong clique size");
    1.54      mc.cliqueMap(map);
    1.55      for (GR::NodeIt n(g); n != INVALID; ++n) {
    1.56 @@ -127,7 +129,7 @@
    1.57  
    1.58  // Check with full graphs
    1.59  template <typename Param>
    1.60 -void checkMaxCliqueFullGraph(int max_sel, Param rule) {
    1.61 +void checkMaxCliqueFullGraph(Param rule) {
    1.62    typedef FullGraph GR;
    1.63    typedef GrossoLocatelliPullanMc<FullGraph> McAlg;
    1.64    typedef McAlg::CliqueNodeIt CliqueIt;
    1.65 @@ -136,7 +138,7 @@
    1.66      GR g(size);
    1.67      GR::NodeMap<bool> map(g);
    1.68      McAlg mc(g);
    1.69 -    check(mc.run(max_sel, rule) == size, "Wrong clique size");
    1.70 +    check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause");
    1.71      check(mc.cliqueSize() == size, "Wrong clique size");
    1.72      mc.cliqueMap(map);
    1.73      for (GR::NodeIt n(g); n != INVALID; ++n) {
    1.74 @@ -150,27 +152,37 @@
    1.75  
    1.76  // Check with grid graphs
    1.77  template <typename Param>
    1.78 -void checkMaxCliqueGridGraph(int max_sel, Param rule) {
    1.79 +void checkMaxCliqueGridGraph(Param rule) {
    1.80    GridGraph g(5, 7);
    1.81    GridGraph::NodeMap<char> map(g);
    1.82    GrossoLocatelliPullanMc<GridGraph> mc(g);
    1.83 -  check(mc.run(max_sel, rule) == 2, "Wrong clique size");
    1.84 +  
    1.85 +  mc.iterationLimit(100);
    1.86 +  check(mc.run(rule) == mc.ITERATION_LIMIT, "Wrong termination cause");
    1.87 +  check(mc.cliqueSize() == 2, "Wrong clique size");
    1.88 +
    1.89 +  mc.stepLimit(100);
    1.90 +  check(mc.run(rule) == mc.STEP_LIMIT, "Wrong termination cause");
    1.91 +  check(mc.cliqueSize() == 2, "Wrong clique size");
    1.92 +
    1.93 +  mc.sizeLimit(2);
    1.94 +  check(mc.run(rule) == mc.SIZE_LIMIT, "Wrong termination cause");
    1.95    check(mc.cliqueSize() == 2, "Wrong clique size");
    1.96  }
    1.97  
    1.98  
    1.99  int main() {
   1.100 -  checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::RANDOM);
   1.101 -  checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::DEGREE_BASED);
   1.102 -  checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc<ListGraph>::PENALTY_BASED);
   1.103 +  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::RANDOM);
   1.104 +  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::DEGREE_BASED);
   1.105 +  checkMaxCliqueGeneral(GrossoLocatelliPullanMc<ListGraph>::PENALTY_BASED);
   1.106  
   1.107 -  checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::RANDOM);
   1.108 -  checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::DEGREE_BASED);
   1.109 -  checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc<FullGraph>::PENALTY_BASED);
   1.110 +  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::RANDOM);
   1.111 +  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::DEGREE_BASED);
   1.112 +  checkMaxCliqueFullGraph(GrossoLocatelliPullanMc<FullGraph>::PENALTY_BASED);
   1.113                         
   1.114 -  checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::RANDOM);
   1.115 -  checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::DEGREE_BASED);
   1.116 -  checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc<GridGraph>::PENALTY_BASED);
   1.117 +  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::RANDOM);
   1.118 +  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::DEGREE_BASED);
   1.119 +  checkMaxCliqueGridGraph(GrossoLocatelliPullanMc<GridGraph>::PENALTY_BASED);
   1.120                         
   1.121    return 0;
   1.122  }