alpar@1956: /* -*- C++ -*- alpar@1956: * alpar@1956: * This file is a part of LEMON, a generic C++ optimization library alpar@1956: * alpar@1956: * Copyright (C) 2003-2006 alpar@1956: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@1956: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@1956: * alpar@1956: * Permission to use, modify and distribute this software is granted alpar@1956: * provided that this copyright notice appears in all copies. For alpar@1956: * precise terms see the accompanying LICENSE file. alpar@1956: * alpar@1956: * This software is provided "AS IS" with no warranty of any kind, alpar@1956: * express or implied, and with no claim as to its suitability for any alpar@1956: * purpose. alpar@1956: * alpar@1956: */ deba@1187: deba@1187: #include deba@1187: #include alpar@1215: #include deba@1187: #include deba@1187: deba@1187: #include alpar@2260: #include deba@1187: deba@1206: #include deba@1206: deba@1206: #include deba@1206: deba@1187: #include deba@1187: #include deba@1187: #include deba@2038: #include deba@1187: deba@1206: #include "test_tools.h" deba@1187: deba@1187: #include "heap_test.h" deba@1187: deba@1728: #include deba@1187: deba@1187: using namespace lemon; alpar@2260: using namespace lemon::concepts; 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 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 = "."; ladanyi@2108: f_name += "/test/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(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 IntHeap; deba@1330: checkConcept, IntHeap>(); deba@1206: heapSortTest(100); deba@1206: heapIncreaseTest(100); deba@1187: deba@1187: typedef FibHeap > NodeHeap; deba@1330: checkConcept >, NodeHeap>(); deba@1728: Timer timer; deba@1187: dijkstraHeapTest(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 IntHeap; deba@1330: checkConcept, IntHeap>(); deba@1206: heapSortTest(100); deba@1206: heapIncreaseTest(100); deba@1187: deba@1187: typedef FibHeap > NodeHeap; deba@1330: checkConcept >, NodeHeap>(); deba@1728: Timer timer; deba@1187: dijkstraHeapTest(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 IntHeap; deba@1330: checkConcept, IntHeap>(); deba@1206: heapSortTest(100); deba@1206: heapIncreaseTest(100); deba@1187: deba@1187: typedef RadixHeap > NodeHeap; deba@1330: checkConcept >, NodeHeap>(); deba@1728: Timer timer; deba@1187: dijkstraHeapTest(graph, length, start); deba@1728: std::cout << timer << std::endl; deba@1728: } deba@1728: deba@1728: { deba@2038: std::cerr << "Checking Bucket Heap" << std::endl; deba@1728: deba@2038: typedef BucketHeap IntHeap; deba@1728: checkConcept, IntHeap>(); deba@1728: heapSortTest(100); deba@1728: heapIncreaseTest(100); deba@1728: deba@2038: typedef BucketHeap > NodeHeap; deba@1728: checkConcept >, NodeHeap>(); deba@1728: Timer timer; deba@1728: dijkstraHeapTest(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: }