1.1 --- a/test/suurballe_test.cc Tue Dec 20 17:44:38 2011 +0100
1.2 +++ b/test/suurballe_test.cc Tue Dec 20 18:15:14 2011 +0100
1.3 @@ -2,7 +2,7 @@
1.4 *
1.5 * This file is a part of LEMON, a generic C++ optimization library.
1.6 *
1.7 - * Copyright (C) 2003-2009
1.8 + * Copyright (C) 2003-2010
1.9 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.10 * (Egervary Research Group on Combinatorial Optimization, EGRES).
1.11 *
1.12 @@ -23,6 +23,7 @@
1.13 #include <lemon/path.h>
1.14 #include <lemon/suurballe.h>
1.15 #include <lemon/concepts/digraph.h>
1.16 +#include <lemon/concepts/heap.h>
1.17
1.18 #include "test_tools.h"
1.19
1.20 @@ -80,8 +81,14 @@
1.21 typedef Digraph::Node Node;
1.22 typedef Digraph::Arc Arc;
1.23 typedef concepts::ReadMap<Arc, VType> LengthMap;
1.24 -
1.25 - typedef Suurballe<Digraph, LengthMap> SuurballeType;
1.26 +
1.27 + typedef Suurballe<Digraph, LengthMap> ST;
1.28 + typedef Suurballe<Digraph, LengthMap>
1.29 + ::SetFlowMap<ST::FlowMap>
1.30 + ::SetPotentialMap<ST::PotentialMap>
1.31 + ::SetPath<SimplePath<Digraph> >
1.32 + ::SetHeap<concepts::Heap<VType, Digraph::NodeMap<int> > >
1.33 + ::Create SuurballeType;
1.34
1.35 Digraph g;
1.36 Node n;
1.37 @@ -101,10 +108,13 @@
1.38 k = suurb_test.run(n, n);
1.39 k = suurb_test.run(n, n, k);
1.40 suurb_test.init(n);
1.41 + suurb_test.fullInit(n);
1.42 + suurb_test.start(n);
1.43 + suurb_test.start(n, k);
1.44 k = suurb_test.findFlow(n);
1.45 k = suurb_test.findFlow(n, k);
1.46 suurb_test.findPaths();
1.47 -
1.48 +
1.49 int f;
1.50 VType c;
1.51 c = const_suurb_test.totalLength();
1.52 @@ -116,7 +126,7 @@
1.53 const_suurb_test.potentialMap();
1.54 k = const_suurb_test.pathNum();
1.55 Path<Digraph> p = const_suurb_test.path(k);
1.56 -
1.57 +
1.58 ignore_unused_variable_warning(fm);
1.59 ignore_unused_variable_warning(pm);
1.60 }
1.61 @@ -195,9 +205,11 @@
1.62 node("target", t).
1.63 run();
1.64
1.65 - // Find 2 paths
1.66 + // Check run()
1.67 {
1.68 Suurballe<ListDigraph> suurballe(digraph, length);
1.69 +
1.70 + // Find 2 paths
1.71 check(suurballe.run(s, t) == 2, "Wrong number of paths");
1.72 check(checkFlow(digraph, suurballe.flowMap(), s, t, 2),
1.73 "The flow is not feasible");
1.74 @@ -207,11 +219,8 @@
1.75 "Wrong potentials");
1.76 for (int i = 0; i < suurballe.pathNum(); ++i)
1.77 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.78 - }
1.79
1.80 - // Find 3 paths
1.81 - {
1.82 - Suurballe<ListDigraph> suurballe(digraph, length);
1.83 + // Find 3 paths
1.84 check(suurballe.run(s, t, 3) == 3, "Wrong number of paths");
1.85 check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
1.86 "The flow is not feasible");
1.87 @@ -221,11 +230,8 @@
1.88 "Wrong potentials");
1.89 for (int i = 0; i < suurballe.pathNum(); ++i)
1.90 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.91 - }
1.92
1.93 - // Find 5 paths (only 3 can be found)
1.94 - {
1.95 - Suurballe<ListDigraph> suurballe(digraph, length);
1.96 + // Find 5 paths (only 3 can be found)
1.97 check(suurballe.run(s, t, 5) == 3, "Wrong number of paths");
1.98 check(checkFlow(digraph, suurballe.flowMap(), s, t, 3),
1.99 "The flow is not feasible");
1.100 @@ -237,5 +243,23 @@
1.101 check(checkPath(digraph, suurballe.path(i), s, t), "Wrong path");
1.102 }
1.103
1.104 + // Check fullInit() + start()
1.105 + {
1.106 + Suurballe<ListDigraph> suurballe(digraph, length);
1.107 + suurballe.fullInit(s);
1.108 +
1.109 + // Find 2 paths
1.110 + check(suurballe.start(t) == 2, "Wrong number of paths");
1.111 + check(suurballe.totalLength() == 510, "The flow is not optimal");
1.112 +
1.113 + // Find 3 paths
1.114 + check(suurballe.start(t, 3) == 3, "Wrong number of paths");
1.115 + check(suurballe.totalLength() == 1040, "The flow is not optimal");
1.116 +
1.117 + // Find 5 paths (only 3 can be found)
1.118 + check(suurballe.start(t, 5) == 3, "Wrong number of paths");
1.119 + check(suurballe.totalLength() == 1040, "The flow is not optimal");
1.120 + }
1.121 +
1.122 return 0;
1.123 }