-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
121 lines (92 loc) · 3.14 KB
/
test.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include "FibonacciHeap.h"
#include "graphs.hpp"
#include <algorithm>
#include <iostream>
#include <vector>
#include <unistd.h>
#include <sys/resource.h>
#include <ctime>
#include <limits.h>
// long get_memory_usage_kb() {
// struct rusage usage;
// getrusage(RUSAGE_SELF, &usage);
// return usage.ru_maxrss; // bytes
// }
// int main(){
// long baseline = get_memory_usage_kb();
// cout << "Baseline: " << baseline << " KB" << endl;
// Graph a = Graph("studie-cases/grafo_6.txt", "vector");
// std::cout << "Memory usage: " << get_memory_usage_kb() - baseline << " KB" << std::endl;
// }
// int main(){
// // average bfs and dfs time, running 100 BFS with random vertices
// Graph a = Graph("studie-cases/grafo_6.txt", "vector");
// int random_vertex = (rand() % a.n) + 1;
// double elapsed_time = 0;
// for(int i = 0; i < 10; i++){
// clock_t start = clock();
// a.dfs(random_vertex);
// clock_t end = clock();
// elapsed_time += double(end - start) / CLOCKS_PER_SEC;
// }
// elapsed_time /= 10;
// cout << elapsed_time << endl;
// }
// int main(){
// // Determine o pai dos veertices 10, 20, 30 na arvore geradora
// // induzida pela BFS e pela DFSquando iniciamos a busca nos
// // veertices 1, 2, 3.
// Graph a = Graph("studie-cases/grafo_5.txt", "vector");
// a.dfs(1);
// a.bfs(1);
// a.dfs(2);
// a.bfs(2);
// a.dfs(3);
// a.bfs(3);
// }
// int main(){
// // Determine a distancia entre os seguintes pares de veertices
// // (10,20), (10,30), (20,30).
// Graph a = Graph("studie-cases/grafo_6.txt", "vector");
// cout << a.distance(10, 20) << endl;
// cout << a.distance(10, 30) << endl;
// cout << a.distance(20, 30) << endl;
// }
// int main(){
// //Obtenha as componentes conexas do grafo. Quantas componentes conexas tem o grafo? Qual
// //´e o tamanho da maior e da menor componente conexa?
// Graph a = Graph("studie-cases/grafo_6.txt", "vector");
// a.connected_components();
// }
// int main(){
// Graph a = Graph("studie-cases/grafo_6.txt", "vector");
// cout << a.diameter() << endl;
// }
// int main(){
// double elapsed_time = 0;
// clock_t start = clock();
// Graph a = Graph("studie-cases/grafo_W_2.txt", "vector", 1);
// clock_t mid = clock();
// elapsed_time += double(mid - start) / CLOCKS_PER_SEC;
// cout << elapsed_time << endl;
// auto b = a.vectorDijsktra(10);
// clock_t end = clock();
// elapsed_time = 0;
// elapsed_time += double(end - mid) / CLOCKS_PER_SEC;
// cout << elapsed_time << endl;
// }
int main(){
//direcionado ou nao
//em arquivo ou nao e mostrando o fluxo
double elapsed_time = 0;
clock_t start = clock();
Graph a = Graph("studie-cases/trab3/grafo_rf_1.txt", "vector", 1);
clock_t mid = clock();
elapsed_time += double(mid - start) / CLOCKS_PER_SEC;
cout << elapsed_time << endl;
cout << a.ford_fulkerson(1, 2) << endl;
clock_t end = clock();
elapsed_time = 0;
elapsed_time += double(end - mid) / CLOCKS_PER_SEC;
cout << elapsed_time << endl;
}