src/work/alpar/dijkstra/dijkstra.cc
changeset 587 266fa11f222b
parent 586 04fdffd38e89
child 588 510cf257e6f2
     1.1 --- a/src/work/alpar/dijkstra/dijkstra.cc	Sat May 08 16:04:28 2004 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,117 +0,0 @@
     1.4 -#include <iostream>
     1.5 -#include <fstream>
     1.6 -
     1.7 -#include <smart_graph.h>
     1.8 -#include <list_graph.h>
     1.9 -#include <dimacs.h>
    1.10 -#include <dijkstra.h>
    1.11 -#include <time_measure.h>
    1.12 -
    1.13 -#include <bin_heap.h>
    1.14 -#include <fib_heap.h>
    1.15 -
    1.16 -using namespace hugo;
    1.17 -
    1.18 -int main(int, char **) {
    1.19 -  typedef SmartGraph::Node Node;
    1.20 -  typedef SmartGraph::NodeIt NodeIt;
    1.21 -  typedef SmartGraph::InEdgeIt InEdgeIt; 
    1.22 -
    1.23 -  SmartGraph G;
    1.24 -  Node s, t;
    1.25 -  SmartGraph::EdgeMap<int> cap(G);
    1.26 -  Timer tim;
    1.27 -  std::cout << "DIMACS load ..." << std::endl;
    1.28 -  readDimacsMaxFlow(std::cin, G, s, t, cap);
    1.29 -  std::cout << "               " << tim <<std::endl;
    1.30 -
    1.31 -  std::cout << "dijkstra demo ..." << std::endl;
    1.32 -  
    1.33 -  //double pre_time=currTime();
    1.34 -  tim.reset();
    1.35 -//   Dijkstra <SmartGraph,
    1.36 -//     SmartGraph::EdgeMap<int>,
    1.37 -//     FibHeap<SmartGraph::Node, int, SmartGraph::NodeMap<int> >
    1.38 -//     > dijkstra_test(G, cap); 
    1.39 -  
    1.40 -  Dijkstra <SmartGraph, SmartGraph::EdgeMap<int>, FibHeap >
    1.41 -    dijkstra_test(G, cap); 
    1.42 -  
    1.43 -  dijkstra_test.run(s);
    1.44 -  //double post_time=currTime();
    1.45 -  
    1.46 -  std::cout << "running time with fib_heap: " 
    1.47 -    // << post_time-pre_time << " sec"
    1.48 -	    << tim
    1.49 -	    << std::endl; 
    1.50 - 
    1.51 -  //pre_time=currTime();
    1.52 -  tim.reset();
    1.53 -//   Dijkstra < SmartGraph,
    1.54 -//     SmartGraph::EdgeMap<int>,
    1.55 -//     BinHeap<SmartGraph::Node, int, SmartGraph::NodeMap<int> > > 
    1.56 -//     dijkstra_test2(G, cap);
    1.57 -  
    1.58 -  Dijkstra <SmartGraph, SmartGraph::EdgeMap<int>, BinHeap >
    1.59 -    dijkstra_test2(G, cap); 
    1.60 -  
    1.61 -  dijkstra_test2.run(s);
    1.62 -  //post_time=currTime();
    1.63 -  
    1.64 -  std::cout << "running time with bin_heap: " 
    1.65 -    //    << post_time-pre_time << " sec"
    1.66 -	    << tim
    1.67 -	    << std::endl; 
    1.68 -  
    1.69 -
    1.70 -  int hiba_fib=0;
    1.71 -  int hiba_bin=0;
    1.72 -  NodeIt u;
    1.73 -  for ( G.first(u) ; G.valid(u); G.next(u) ) {
    1.74 -    InEdgeIt e;
    1.75 -    for ( G.first(e,u); G.valid(e); G.next(e) ) {
    1.76 -      Node v=G.tail(e);
    1.77 -      if ( dijkstra_test.dist(u) - dijkstra_test.dist(v) > cap[e] )
    1.78 -	{
    1.79 -	  std::cout<<"Hibas el a fibonaccis Dijkstraban: " 
    1.80 -		   << dijkstra_test.dist(u) - dijkstra_test.dist(v) - 
    1.81 -	    cap[e]<<std::endl;
    1.82 -	  ++hiba_fib;
    1.83 -	}
    1.84 -      if ( dijkstra_test2.dist(u) - dijkstra_test2.dist(v) > cap[e] )
    1.85 -	{
    1.86 -	  std::cout<<"Hibas el a binarisos Dijkstraban: " 
    1.87 -		   << dijkstra_test2.dist(u) - dijkstra_test2.dist(v) - 
    1.88 -	    cap[e]<<std::endl;
    1.89 -	  ++hiba_bin;
    1.90 -	}
    1.91 -      if ( e==dijkstra_test.pred(u) && 
    1.92 -	   dijkstra_test.dist(u) - dijkstra_test.dist(v) != cap[e] )
    1.93 -	{
    1.94 -	  std::cout<<"Hibas fael a fibonaccis Dijkstraban: "<<
    1.95 -	    dijkstra_test.dist(u) - dijkstra_test.dist(v)- cap[e]<<std::endl;
    1.96 -	  ++hiba_fib;
    1.97 -	}
    1.98 -      if ( e==dijkstra_test2.pred(u) && 
    1.99 -	   dijkstra_test2.dist(u) - dijkstra_test2.dist(v) != cap[e] )
   1.100 -	{
   1.101 -	  std::cout<<"Hibas fael a binarisos Dijkstraban: "<<
   1.102 -	    dijkstra_test2.dist(u) - dijkstra_test2.dist(v)- cap[e]<<std::endl;
   1.103 -	  ++hiba_bin;
   1.104 -	}
   1.105 -    }
   1.106 - 
   1.107 -    if ( dijkstra_test.dist(u) != dijkstra_test2.dist(u) ) 
   1.108 -      std::cout << "Nem egyezik meg a tavolsag!"<<std::endl;
   1.109 -
   1.110 -
   1.111 - }
   1.112 -
   1.113 -  std::cout << "Hibas elek szama a fibonaccis Dijkstraban: " 
   1.114 -	    << hiba_fib << " a " << G.edgeNum() <<"-bol."<< std::endl;
   1.115 -  
   1.116 -  std::cout << "Hibas elek szama a binarisos Dijkstraban: " 
   1.117 -	    << hiba_bin << " a " << G.edgeNum() <<"-bol."<< std::endl;
   1.118 -  
   1.119 -  return 0;
   1.120 -}