src/test/dijkstra_test.cc
changeset 990 407e4d47fdd3
parent 959 c80ef5912903
child 1148 1eea022c7a16
equal deleted inserted replaced
11:4b93464d3222 12:0ce40d0cff34
    91   
    91   
    92   check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
    92   check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
    93 
    93 
    94 
    94 
    95   for(EdgeIt e(G); e!=INVALID; ++e) {
    95   for(EdgeIt e(G); e!=INVALID; ++e) {
    96     Node u=G.tail(e);
    96     Node u=G.source(e);
    97     Node v=G.head(e);
    97     Node v=G.target(e);
    98     check( !dijkstra_test.reached(u) ||
    98     check( !dijkstra_test.reached(u) ||
    99 	   (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= cap[e]),
    99 	   (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= cap[e]),
   100 	   "dist(head)-dist(tail)- edge_length= " 
   100 	   "dist(target)-dist(source)- edge_length= " 
   101 	   << dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   101 	   << dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   102 	   - cap[e]);
   102 	   - cap[e]);
   103   }
   103   }
   104 
   104 
   105   ///\bug This works only for integer lengths
   105   ///\bug This works only for integer lengths
   106   for(NodeIt v(G); v!=INVALID; ++v){
   106   for(NodeIt v(G); v!=INVALID; ++v){
   107     check(dijkstra_test.reached(v),"Each node should be reached.");
   107     check(dijkstra_test.reached(v),"Each node should be reached.");
   108     if ( dijkstra_test.pred(v)!=INVALID ) {
   108     if ( dijkstra_test.pred(v)!=INVALID ) {
   109       Edge e=dijkstra_test.pred(v);
   109       Edge e=dijkstra_test.pred(v);
   110       Node u=G.tail(e);
   110       Node u=G.source(e);
   111       check(u==dijkstra_test.predNode(v),"Wrong tree.");
   111       check(u==dijkstra_test.predNode(v),"Wrong tree.");
   112       check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == cap[e],
   112       check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == cap[e],
   113 	    "Wrong distance! Difference: " 
   113 	    "Wrong distance! Difference: " 
   114 	    << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   114 	    << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   115 			    - cap[e]));
   115 			    - cap[e]));