GRAPH_TYPEDEFS and UNDIRGRAPH_TYPEDEFS macros added to graph_utils.h.
6 #include <lemon/dijkstra.h>
8 class IntIntMap : public std::vector<int> {
10 typedef std::vector<int> Parent;
12 IntIntMap() : Parent() {}
13 IntIntMap(int n) : Parent(n) {}
14 IntIntMap(int n, int v) : Parent(n, v) {}
16 void set(int key, int value) {
17 Parent::operator[](key) = value;
22 template <typename _Heap>
23 void heapSortTest(int n) {
29 std::vector<int> v(n);
31 for (int i = 0; i < n; ++i) {
35 std::sort(v.begin(), v.end());
36 for (int i = 0; i < n; ++i) {
37 check(v[i] == heap.prio() ,"Wrong order in heap sort.");
42 template <typename _Heap>
43 void heapIncreaseTest(int n) {
49 std::vector<int> v(n);
51 for (int i = 0; i < n; ++i) {
55 for (int i = 0; i < n; ++i) {
56 v[i] += rand() % 1000;
57 heap.increase(i, v[i]);
59 std::sort(v.begin(), v.end());
60 for (int i = 0; i < n; ++i) {
61 check(v[i] == heap.prio() ,"Wrong order in heap increase test.");
68 template <typename _Graph, typename _LengthMap, typename _Heap>
69 void dijkstraHeapTest(_Graph& graph, _LengthMap& length,
70 typename _Graph::Node& start) {
74 typedef _LengthMap LengthMap;
76 typedef typename Graph::Node Node;
77 typedef typename Graph::Edge Edge;
78 typedef typename Graph::NodeIt NodeIt;
79 typedef typename Graph::EdgeIt EdgeIt;
81 typename Dijkstra<Graph, LengthMap>::template DefStandardHeap<Heap>::
82 Create dijkstra(graph, length);
86 for(EdgeIt e(graph); e!=INVALID; ++e) {
87 Node u=graph.source(e);
88 Node v=graph.target(e);
89 if (dijkstra.reached(u)) {
90 check( dijkstra.dist(v) - dijkstra.dist(u) <= length[e],
91 "Error in a shortest path tree edge!");
95 for(NodeIt v(graph); v!=INVALID; ++v) {
96 if ( dijkstra.reached(v) && dijkstra.pred(v) != INVALID ) {
97 Edge e=dijkstra.pred(v);
98 Node u=graph.source(e);
99 check( dijkstra.dist(v) - dijkstra .dist(u) == length[e],
100 "Error in a shortest path tree edge!");