src/test/dijkstra_heap_test.cc
changeset 1266 74d616d081f0
parent 1194 7bce0ef61d6b
equal deleted inserted replaced
12:749115aed5c9 13:032a0eccba38
   117 
   117 
   118   NodeIt v;
   118   NodeIt v;
   119   for(NodeIt v(graph); v!=INVALID; ++v) {
   119   for(NodeIt v(graph); v!=INVALID; ++v) {
   120     if ( dijkstra_test.reached(v) ) {
   120     if ( dijkstra_test.reached(v) ) {
   121       Edge e=dijkstra_test.pred(v);
   121       Edge e=dijkstra_test.pred(v);
   122       Node u=graph.source(e);
   122       if(e!=INVALID) {
   123       if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) != cap[e] ) {
   123 	Node u=graph.source(e);
   124 	std::cout<<"Error in a shortest path tree edge! Difference: " 
   124 	if ( dijkstra_test.dist(v) - dijkstra_test.dist(u) != cap[e] ) {
   125 		 <<std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   125 	  std::cout<<"Error in a shortest path tree edge! Difference: " 
   126 			    - cap[e])<<std::endl;
   126 		   <<std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) 
   127 	++error2;
   127 			      - cap[e])<<std::endl;
       
   128 	  ++error2;
       
   129 	}
   128       }
   130       }
   129     }
   131     }
   130   }
   132   }
   131 
   133   
   132 
   134 
   133   
   135   
   134   std::cout << error1 << " non-tree and " << error2 
   136   std::cout << error1 << " non-tree and " << error2 
   135 	    << " shortest path tree edge is erroneous."<<std::endl;
   137 	    << " shortest path tree edge is erroneous."<<std::endl;
   136 
   138 
   166   }
   168   }
   167 
   169 
   168   for(NodeIt n(graph); v!=INVALID; ++v) {
   170   for(NodeIt n(graph); v!=INVALID; ++v) {
   169     if ( dijkstra_test2.reached(v) ) {
   171     if ( dijkstra_test2.reached(v) ) {
   170       Edge e=dijkstra_test2.pred(v);
   172       Edge e=dijkstra_test2.pred(v);
   171       Node u=graph.source(e);
   173       if(e!=INVALID) {
   172       if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) != cap[e] ) {
   174 	Node u=graph.source(e);
   173 	std::cout<<"Error in a shortest path tree edge! Difference: " 
   175 	if ( dijkstra_test2.dist(v) - dijkstra_test2.dist(u) != cap[e] ) {
   174 		 <<std::abs(dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   176 	  std::cout<<"Error in a shortest path tree edge! Difference: " 
   175 			    - cap[e])<<std::endl;
   177 		   <<std::abs(dijkstra_test2.dist(v) - dijkstra_test2.dist(u) 
   176 	++error2;
   178 			      - cap[e])<<std::endl;
       
   179 	  ++error2;
       
   180 	}
   177       }
   181       }
   178     }
   182     }
   179   }
   183   }
   180 
   184   
   181 
   185 
   182   std::cout << error1 << " non-tree and " << error2 
   186   std::cout << error1 << " non-tree and " << error2 
   183 	    << " shortest path tree edge is erroneous."<<std::endl;
   187 	    << " shortest path tree edge is erroneous."<<std::endl;
   184 
   188 
   185   std::cout <<
   189   std::cout <<
   213   }
   217   }
   214 
   218 
   215   for(NodeIt n(graph); v!=INVALID; ++v) {
   219   for(NodeIt n(graph); v!=INVALID; ++v) {
   216     if ( dijkstra_test3.reached(v) ) {
   220     if ( dijkstra_test3.reached(v) ) {
   217       Edge e=dijkstra_test3.pred(v);
   221       Edge e=dijkstra_test3.pred(v);
   218       Node u=graph.source(e);
   222       if(e!=INVALID) {
   219       if ( dijkstra_test3.dist(v) - dijkstra_test3.dist(u) != cap[e] ) {
   223 	Node u=graph.source(e);
   220 	std::cout<<"Error in a shortest path tree edge! Difference: " 
   224 	if ( dijkstra_test3.dist(v) - dijkstra_test3.dist(u) != cap[e] ) {
   221 		 <<std::abs(dijkstra_test3.dist(v) - dijkstra_test3.dist(u) 
   225 	  std::cout<<"Error in a shortest path tree edge! Difference: " 
   222 			    - cap[e])<<std::endl;
   226 		   <<std::abs(dijkstra_test3.dist(v) - dijkstra_test3.dist(u) 
   223 	++error2;
   227 			      - cap[e])<<std::endl;
       
   228 	  ++error2;
       
   229 	}
   224       }
   230       }
   225     }
   231     }
   226   }
   232   }
   227 
   233   
   228 
   234 
   229   std::cout << error1 << " non-tree and " << error2 
   235   std::cout << error1 << " non-tree and " << error2 
   230 	    << " shortest path tree edge is erroneous."<<std::endl;
   236 	    << " shortest path tree edge is erroneous."<<std::endl;
   231 
   237 
   232   return 0;
   238   return 0;