diff -r 7c4ba7daaf5f -r 2b6bffe0e7e8 test/suurballe_test.cc --- a/test/suurballe_test.cc Tue Dec 20 17:44:38 2011 +0100 +++ b/test/suurballe_test.cc Tue Dec 20 18:15:14 2011 +0100 @@ -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; c = const_suurb_test.totalLength(); @@ -116,7 +126,7 @@ const_suurb_test.potentialMap(); k = const_suurb_test.pathNum(); Path p = const_suurb_test.path(k); - + ignore_unused_variable_warning(fm); ignore_unused_variable_warning(pm); } @@ -195,9 +205,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"); @@ -207,11 +219,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"); @@ -221,11 +230,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"); @@ -237,5 +243,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; }