src/work/jacint/prim.cc
author alpar
Sat, 20 Mar 2004 16:13:19 +0000
changeset 217 fc549fac0dd0
parent 173 de9849252e78
child 220 7deda4d6a07a
permissions -rw-r--r--
Several bugfixes
jacint@173
     1
#include <iostream>
jacint@173
     2
#include <fstream>
jacint@173
     3
jacint@211
     4
#include <list_graph.h>
jacint@211
     5
#include <dimacs.h>
jacint@173
     6
#include <prim.h>
jacint@173
     7
#include <time_measure.h>
jacint@173
     8
jacint@173
     9
#include <bin_heap.hh>
jacint@173
    10
#include <fib_heap.h>
jacint@173
    11
jacint@173
    12
using namespace hugo;
jacint@173
    13
jacint@173
    14
int main(int, char **) {
jacint@211
    15
  typedef ListGraph::Node Node;
jacint@173
    16
jacint@173
    17
  ListGraph G;
jacint@211
    18
  Node s, t;
jacint@173
    19
  ListGraph::EdgeMap<int> cap(G);
jacint@173
    20
  readDimacsMaxFlow(std::cin, G, s, t, cap);
jacint@173
    21
jacint@173
    22
  std::cout << "prim demo ..." << std::endl;
jacint@173
    23
  
jacint@173
    24
  double pre_time=currTime();
jacint@211
    25
    Prim<ListGraph, int, FibHeap<ListGraph::Node, int, 
jacint@173
    26
    ListGraph::NodeMap<int> > > prim_test(G, cap);
jacint@173
    27
    prim_test.run();
jacint@173
    28
  double post_time=currTime();
jacint@173
    29
    
jacint@173
    30
  std::cout << "running time with fib_heap: " 
jacint@173
    31
	    << post_time-pre_time << " sec"<< std::endl; 
jacint@173
    32
 
jacint@173
    33
  pre_time=currTime();
jacint@211
    34
  Prim<ListGraph, int, BinHeap<ListGraph::Node, int, 
jacint@173
    35
    ListGraph::NodeMap<int> > > prim_test2(G, cap);
jacint@173
    36
  prim_test2.run();
jacint@173
    37
  post_time=currTime();
jacint@173
    38
  
jacint@173
    39
  std::cout << "running time with bin_heap: " 
jacint@173
    40
	    << post_time-pre_time << " sec"<< std::endl; 
jacint@173
    41
  
jacint@173
    42
  std::cout<<"A minimalis feszitofa sulya fib kupaccal: "<< prim_test.weight() <<std::endl;
jacint@173
    43
  std::cout<<"A minimalis feszitofa sulya bin kupaccal: "<< prim_test2.weight() <<std::endl;
jacint@173
    44
  if ( prim_test.weight() != prim_test2.weight() ) 
jacint@173
    45
    std::cout<<"Nem egyezik meg!"<<std::endl; 
jacint@173
    46
  else std::cout<<"Megegyezik."<<std::endl; 
jacint@173
    47
jacint@173
    48
  return 0;
jacint@173
    49
}