deba@1187: // -*- c++ -*-
deba@1187: 
deba@1187: #include <iostream>
deba@1187: #include <fstream>
alpar@1215: #include <string>
deba@1187: #include <vector>
deba@1187: 
deba@1187: #include <lemon/concept_check.h>
deba@1330: #include <lemon/concept/heap.h>
deba@1187: 
deba@1206: #include <lemon/smart_graph.h>
deba@1206: 
deba@1206: #include <lemon/graph_reader.h>
deba@1206: 
deba@1187: #include <lemon/bin_heap.h>
deba@1187: #include <lemon/fib_heap.h>
deba@1187: #include <lemon/radix_heap.h>
deba@1728: #include <lemon/linear_heap.h>
deba@1187: 
deba@1206: #include "test_tools.h"
deba@1187: 
deba@1187: #include "heap_test.h"
deba@1187: 
deba@1728: #include <lemon/time_measure.h>
deba@1187: 
deba@1187: using namespace lemon;
deba@1330: using namespace lemon::concept;
deba@1187: 
deba@1187: 
deba@1187: int main() {
deba@1187: 
deba@1187:   typedef int Item;
deba@1187:   typedef int Prio;
deba@1187:   typedef IntIntMap ItemIntMap;
deba@1187: 
deba@1187:   typedef ListGraph Graph;
deba@1187: 
deba@1187:   typedef Graph::Edge Edge;
deba@1187:   typedef Graph::Node Node;
deba@1187:   typedef Graph::EdgeIt EdgeIt;
deba@1187:   typedef Graph::NodeIt NodeIt;
deba@1187:   typedef Graph::EdgeMap<int> LengthMap;
deba@1187: 
deba@1187:   Graph graph;
deba@1187:   LengthMap length(graph);
deba@1187:   Node start;
deba@1187: 
deba@1206:   /// \todo create own test graph
alpar@1215: 
alpar@1215:   std::string f_name;
alpar@1215:   if( getenv("srcdir") )
alpar@1215:     f_name = std::string(getenv("srcdir"));
alpar@1215:   else f_name = ".";
alpar@1215:   f_name += "/dijkstra_test.lgf";
alpar@1215:   
alpar@1215:   std::ifstream input(f_name.c_str());
alpar@1215:   check(input, "Input file '" << f_name << "' not found.");
deba@1744:   GraphReader<Graph>(input, graph).
deba@1845:     readEdgeMap("capacity", length).
deba@1744:     readNode("source", start).
deba@1744:     run();  
deba@1187:  
deba@1187:   {
deba@1187:     std::cerr << "Checking Bin Heap" << std::endl;
deba@1187: 
deba@1187:     typedef BinHeap<Item, Prio, ItemIntMap> IntHeap;
deba@1330:     checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
deba@1206:     heapSortTest<IntHeap>(100);
deba@1206:     heapIncreaseTest<IntHeap>(100);
deba@1187:     
deba@1187:     typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
deba@1330:     checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
deba@1728:     Timer timer;
deba@1187:     dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
deba@1728:     std::cout << timer << std::endl;
deba@1187:   }
deba@1187:   {
deba@1187:     std::cerr << "Checking Fib Heap" << std::endl;
deba@1187: 
deba@1187:     typedef FibHeap<Item, Prio, ItemIntMap> IntHeap;
deba@1330:     checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
deba@1206:     heapSortTest<IntHeap>(100);
deba@1206:     heapIncreaseTest<IntHeap>(100);
deba@1187: 
deba@1187:     typedef FibHeap<Node, Prio, Graph::NodeMap<int> > NodeHeap;
deba@1330:     checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
deba@1728:     Timer timer;
deba@1187:     dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
deba@1728:     std::cout << timer << std::endl;
deba@1187:   }
deba@1187:   {
deba@1187:     std::cerr << "Checking Radix Heap" << std::endl;
deba@1187: 
deba@1187:     typedef RadixHeap<Item, ItemIntMap> IntHeap;
deba@1330:     checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
deba@1206:     heapSortTest<IntHeap>(100);
deba@1206:     heapIncreaseTest<IntHeap>(100);
deba@1187: 
deba@1187:     typedef RadixHeap<Node, Graph::NodeMap<int> > NodeHeap;
deba@1330:     checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
deba@1728:     Timer timer;
deba@1187:     dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
deba@1728:     std::cout << timer << std::endl;
deba@1728:   }
deba@1728: 
deba@1728:   {
deba@1728:     std::cerr << "Checking Linear Heap" << std::endl;
deba@1728: 
deba@1728:     typedef LinearHeap<Item, ItemIntMap> IntHeap;
deba@1728:     checkConcept<Heap<Item, Prio, ItemIntMap>, IntHeap>();
deba@1728:     heapSortTest<IntHeap>(100);
deba@1728:     heapIncreaseTest<IntHeap>(100);
deba@1728: 
deba@1728:     typedef LinearHeap<Node, Graph::NodeMap<int> > NodeHeap;
deba@1728:     checkConcept<Heap<Node, Prio, Graph::NodeMap<int> >, NodeHeap>();
deba@1728:     Timer timer;
deba@1728:     dijkstraHeapTest<Graph, LengthMap, NodeHeap>(graph, length, start);
deba@1728:     std::cout << timer << std::endl;
deba@1187:   }
deba@1187: 
deba@1187:   std::cout << __FILE__ ": All tests passed.\n";
deba@1187: 
deba@1187:   return 0;
deba@1187: }