src/work/jacint/prim.cc
changeset 173 de9849252e78
child 211 9222a9b8b323
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/work/jacint/prim.cc	Thu Mar 11 23:31:13 2004 +0000
     1.3 @@ -0,0 +1,49 @@
     1.4 +#include <iostream>
     1.5 +#include <fstream>
     1.6 +
     1.7 +#include <list_graph.hh>
     1.8 +#include <dimacs.hh>
     1.9 +#include <prim.h>
    1.10 +#include <time_measure.h>
    1.11 +
    1.12 +#include <bin_heap.hh>
    1.13 +#include <fib_heap.h>
    1.14 +
    1.15 +using namespace hugo;
    1.16 +
    1.17 +int main(int, char **) {
    1.18 +  typedef ListGraph::NodeIt NodeIt;
    1.19 +
    1.20 +  ListGraph G;
    1.21 +  NodeIt s, t;
    1.22 +  ListGraph::EdgeMap<int> cap(G);
    1.23 +  readDimacsMaxFlow(std::cin, G, s, t, cap);
    1.24 +
    1.25 +  std::cout << "prim demo ..." << std::endl;
    1.26 +  
    1.27 +  double pre_time=currTime();
    1.28 +    Prim<ListGraph, int, FibHeap<ListGraph::NodeIt, int, 
    1.29 +    ListGraph::NodeMap<int> > > prim_test(G, cap);
    1.30 +    prim_test.run();
    1.31 +  double post_time=currTime();
    1.32 +    
    1.33 +  std::cout << "running time with fib_heap: " 
    1.34 +	    << post_time-pre_time << " sec"<< std::endl; 
    1.35 + 
    1.36 +  pre_time=currTime();
    1.37 +  Prim<ListGraph, int, BinHeap<ListGraph::NodeIt, int, 
    1.38 +    ListGraph::NodeMap<int> > > prim_test2(G, cap);
    1.39 +  prim_test2.run();
    1.40 +  post_time=currTime();
    1.41 +  
    1.42 +  std::cout << "running time with bin_heap: " 
    1.43 +	    << post_time-pre_time << " sec"<< std::endl; 
    1.44 +  
    1.45 +  std::cout<<"A minimalis feszitofa sulya fib kupaccal: "<< prim_test.weight() <<std::endl;
    1.46 +  std::cout<<"A minimalis feszitofa sulya bin kupaccal: "<< prim_test2.weight() <<std::endl;
    1.47 +  if ( prim_test.weight() != prim_test2.weight() ) 
    1.48 +    std::cout<<"Nem egyezik meg!"<<std::endl; 
    1.49 +  else std::cout<<"Megegyezik."<<std::endl; 
    1.50 +
    1.51 +  return 0;
    1.52 +}