diff -r b2acba449222 -r e6a156fc186d src/work/jacint/dijkstra.cc --- a/src/work/jacint/dijkstra.cc Thu Apr 22 13:59:37 2004 +0000 +++ b/src/work/jacint/dijkstra.cc Thu Apr 22 14:11:28 2004 +0000 @@ -1,99 +1,57 @@ #include #include -#include -#include -#include +#include +#include #include #include - -#include -#include +#include using namespace hugo; int main(int, char **) { - typedef SmartGraph::Node Node; - typedef SmartGraph::NodeIt NodeIt; - typedef SmartGraph::InEdgeIt InEdgeIt; + + typedef ListGraph Graph; - SmartGraph G; + typedef Graph::Node Node; + typedef Graph::EdgeIt EdgeIt; + + Graph G; Node s, t; - SmartGraph::EdgeMap cap(G); + Graph::EdgeMap cap(G); readDimacsMaxFlow(std::cin, G, s, t, cap); - - std::cout << "dijkstra demo ..." << std::endl; + Timer ts; - double pre_time=currTime(); - Dijkstra > > dijkstra_test(G, cap); - dijkstra_test.run(s); + std::cout << "Testing dijkstra.h with Fibonacci-heap +implementation fib_heap.h ..." << std::endl; + + Dijkstra > +> dijkstra_test(G, s, cap); + ts.reset(); + dijkstra_test.run(); + std::cout << "elapsed time: " << ts << std::endl; double post_time=currTime(); - std::cout << "running time with fib_heap: " - << post_time-pre_time << " sec"<< std::endl; + std::cout << "running time: " << post_time-pre_time << " sec"<< std::endl; - pre_time=currTime(); - Dijkstra > > dijkstra_test2(G, cap); - dijkstra_test2.run(s); - post_time=currTime(); - - std::cout << "running time with bin_heap: " - << post_time-pre_time << " sec"<< std::endl; - + EachEdgeIt e; - int hiba_fib=0; - int hiba_bin=0; - NodeIt u; - for ( G.first(u) ; G.valid(u); G.next(u) ) { - InEdgeIt e; - for ( G.first(e,u); G.valid(e); G.next(e) ) { - Node v=G.tail(e); - if ( dijkstra_test.dist(u) - dijkstra_test.dist(v) > cap[e] ) - { - std::cout<<"Hibas el a fibonaccis Dijkstraban: " - << dijkstra_test.dist(u) - dijkstra_test.dist(v) - - cap[e]< cap[e] ) - { - std::cout<<"Hibas el a binarisos Dijkstraban: " - << dijkstra_test2.dist(u) - dijkstra_test2.dist(v) - - cap[e]< cap.get(e) ) { + std::cout<<"Hiba: "<