Changeset 209:765619b7cbb2 in lemon1.2 for test/dijkstra_test.cc
 Timestamp:
 07/13/08 20:51:02 (13 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

test/dijkstra_test.cc
r171 r209 1 /* * C++*1 /* * mode: C++; indenttabsmode: nil; * 2 2 * 3 * This file is a part of LEMON, a generic C++ optimization library 3 * This file is a part of LEMON, a generic C++ optimization library. 4 4 * 5 5 * Copyright (C) 20032008 … … 29 29 using namespace lemon; 30 30 31 void checkDijkstraCompile() 31 void checkDijkstraCompile() 32 32 { 33 33 typedef int VType; … … 35 35 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap; 36 36 typedef Dijkstra<Digraph, LengthMap> DType; 37 37 38 38 Digraph G; 39 39 Digraph::Node n; … … 61 61 } 62 62 63 void checkDijkstraFunctionCompile() 63 void checkDijkstraFunctionCompile() 64 64 { 65 65 typedef int VType; … … 68 68 typedef Digraph::Node Node; 69 69 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap; 70 70 71 71 Digraph g; 72 72 dijkstra(g,LengthMap(),Node()).run(); … … 79 79 80 80 template <class Digraph> 81 void checkDijkstra() { 81 void checkDijkstra() { 82 82 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph); 83 83 typedef typename Digraph::template ArcMap<int> LengthMap; … … 87 87 LengthMap length(G); 88 88 PetStruct<Digraph> ps = addPetersen(G, 5); 89 89 90 90 for(int i=0;i<5;i++) { 91 91 length[ps.outcir[i]]=4; … … 95 95 s=ps.outer[0]; 96 96 t=ps.inner[1]; 97 98 Dijkstra<Digraph, LengthMap> 99 97 98 Dijkstra<Digraph, LengthMap> 99 dijkstra_test(G, length); 100 100 dijkstra_test.run(s); 101 101 102 102 check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path."); 103 103 … … 107 107 check(pathSource(G, p) == s,"path() found a wrong path."); 108 108 check(pathTarget(G, p) == t,"path() found a wrong path."); 109 109 110 110 for(ArcIt e(G); e!=INVALID; ++e) { 111 111 Node u=G.source(e); 112 112 Node v=G.target(e); 113 113 check( !dijkstra_test.reached(u)  (dijkstra_test.dist(v)  dijkstra_test.dist(u) <= length[e]), 114 114 "dist(target)dist(source)arc_length= " << dijkstra_test.dist(v)  dijkstra_test.dist(u)  length[e]); 115 115 } 116 116 … … 122 122 check(u==dijkstra_test.predNode(v),"Wrong tree."); 123 123 check(dijkstra_test.dist(v)  dijkstra_test.dist(u) == length[e], 124 124 "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v)  dijkstra_test.dist(u)  length[e])); 125 125 } 126 126 } 127 127 128 128 { 129 129 NullMap<Node,Arc> myPredMap;
Note: See TracChangeset
for help on using the changeset viewer.