Location: LEMON/LEMON-main/test/heap_test.cc - annotation
Load file history
Porting SmartGraph from svn -r 3481
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b r100:4f754b4cf82b | /* -*- C++ -*-
*
* This file is a part of LEMON, a generic C++ optimization library
*
* Copyright (C) 2003-2008
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <lemon/concept_check.h>
#include <lemon/concepts/heap.h>
#include <lemon/list_graph.h>
#include <lemon/digraph_reader.h>
#include <lemon/bin_heap.h>
#include <lemon/fib_heap.h>
#include <lemon/radix_heap.h>
#include <lemon/bucket_heap.h>
#include "test_tools.h"
#include "heap_test.h"
#include <lemon/time_measure.h>
using namespace lemon;
using namespace lemon::concepts;
int main() {
typedef int Item;
typedef int Prio;
typedef IntIntMap ItemIntMap;
typedef ListDigraph Digraph;
typedef Digraph::Arc Arc;
typedef Digraph::Node Node;
typedef Digraph::ArcIt ArcIt;
typedef Digraph::NodeIt NodeIt;
typedef Digraph::ArcMap<int> LengthMap;
Digraph digraph;
LengthMap length(digraph);
Node start;
/// \todo create own test digraph
std::string f_name;
if( getenv("srcdir") )
f_name = std::string(getenv("srcdir"));
else f_name = ".";
f_name += "/test/dijkstra_test.lgf";
std::ifstream input(f_name.c_str());
check(input, "Input file '" << f_name << "' not found.");
DigraphReader<Digraph>(input, digraph).
readArcMap("capacity", length).
readNode("source", start).
run();
{
std::cerr << "Checking Bin Heap" << std::endl;
typedef BinHeap<Prio, ItemIntMap> IntHeap;
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
heapSortTest<IntHeap>(100);
heapIncreaseTest<IntHeap>(100);
typedef FibHeap<Prio, Digraph::NodeMap<int> > NodeHeap;
checkConcept<Heap<Prio, Digraph::NodeMap<int> >, NodeHeap>();
Timer timer;
dijkstraHeapTest<Digraph, LengthMap, NodeHeap>(digraph, length, start);
std::cout << timer << std::endl;
}
{
std::cerr << "Checking Fib Heap" << std::endl;
typedef FibHeap<Prio, ItemIntMap> IntHeap;
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
heapSortTest<IntHeap>(100);
heapIncreaseTest<IntHeap>(100);
typedef FibHeap<Prio, Digraph::NodeMap<int> > NodeHeap;
checkConcept<Heap<Prio, Digraph::NodeMap<int> >, NodeHeap>();
Timer timer;
dijkstraHeapTest<Digraph, LengthMap, NodeHeap>(digraph, length, start);
std::cout << timer << std::endl;
}
{
std::cerr << "Checking Radix Heap" << std::endl;
typedef RadixHeap<ItemIntMap> IntHeap;
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
heapSortTest<IntHeap>(100);
heapIncreaseTest<IntHeap>(100);
typedef RadixHeap<Digraph::NodeMap<int> > NodeHeap;
checkConcept<Heap<Prio, Digraph::NodeMap<int> >, NodeHeap>();
Timer timer;
dijkstraHeapTest<Digraph, LengthMap, NodeHeap>(digraph, length, start);
std::cout << timer << std::endl;
}
{
std::cerr << "Checking Bucket Heap" << std::endl;
typedef BucketHeap<ItemIntMap> IntHeap;
checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
heapSortTest<IntHeap>(100);
heapIncreaseTest<IntHeap>(100);
typedef BucketHeap<Digraph::NodeMap<int> > NodeHeap;
checkConcept<Heap<Prio, Digraph::NodeMap<int> >, NodeHeap>();
Timer timer;
dijkstraHeapTest<Digraph, LengthMap, NodeHeap>(digraph, length, start);
std::cout << timer << std::endl;
}
std::cout << __FILE__ ": All tests passed.\n";
return 0;
}
|