diff -r 70b199792735 -r ad40f7d32846 test/suurballe_test.cc --- a/test/suurballe_test.cc Fri Aug 09 11:07:27 2013 +0200 +++ b/test/suurballe_test.cc Sun Aug 11 15:28:12 2013 +0200 @@ -2,7 +2,7 @@ * * This file is a part of LEMON, a generic C++ optimization library. * - * Copyright (C) 2003-2009 + * Copyright (C) 2003-2010 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * @@ -23,6 +23,7 @@ #include #include #include +#include #include "test_tools.h" @@ -80,8 +81,14 @@ typedef Digraph::Node Node; typedef Digraph::Arc Arc; typedef concepts::ReadMap LengthMap; - - typedef Suurballe SuurballeType; + + typedef Suurballe ST; + typedef Suurballe + ::SetFlowMap + ::SetPotentialMap + ::SetPath > + ::SetHeap > > + ::Create SuurballeType; Digraph g; Node n; @@ -101,10 +108,13 @@ k = suurb_test.run(n, n); k = suurb_test.run(n, n, k); suurb_test.init(n); + suurb_test.fullInit(n); + suurb_test.start(n); + suurb_test.start(n, k); k = suurb_test.findFlow(n); k = suurb_test.findFlow(n, k); suurb_test.findPaths(); - + int f; VType c; ::lemon::ignore_unused_variable_warning(f,c); @@ -118,7 +128,7 @@ const_suurb_test.potentialMap(); k = const_suurb_test.pathNum(); Path p = const_suurb_test.path(k); - + ::lemon::ignore_unused_variable_warning(fm); ::lemon::ignore_unused_variable_warning(pm); } @@ -197,9 +207,11 @@ node("target", t). run(); - // Find 2 paths + // Check run() { Suurballe suurballe(digraph, length); + + // Find 2 paths check(suurballe.run(s, t) == 2, "Wrong number of paths"); check(checkFlow(digraph, suurballe.flowMap(), s, t, 2), "The flow is not feasible"); @@ -209,11 +221,8 @@ "Wrong potentials"); for (int i = 0; i < suurballe.pathNum(); ++i) check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); - } - // Find 3 paths - { - Suurballe suurballe(digraph, length); + // Find 3 paths check(suurballe.run(s, t, 3) == 3, "Wrong number of paths"); check(checkFlow(digraph, suurballe.flowMap(), s, t, 3), "The flow is not feasible"); @@ -223,11 +232,8 @@ "Wrong potentials"); for (int i = 0; i < suurballe.pathNum(); ++i) check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); - } - // Find 5 paths (only 3 can be found) - { - Suurballe suurballe(digraph, length); + // Find 5 paths (only 3 can be found) check(suurballe.run(s, t, 5) == 3, "Wrong number of paths"); check(checkFlow(digraph, suurballe.flowMap(), s, t, 3), "The flow is not feasible"); @@ -239,5 +245,23 @@ check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path"); } + // Check fullInit() + start() + { + Suurballe suurballe(digraph, length); + suurballe.fullInit(s); + + // Find 2 paths + check(suurballe.start(t) == 2, "Wrong number of paths"); + check(suurballe.totalLength() == 510, "The flow is not optimal"); + + // Find 3 paths + check(suurballe.start(t, 3) == 3, "Wrong number of paths"); + check(suurballe.totalLength() == 1040, "The flow is not optimal"); + + // Find 5 paths (only 3 can be found) + check(suurballe.start(t, 5) == 3, "Wrong number of paths"); + check(suurballe.totalLength() == 1040, "The flow is not optimal"); + } + return 0; }