COIN-OR::LEMON - Graph Library

source: lemon-0.x/src/test/heap_test.cc @ 1330:52ef02524468

Last change on this file since 1330:52ef02524468 was 1330:52ef02524468, checked in by Balazs Dezso, 19 years ago

Heap concept moved to namespace concept.

File size: 2.4 KB
RevLine 
[1187]1// -*- c++ -*-
2
3#include <iostream>
4#include <fstream>
[1215]5#include <string>
[1187]6#include <vector>
7
8#include <lemon/concept_check.h>
[1330]9#include <lemon/concept/heap.h>
[1187]10
[1206]11#include <lemon/smart_graph.h>
12
13#include <lemon/graph_reader.h>
14
[1187]15#include <lemon/bin_heap.h>
16#include <lemon/fib_heap.h>
17#include <lemon/radix_heap.h>
18
[1206]19#include "test_tools.h"
[1187]20
21#include "heap_test.h"
22
23
24using namespace lemon;
[1330]25using namespace lemon::concept;
[1187]26
27
28int main() {
29
30  typedef int Item;
31  typedef int Prio;
32  typedef IntIntMap ItemIntMap;
33
34  typedef ListGraph Graph;
35
36  typedef Graph::Edge Edge;
37  typedef Graph::Node Node;
38  typedef Graph::EdgeIt EdgeIt;
39  typedef Graph::NodeIt NodeIt;
40  typedef Graph::EdgeMap<int> LengthMap;
41
42  Graph graph;
43  LengthMap length(graph);
44  Node start;
45
[1206]46  /// \todo create own test graph
[1215]47
48  std::string f_name;
49  if( getenv("srcdir") )
50    f_name = std::string(getenv("srcdir"));
51  else f_name = ".";
52  f_name += "/dijkstra_test.lgf";
53 
54  std::ifstream input(f_name.c_str());
55  check(input, "Input file '" << f_name << "' not found.");
[1206]56  readGraph(input, graph, length, start); 
[1187]57 
58  {
59    std::cerr << "Checking Bin Heap" << std::endl;
60
61    typedef BinHeap<Item, Prio, ItemIntMap> IntHeap;
[1330]62    checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
[1206]63    heapSortTest<IntHeap>(100);
64    heapIncreaseTest<IntHeap>(100);
[1187]65   
66    typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
[1330]67    checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
[1187]68    dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
69  }
70  {
71    std::cerr << "Checking Fib Heap" << std::endl;
72
73    typedef FibHeap<Item, Prio, ItemIntMap> IntHeap;
[1330]74    checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
[1206]75    heapSortTest<IntHeap>(100);
76    heapIncreaseTest<IntHeap>(100);
[1187]77
78    typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
[1330]79    checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
[1187]80    dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
81  }
82  {
83    std::cerr << "Checking Radix Heap" << std::endl;
84
85    typedef RadixHeap<Item, ItemIntMap> IntHeap;
[1330]86    checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
[1206]87    heapSortTest<IntHeap>(100);
88    heapIncreaseTest<IntHeap>(100);
[1187]89
90    typedef RadixHeap<Node, Graph::NodeMap<int> > NodeHeap;
[1330]91    checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
[1187]92    dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
93  }
94
95  std::cout << __FILE__ ": All tests passed.\n";
96
97  return 0;
98}
Note: See TracBrowser for help on using the repository browser.