1.1 --- a/src/test/heap_test.h Wed Mar 09 14:06:32 2005 +0000
1.2 +++ b/src/test/heap_test.h Wed Mar 09 14:10:21 2005 +0000
1.3 @@ -1,11 +1,8 @@
1.4 // -+- c++ -+-
1.5 +
1.6 #include <vector>
1.7 #include <algorithm>
1.8
1.9 -#include <lemon/bin_heap.h>
1.10 -#include <lemon/fib_heap.h>
1.11 -#include <lemon/radix_heap.h>
1.12 -
1.13 #include <lemon/dijkstra.h>
1.14
1.15 class IntIntMap : public std::vector<int> {
1.16 @@ -42,6 +39,32 @@
1.17 }
1.18 }
1.19
1.20 +template <typename _Heap>
1.21 +void heapIncreaseTest(int n) {
1.22 + typedef _Heap Heap;
1.23 + IntIntMap map(n, -1);
1.24 +
1.25 + Heap heap(map);
1.26 +
1.27 + std::vector<int> v(n);
1.28 +
1.29 + for (int i = 0; i < n; ++i) {
1.30 + v[i] = rand() % 1000;
1.31 + heap.push(i, v[i]);
1.32 + }
1.33 + for (int i = 0; i < n; ++i) {
1.34 + v[i] += rand() % 1000;
1.35 + heap.increase(i, v[i]);
1.36 + }
1.37 + std::sort(v.begin(), v.end());
1.38 + for (int i = 0; i < n; ++i) {
1.39 + check(v[i] == heap.prio() ,"Wrong order in heap increase test.");
1.40 + heap.pop();
1.41 + }
1.42 +}
1.43 +
1.44 +
1.45 +
1.46 template <typename _Traits, typename _Heap>
1.47 struct DefHeapTraits : public _Traits {
1.48 typedef _Heap Heap;
1.49 @@ -76,7 +99,7 @@
1.50 }
1.51
1.52 for(NodeIt v(graph); v!=INVALID; ++v) {
1.53 - if ( dijkstra.reached(v) ) {
1.54 + if ( dijkstra.reached(v) && dijkstra.pred(v) != INVALID ) {
1.55 Edge e=dijkstra.pred(v);
1.56 Node u=graph.source(e);
1.57 check( dijkstra.dist(v) - dijkstra .dist(u) == length[e],