8 #include <lemon/concept_check.h>
10 #include <lemon/smart_graph.h>
12 #include <lemon/graph_reader.h>
14 #include <lemon/bin_heap.h>
15 #include <lemon/fib_heap.h>
16 #include <lemon/radix_heap.h>
18 #include "test_tools.h"
20 #include "heap_test.h"
23 using namespace lemon;
25 template <typename Item, typename Prio, typename ItemIntMap>
29 template <typename _Heap>
37 ignore_unused_variable_warning(item);
38 ignore_unused_variable_warning(prio);
40 typedef typename _Heap::state_enum state_enum;
43 ignore_unused_variable_warning(state);
45 _Heap heap1 = _Heap(map);
47 ignore_unused_variable_warning(heap1);
49 heap.push(item, prio);
57 heap.decrease(item, prio);
58 heap.increase(item, prio);
63 state = heap.state(item);
65 state = _Heap::PRE_HEAP;
66 state = _Heap::IN_HEAP;
67 state = _Heap::POST_HEAP;
73 Constraints() : heap(0), map(0) {}
81 typedef IntIntMap ItemIntMap;
83 typedef ListGraph Graph;
85 typedef Graph::Edge Edge;
86 typedef Graph::Node Node;
87 typedef Graph::EdgeIt EdgeIt;
88 typedef Graph::NodeIt NodeIt;
89 typedef Graph::EdgeMap<int> LengthMap;
92 LengthMap length(graph);
95 /// \todo create own test graph
98 if( getenv("srcdir") )
99 f_name = std::string(getenv("srcdir"));
101 f_name += "/dijkstra_test.lgf";
103 std::ifstream input(f_name.c_str());
104 check(input, "Input file '" << f_name << "' not found.");
105 readGraph(input, graph, length, start);
108 std::cerr << "Checking Bin Heap" << std::endl;
110 typedef BinHeap<Item, Prio, ItemIntMap> IntHeap;
111 checkConcept<HeapConcept<Item, Prio, ItemIntMap>, IntHeap>();
112 heapSortTest<IntHeap>(100);
113 heapIncreaseTest<IntHeap>(100);
115 typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
116 checkConcept<HeapConcept<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
117 dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
120 std::cerr << "Checking Fib Heap" << std::endl;
122 typedef FibHeap<Item, Prio, ItemIntMap> IntHeap;
123 checkConcept<HeapConcept<Item, Prio, ItemIntMap>, IntHeap>();
124 heapSortTest<IntHeap>(100);
125 heapIncreaseTest<IntHeap>(100);
127 typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
128 checkConcept<HeapConcept<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
129 dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
132 std::cerr << "Checking Radix Heap" << std::endl;
134 typedef RadixHeap<Item, ItemIntMap> IntHeap;
135 checkConcept<HeapConcept<Item, Prio, ItemIntMap>, IntHeap>();
136 heapSortTest<IntHeap>(100);
137 heapIncreaseTest<IntHeap>(100);
139 typedef RadixHeap<Node, Graph::NodeMap<int> > NodeHeap;
140 checkConcept<HeapConcept<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
141 dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
144 std::cout << __FILE__ ": All tests passed.\n";