COIN-OR::LEMON - Graph Library

Changeset 1206:9c398137c2cb in lemon-0.x for src/test/heap_test.h


Ignore:
Timestamp:
03/09/05 15:10:21 (16 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1625
Message:

Increase test
Changing test graph

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/test/heap_test.h

    r1187 r1206  
    11// -+- c++ -+-
     2
    23#include <vector>
    34#include <algorithm>
    4 
    5 #include <lemon/bin_heap.h>
    6 #include <lemon/fib_heap.h>
    7 #include <lemon/radix_heap.h>
    85
    96#include <lemon/dijkstra.h>
     
    4340}
    4441
     42template <typename _Heap>
     43void heapIncreaseTest(int n) {
     44  typedef _Heap Heap;
     45  IntIntMap map(n, -1);
     46
     47  Heap heap(map);
     48 
     49  std::vector<int> v(n);
     50
     51  for (int i = 0; i < n; ++i) {
     52    v[i] = rand() % 1000;
     53    heap.push(i, v[i]);
     54  }
     55  for (int i = 0; i < n; ++i) {
     56    v[i] += rand() % 1000;
     57    heap.increase(i, v[i]);
     58  }
     59  std::sort(v.begin(), v.end());
     60  for (int i = 0; i < n; ++i) {
     61    check(v[i] == heap.prio() ,"Wrong order in heap increase test.");
     62    heap.pop();
     63  }
     64}
     65
     66
     67
    4568template <typename _Traits, typename _Heap>
    4669struct DefHeapTraits : public _Traits {
     
    77100
    78101  for(NodeIt v(graph); v!=INVALID; ++v) {
    79     if ( dijkstra.reached(v) ) {
     102    if ( dijkstra.reached(v) && dijkstra.pred(v) != INVALID ) {
    80103      Edge e=dijkstra.pred(v);
    81104      Node u=graph.source(e);
Note: See TracChangeset for help on using the changeset viewer.