Naming and coding style fixes and various other changes.
2 * src/test/dijkstra_test.cc - Part of LEMON, a generic C++ optimization library
4 * Copyright (C) 2004 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5 * (Egervary Combinatorial Optimization Research Group, EGRES).
7 * Permission to use, modify and distribute this software is granted
8 * provided that this copyright notice appears in all copies. For
9 * precise terms see the accompanying LICENSE file.
11 * This software is provided "AS IS" with no warranty of any kind,
12 * express or implied, and with no claim as to its suitability for any
17 #include "test_tools.h"
18 #include <lemon/smart_graph.h>
19 #include <lemon/dijkstra.h>
20 #include<lemon/skeletons/graph.h>
21 #include<lemon/skeletons/maps.h>
22 using namespace lemon;
24 const int PET_SIZE =5;
27 void check_Dijkstra_BinHeap_Compile()
30 typedef skeleton::StaticGraph Graph;
32 typedef Graph::Edge Edge;
33 typedef Graph::Node Node;
34 typedef Graph::EdgeIt EdgeIt;
35 typedef Graph::NodeIt NodeIt;
36 typedef skeleton::ReadMap<Edge,VType> LengthMap;
38 typedef Dijkstra<Graph, LengthMap> DType;
47 DType::PredNodeMap pn(G);
50 DType dijkstra_test(G,cap);
54 l = dijkstra_test.dist(n);
55 e = dijkstra_test.pred(n);
56 n = dijkstra_test.predNode(n);
57 d = dijkstra_test.distMap();
58 p = dijkstra_test.predMap();
59 pn = dijkstra_test.predNodeMap();
60 b = dijkstra_test.reached(n);
67 typedef SmartGraph Graph;
69 typedef Graph::Edge Edge;
70 typedef Graph::Node Node;
71 typedef Graph::EdgeIt EdgeIt;
72 typedef Graph::NodeIt NodeIt;
73 typedef Graph::EdgeMap<int> LengthMap;
78 PetStruct<Graph> ps = addPetersen(G,PET_SIZE);
80 for(int i=0;i<PET_SIZE;i++) {
88 Dijkstra<Graph, LengthMap>
89 dijkstra_test(G, cap);
92 check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
95 for(EdgeIt e(G); e!=INVALID; ++e) {
98 check( !dijkstra_test.reached(u) ||
99 (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= cap[e]),
100 "dist(head)-dist(tail)- edge_length= "
101 << dijkstra_test.dist(v) - dijkstra_test.dist(u)
105 ///\bug This works only for integer lengths
106 for(NodeIt v(G); v!=INVALID; ++v){
107 check(dijkstra_test.reached(v),"Each node should be reached.");
108 if ( dijkstra_test.pred(v)!=INVALID ) {
109 Edge e=dijkstra_test.pred(v);
111 check(u==dijkstra_test.predNode(v),"Wrong tree.");
112 check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == cap[e],
113 "Wrong distance! Difference: "
114 << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u)