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