-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cxx
37 lines (28 loc) · 1.02 KB
/
main.cxx
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
#include <vector>
#include <string>
#include <cstdio>
#include <iostream>
#include "src/main.hxx"
using namespace std;
template <class G, class H>
void runPagerank(G& x, H& xt, int repeat) {
vector<float> *init = nullptr;
// Find pagerank by pushing contribution to out-vertices.
auto a1 = pagerankPush(x, init, {repeat});
auto e1 = absError(a1.ranks, a1.ranks);
printf("[%09.3f ms; %03d iters.] [%.4e err.] pagerankPush\n", a1.time, a1.iterations, e1);
// Find pagerank by pulling contribution from in-vertices.
auto a2 = pagerankPull(xt, init, {repeat});
auto e2 = absError(a2.ranks, a1.ranks);
printf("[%09.3f ms; %03d iters.] [%.4e err.] pagerankPull\n", a2.time, a2.iterations, e2);
}
int main(int argc, char **argv) {
char *file = argv[1];
int repeat = argc>2? stoi(argv[2]) : 5;
printf("Loading graph %s ...\n", file);
auto x = readMtx(file); println(x);
auto xt = transposeWithDegree(x); print(xt); printf(" (transposeWithDegree)\n");
runPagerank(x, xt, repeat);
printf("\n");
return 0;
}