test/suurballe_test.cc
 changeset 858 9f6ed854d409 parent 857 abb95d48e89e child 877 141f9c0db4a3
```     1.1 --- a/test/suurballe_test.cc	Fri Oct 16 09:35:46 2009 +0200
1.2 +++ b/test/suurballe_test.cc	Tue Mar 02 10:27:47 2010 +0100
1.3 @@ -205,9 +205,11 @@
1.4      node("target", t).
1.5      run();
1.6
1.7 -  // Find 2 paths
1.8 +  // Check run()
1.9    {
1.10      Suurballe<ListDigraph> suurballe(digraph, length);
1.11 +
1.12 +    // Find 2 paths
1.13      check(suurballe.run(s, t) == 2, "Wrong number of paths");
1.14      check(checkFlow(digraph, suurballe.flowMap(), s, t, 2),
1.15            "The flow is not feasible");
1.16 @@ -217,11 +219,8 @@
1.17            "Wrong potentials");
1.18      for (int i = 0; i < suurballe.pathNum(); ++i)
1.19        check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.20 -  }
1.21 -
1.22 -  // Find 3 paths
1.23 -  {
1.24 -    Suurballe<ListDigraph> suurballe(digraph, length);
1.25 +
1.26 +    // Find 3 paths
1.27      check(suurballe.run(s, t, 3) == 3, "Wrong number of paths");
1.28      check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
1.29            "The flow is not feasible");
1.30 @@ -231,11 +230,8 @@
1.31            "Wrong potentials");
1.32      for (int i = 0; i < suurballe.pathNum(); ++i)
1.33        check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.34 -  }
1.35 -
1.36 -  // Find 5 paths (only 3 can be found)
1.37 -  {
1.38 -    Suurballe<ListDigraph> suurballe(digraph, length);
1.39 +
1.40 +    // Find 5 paths (only 3 can be found)
1.41      check(suurballe.run(s, t, 5) == 3, "Wrong number of paths");
1.42      check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
1.43            "The flow is not feasible");
1.44 @@ -246,6 +242,24 @@
1.45      for (int i = 0; i < suurballe.pathNum(); ++i)
1.46        check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.47    }
1.48 +
1.49 +  // Check fullInit() + start()
1.50 +  {
1.51 +    Suurballe<ListDigraph> suurballe(digraph, length);
1.52 +    suurballe.fullInit(s);
1.53 +
1.54 +    // Find 2 paths
1.55 +    check(suurballe.start(t) == 2, "Wrong number of paths");
1.56 +    check(suurballe.totalLength() == 510, "The flow is not optimal");
1.57 +
1.58 +    // Find 3 paths
1.59 +    check(suurballe.start(t, 3) == 3, "Wrong number of paths");
1.60 +    check(suurballe.totalLength() == 1040, "The flow is not optimal");
1.61 +
1.62 +    // Find 5 paths (only 3 can be found)
1.63 +    check(suurballe.start(t, 5) == 3, "Wrong number of paths");
1.64 +    check(suurballe.totalLength() == 1040, "The flow is not optimal");
1.65 +  }
1.66
1.67    return 0;
1.68  }
```