jacint@173
|
1 |
#include <iostream>
|
jacint@173
|
2 |
#include <fstream>
|
jacint@173
|
3 |
|
jacint@173
|
4 |
#include <list_graph.hh>
|
jacint@173
|
5 |
#include <dimacs.hh>
|
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@173
|
15 |
typedef ListGraph::NodeIt NodeIt;
|
jacint@173
|
16 |
|
jacint@173
|
17 |
ListGraph G;
|
jacint@173
|
18 |
NodeIt 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@173
|
25 |
Prim<ListGraph, int, FibHeap<ListGraph::NodeIt, 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@173
|
34 |
Prim<ListGraph, int, BinHeap<ListGraph::NodeIt, 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 |
}
|