-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_perf.cpp
More file actions
42 lines (37 loc) · 1.37 KB
/
main_perf.cpp
File metadata and controls
42 lines (37 loc) · 1.37 KB
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
#include <iostream>
#include <string>
#include <vector>
#include "utility.h"
#include "graph/graph.h"
#include "graph/graph_by_row.h"
int main(int argc, char *argv[]) {
if (argc < 4) {
std::cerr << "Usage: " << argv[0] << " <filename> <graph_type (a or b)> <algorithm_type (p or s)>" << std::endl;
return 1;
}
std::string filename(argv[1]);
std::cout << "File: " << filename << std::endl;
std::cout << "Parsing file..." << std::endl;
std::vector<std::pair<unsigned int, unsigned int>> edges = utility::parse_edges_from_file_and_normalize(filename);
unsigned int n = 0;
for (auto &edge: edges) {
n = std::max(n, std::max(edge.first, edge.second));
}
n++;
std::cout << "File parsed!" << std::endl << std::endl;
if (argv[2][0] == 'a') {
graph g(n, edges);
if (argv[3][0] == 'p') {
g.par_page_rank(std::vector<float>(n, static_cast<float>(1) / n), 0.85, 50, 1e-7, -1);
} else {
g.seq_page_rank(std::vector<float>(n, static_cast<float>(1) / n), 0.85, 50, 1e-7);
}
} else {
graph_by_row gbr(n, edges);
if (argv[3][0] == 'p') {
gbr.par_page_rank(std::vector<float>(n, static_cast<float>(1) / n), 0.85, 50, 1e-7, -1);
} else {
gbr.seq_page_rank(std::vector<float>(n, static_cast<float>(1) / n), 0.85, 50, 1e-7);
}
}
}