// -*- c++ -*- #include #include #include #include #include #include #include #include #include #include #include "test_tools.h" #include "heap_test.h" using namespace lemon; template class HeapConcept { public: template struct Constraints { public: void constraints() { Item item; Prio prio; ignore_unused_variable_warning(item); ignore_unused_variable_warning(prio); typedef typename _Heap::state_enum state_enum; state_enum state; ignore_unused_variable_warning(state); _Heap heap1 = _Heap(map); ignore_unused_variable_warning(heap1); heap.push(item, prio); prio = heap.prio(); item = heap.top(); heap.pop(); heap.set(item, prio); heap.decrease(item, prio); heap.increase(item, prio); prio = heap[item]; heap.erase(item); state = heap.state(item); state = _Heap::PRE_HEAP; state = _Heap::IN_HEAP; state = _Heap::POST_HEAP; } _Heap& heap; ItemIntMap& map; Constraints() : heap(0), map(0) {} }; }; int main() { typedef int Item; typedef int Prio; typedef IntIntMap ItemIntMap; typedef ListGraph Graph; typedef Graph::Edge Edge; typedef Graph::Node Node; typedef Graph::EdgeIt EdgeIt; typedef Graph::NodeIt NodeIt; typedef Graph::EdgeMap LengthMap; Graph graph; LengthMap length(graph); Node start; /// \todo create own test graph std::string f_name; if( getenv("srcdir") ) f_name = std::string(getenv("srcdir")); else f_name = "."; f_name += "/dijkstra_test.lgf"; std::ifstream input(f_name.c_str()); check(input, "Input file '" << f_name << "' not found."); readGraph(input, graph, length, start); { std::cerr << "Checking Bin Heap" << std::endl; typedef BinHeap IntHeap; checkConcept, IntHeap>(); heapSortTest(100); heapIncreaseTest(100); typedef FibHeap > NodeHeap; checkConcept >, NodeHeap>(); dijkstraHeapTest(graph, length, start); } { std::cerr << "Checking Fib Heap" << std::endl; typedef FibHeap IntHeap; checkConcept, IntHeap>(); heapSortTest(100); heapIncreaseTest(100); typedef FibHeap > NodeHeap; checkConcept >, NodeHeap>(); dijkstraHeapTest(graph, length, start); } { std::cerr << "Checking Radix Heap" << std::endl; typedef RadixHeap IntHeap; checkConcept, IntHeap>(); heapSortTest(100); heapIncreaseTest(100); typedef RadixHeap > NodeHeap; checkConcept >, NodeHeap>(); dijkstraHeapTest(graph, length, start); } std::cout << __FILE__ ": All tests passed.\n"; return 0; }