COIN-OR::LEMON - Graph Library

Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/heap_test.cc

    r749 r463  
    2626
    2727#include <lemon/smart_graph.h>
     28
    2829#include <lemon/lgf_reader.h>
    2930#include <lemon/dijkstra.h>
     
    3132
    3233#include <lemon/bin_heap.h>
    33 #include <lemon/fourary_heap.h>
    34 #include <lemon/kary_heap.h>
    35 #include <lemon/fib_heap.h>
    36 #include <lemon/pairing_heap.h>
    37 #include <lemon/radix_heap.h>
    38 #include <lemon/binom_heap.h>
    39 #include <lemon/bucket_heap.h>
    4034
    4135#include "test_tools.h"
     
    9387void heapSortTest() {
    9488  RangeMap<int> map(test_len, -1);
     89
    9590  Heap heap(map);
    9691
    9792  std::vector<int> v(test_len);
     93
    9894  for (int i = 0; i < test_len; ++i) {
    9995    v[i] = test_seq[i];
     
    10298  std::sort(v.begin(), v.end());
    10399  for (int i = 0; i < test_len; ++i) {
    104     check(v[i] == heap.prio(), "Wrong order in heap sort.");
     100    check(v[i] == heap.prio() ,"Wrong order in heap sort.");
    105101    heap.pop();
    106102  }
     
    114110
    115111  std::vector<int> v(test_len);
     112
    116113  for (int i = 0; i < test_len; ++i) {
    117114    v[i] = test_seq[i];
     
    124121  std::sort(v.begin(), v.end());
    125122  for (int i = 0; i < test_len; ++i) {
    126     check(v[i] == heap.prio(), "Wrong order in heap increase test.");
     123    check(v[i] == heap.prio() ,"Wrong order in heap increase test.");
    127124    heap.pop();
    128125  }
    129126}
     127
     128
    130129
    131130template <typename Heap>
     
    143142    if (dijkstra.reached(s)) {
    144143      check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a],
    145              "Error in shortest path tree.");
     144             "Error in a shortest path tree!");
    146145    }
    147146  }
     
    152151      Node s = digraph.source(a);
    153152      check( dijkstra.dist(n) - dijkstra.dist(s) == length[a],
    154              "Error in shortest path tree.");
     153             "Error in a shortest path tree!");
    155154    }
    156155  }
     
    174173    run();
    175174
    176   // BinHeap
    177175  {
    178176    typedef BinHeap<Prio, ItemIntMap> IntHeap;
     
    186184  }
    187185
    188   // FouraryHeap
    189   {
    190     typedef FouraryHeap<Prio, ItemIntMap> IntHeap;
    191     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    192     heapSortTest<IntHeap>();
    193     heapIncreaseTest<IntHeap>();
    194 
    195     typedef FouraryHeap<Prio, IntNodeMap > NodeHeap;
    196     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    197     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    198   }
    199 
    200   // KaryHeap
    201   {
    202     typedef KaryHeap<Prio, ItemIntMap> IntHeap;
    203     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    204     heapSortTest<IntHeap>();
    205     heapIncreaseTest<IntHeap>();
    206 
    207     typedef KaryHeap<Prio, IntNodeMap > NodeHeap;
    208     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    209     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    210   }
    211 
    212   // FibHeap
    213   {
    214     typedef FibHeap<Prio, ItemIntMap> IntHeap;
    215     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    216     heapSortTest<IntHeap>();
    217     heapIncreaseTest<IntHeap>();
    218 
    219     typedef FibHeap<Prio, IntNodeMap > NodeHeap;
    220     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    221     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    222   }
    223 
    224   // PairingHeap
    225   {
    226     typedef PairingHeap<Prio, ItemIntMap> IntHeap;
    227     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    228     heapSortTest<IntHeap>();
    229     heapIncreaseTest<IntHeap>();
    230 
    231     typedef PairingHeap<Prio, IntNodeMap > NodeHeap;
    232     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    233     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    234   }
    235 
    236   // RadixHeap
    237   {
    238     typedef RadixHeap<ItemIntMap> IntHeap;
    239     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    240     heapSortTest<IntHeap>();
    241     heapIncreaseTest<IntHeap>();
    242 
    243     typedef RadixHeap<IntNodeMap > NodeHeap;
    244     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    245     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    246   }
    247 
    248   // BinomHeap
    249   {
    250     typedef BinomHeap<Prio, ItemIntMap> IntHeap;
    251     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    252     heapSortTest<IntHeap>();
    253     heapIncreaseTest<IntHeap>();
    254 
    255     typedef BinomHeap<Prio, IntNodeMap > NodeHeap;
    256     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    257     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    258   }
    259 
    260   // BucketHeap, SimpleBucketHeap
    261   {
    262     typedef BucketHeap<ItemIntMap> IntHeap;
    263     checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
    264     heapSortTest<IntHeap>();
    265     heapIncreaseTest<IntHeap>();
    266 
    267     typedef BucketHeap<IntNodeMap > NodeHeap;
    268     checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
    269     dijkstraHeapTest<NodeHeap>(digraph, length, source);
    270 
    271     typedef SimpleBucketHeap<ItemIntMap> SimpleIntHeap;
    272     heapSortTest<SimpleIntHeap>();
    273   }
    274 
    275186  return 0;
    276187}
Note: See TracChangeset for help on using the changeset viewer.