src/test/dijkstra_heap_test.cc
changeset 1119 d3504fc075dc
parent 921 818510fa3d99
child 1139 f59038affc7e
equal deleted inserted replaced
8:6be0c663a4fc 9:ac6275607b61
    71   int error1=0;
    71   int error1=0;
    72   int error2=0;
    72   int error2=0;
    73 
    73 
    74   EdgeIt e;
    74   EdgeIt e;
    75   for(G.first(e); e!=INVALID; ++e) {
    75   for(G.first(e); e!=INVALID; ++e) {
    76     Node u=G.tail(e);
    76     Node u=G.source(e);
    77     Node v=G.head(e);
    77     Node v=G.target(e);
    78     if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap[e] )
    78     if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) > cap[e] )
    79       if ( dijkstra_test.reached(u) ) {
    79       if ( dijkstra_test.reached(u) ) {
    80 	std::cout<<"Error! dist(head)-dist(tail)- edge_length= " 
    80 	std::cout<<"Error! dist(target)-dist(source)- edge_length= " 
    81 		 <<dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    81 		 <<dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    82 	  - cap[e]<<std::endl;
    82 	  - cap[e]<<std::endl;
    83 	++error1;
    83 	++error1;
    84       }
    84       }
    85   }
    85   }
    86 
    86 
    87   NodeIt v;
    87   NodeIt v;
    88   for(G.first(v); v!=INVALID; ++v) {
    88   for(G.first(v); v!=INVALID; ++v) {
    89     if ( dijkstra_test.reached(v) ) {
    89     if ( dijkstra_test.reached(v) ) {
    90       Edge e=dijkstra_test.pred(v);
    90       Edge e=dijkstra_test.pred(v);
    91       Node u=G.tail(e);
    91       Node u=G.source(e);
    92       if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) != cap[e] ) {
    92       if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) != cap[e] ) {
    93 	std::cout<<"Error in a shortest path tree edge! Difference: " 
    93 	std::cout<<"Error in a shortest path tree edge! Difference: " 
    94 		 <<std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    94 		 <<std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
    95 			    - cap[e])<<std::endl;
    95 			    - cap[e])<<std::endl;
    96 	++error2;
    96 	++error2;
   120   
   120   
   121   error1=0;
   121   error1=0;
   122   error2=0;
   122   error2=0;
   123 
   123 
   124   for(G.first(e); e!=INVALID; ++e) {
   124   for(G.first(e); e!=INVALID; ++e) {
   125     Node u=G.tail(e);
   125     Node u=G.source(e);
   126     Node v=G.head(e);
   126     Node v=G.target(e);
   127     if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) > cap[e] )
   127     if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) > cap[e] )
   128       if ( dijkstra_test2.reached(u) ) {
   128       if ( dijkstra_test2.reached(u) ) {
   129 	std::cout<<"Error! dist(head)-dist(tail)- edge_length= " 
   129 	std::cout<<"Error! dist(target)-dist(source)- edge_length= " 
   130 		 <<dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   130 		 <<dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   131 	  - cap[e]<<std::endl;
   131 	  - cap[e]<<std::endl;
   132 	++error1;
   132 	++error1;
   133       }
   133       }
   134   }
   134   }
   135 
   135 
   136   for(G.first(v); v!=INVALID; ++v) {
   136   for(G.first(v); v!=INVALID; ++v) {
   137     if ( dijkstra_test2.reached(v) ) {
   137     if ( dijkstra_test2.reached(v) ) {
   138       Edge e=dijkstra_test2.pred(v);
   138       Edge e=dijkstra_test2.pred(v);
   139       Node u=G.tail(e);
   139       Node u=G.source(e);
   140       if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) != cap[e] ) {
   140       if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) != cap[e] ) {
   141 	std::cout<<"Error in a shortest path tree edge! Difference: " 
   141 	std::cout<<"Error in a shortest path tree edge! Difference: " 
   142 		 <<std::abs(dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   142 		 <<std::abs(dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   143 			    - cap[e])<<std::endl;
   143 			    - cap[e])<<std::endl;
   144 	++error2;
   144 	++error2;