test/dijkstra_test.cc
changeset 218 0d6511647639
parent 209 765619b7cbb2
child 220 a5d8c039f218
equal deleted inserted replaced
2:ed3507799490 3:808b7be47087
   108   check(pathTarget(G, p) == t,"path() found a wrong path.");
   108   check(pathTarget(G, p) == t,"path() found a wrong path.");
   109 
   109 
   110   for(ArcIt e(G); e!=INVALID; ++e) {
   110   for(ArcIt e(G); e!=INVALID; ++e) {
   111     Node u=G.source(e);
   111     Node u=G.source(e);
   112     Node v=G.target(e);
   112     Node v=G.target(e);
   113     check( !dijkstra_test.reached(u) || (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]),
   113     check( !dijkstra_test.reached(u) ||
   114            "dist(target)-dist(source)-arc_length= " << dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]);
   114            (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]),
       
   115            "dist(target)-dist(source)-arc_length= " <<
       
   116            dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]);
   115   }
   117   }
   116 
   118 
   117   for(NodeIt v(G); v!=INVALID; ++v){
   119   for(NodeIt v(G); v!=INVALID; ++v){
   118     check(dijkstra_test.reached(v),"Each node should be reached.");
   120     check(dijkstra_test.reached(v),"Each node should be reached.");
   119     if ( dijkstra_test.predArc(v)!=INVALID ) {
   121     if ( dijkstra_test.predArc(v)!=INVALID ) {
   120       Arc e=dijkstra_test.predArc(v);
   122       Arc e=dijkstra_test.predArc(v);
   121       Node u=G.source(e);
   123       Node u=G.source(e);
   122       check(u==dijkstra_test.predNode(v),"Wrong tree.");
   124       check(u==dijkstra_test.predNode(v),"Wrong tree.");
   123       check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e],
   125       check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e],
   124             "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]));
   126             "Wrong distance! Difference: " <<
       
   127             std::abs(dijkstra_test.dist(v)-dijkstra_test.dist(u)-length[e]));
   125     }
   128     }
   126   }
   129   }
   127 
   130 
   128   {
   131   {
   129     NullMap<Node,Arc> myPredMap;
   132     NullMap<Node,Arc> myPredMap;