diff --git a/test/max_clique_test.cc b/test/max_clique_test.cc --- a/test/max_clique_test.cc +++ b/test/max_clique_test.cc @@ -58,7 +58,7 @@ // Check with general graphs template -void checkMaxCliqueGeneral(int max_sel, Param rule) { +void checkMaxCliqueGeneral(Param rule) { typedef ListGraph GR; typedef GrossoLocatelliPullanMc McAlg; typedef McAlg::CliqueNodeIt CliqueIt; @@ -68,12 +68,13 @@ GR g; GR::NodeMap map(g); McAlg mc(g); - check(mc.run(max_sel, rule) == 0, "Wrong clique size"); + mc.iterationLimit(50); + check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 0, "Wrong clique size"); check(CliqueIt(mc) == INVALID, "Wrong CliqueNodeIt"); GR::Node u = g.addNode(); - check(mc.run(max_sel, rule) == 1, "Wrong clique size"); + check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 1, "Wrong clique size"); mc.cliqueMap(map); check(map[u], "Wrong clique map"); @@ -82,7 +83,7 @@ "Wrong CliqueNodeIt"); GR::Node v = g.addNode(); - check(mc.run(max_sel, rule) == 1, "Wrong clique size"); + check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 1, "Wrong clique size"); mc.cliqueMap(map); check((map[u] && !map[v]) || (map[v] && !map[u]), "Wrong clique map"); @@ -90,7 +91,7 @@ check(it2 != INVALID && ++it2 == INVALID, "Wrong CliqueNodeIt"); g.addEdge(u, v); - check(mc.run(max_sel, rule) == 2, "Wrong clique size"); + check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 2, "Wrong clique size"); mc.cliqueMap(map); check(map[u] && map[v], "Wrong clique map"); @@ -110,7 +111,8 @@ .run(); McAlg mc(g); - check(mc.run(max_sel, rule) == 4, "Wrong clique size"); + mc.iterationLimit(50); + check(mc.run(rule) == McAlg::ITERATION_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 4, "Wrong clique size"); mc.cliqueMap(map); for (GR::NodeIt n(g); n != INVALID; ++n) { @@ -127,7 +129,7 @@ // Check with full graphs template -void checkMaxCliqueFullGraph(int max_sel, Param rule) { +void checkMaxCliqueFullGraph(Param rule) { typedef FullGraph GR; typedef GrossoLocatelliPullanMc McAlg; typedef McAlg::CliqueNodeIt CliqueIt; @@ -136,7 +138,7 @@ GR g(size); GR::NodeMap map(g); McAlg mc(g); - check(mc.run(max_sel, rule) == size, "Wrong clique size"); + check(mc.run(rule) == McAlg::SIZE_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == size, "Wrong clique size"); mc.cliqueMap(map); for (GR::NodeIt n(g); n != INVALID; ++n) { @@ -150,27 +152,37 @@ // Check with grid graphs template -void checkMaxCliqueGridGraph(int max_sel, Param rule) { +void checkMaxCliqueGridGraph(Param rule) { GridGraph g(5, 7); GridGraph::NodeMap map(g); GrossoLocatelliPullanMc mc(g); - check(mc.run(max_sel, rule) == 2, "Wrong clique size"); + + mc.iterationLimit(100); + check(mc.run(rule) == mc.ITERATION_LIMIT, "Wrong termination cause"); + check(mc.cliqueSize() == 2, "Wrong clique size"); + + mc.stepLimit(100); + check(mc.run(rule) == mc.STEP_LIMIT, "Wrong termination cause"); + check(mc.cliqueSize() == 2, "Wrong clique size"); + + mc.sizeLimit(2); + check(mc.run(rule) == mc.SIZE_LIMIT, "Wrong termination cause"); check(mc.cliqueSize() == 2, "Wrong clique size"); } int main() { - checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc::RANDOM); - checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc::DEGREE_BASED); - checkMaxCliqueGeneral(50, GrossoLocatelliPullanMc::PENALTY_BASED); + checkMaxCliqueGeneral(GrossoLocatelliPullanMc::RANDOM); + checkMaxCliqueGeneral(GrossoLocatelliPullanMc::DEGREE_BASED); + checkMaxCliqueGeneral(GrossoLocatelliPullanMc::PENALTY_BASED); - checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc::RANDOM); - checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc::DEGREE_BASED); - checkMaxCliqueFullGraph(50, GrossoLocatelliPullanMc::PENALTY_BASED); + checkMaxCliqueFullGraph(GrossoLocatelliPullanMc::RANDOM); + checkMaxCliqueFullGraph(GrossoLocatelliPullanMc::DEGREE_BASED); + checkMaxCliqueFullGraph(GrossoLocatelliPullanMc::PENALTY_BASED); - checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc::RANDOM); - checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc::DEGREE_BASED); - checkMaxCliqueGridGraph(50, GrossoLocatelliPullanMc::PENALTY_BASED); + checkMaxCliqueGridGraph(GrossoLocatelliPullanMc::RANDOM); + checkMaxCliqueGridGraph(GrossoLocatelliPullanMc::DEGREE_BASED); + checkMaxCliqueGridGraph(GrossoLocatelliPullanMc::PENALTY_BASED); return 0; }