35 lines
879 B
C
35 lines
879 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include "matrix_operation.h"
|
|
#include "sparse_matrix.h"
|
|
#include "read_from_rb.h"
|
|
#include "power_algorithm.h"
|
|
#include "time_helper.h"
|
|
#include <sys/time.h>
|
|
|
|
void test_pagerank(const char *path) {
|
|
struct timeval tvstart, tv;
|
|
gettimeofday(&tvstart, NULL);
|
|
|
|
SparseMatrix *matrix = read_sparse_matrix_from_mtx(path);
|
|
convert_to_stochastic(matrix);
|
|
// Time 2
|
|
gettimeofday(&tv, NULL);
|
|
print_time_diff("read matrix", &tvstart, &tv);
|
|
double *result = malloc(matrix->num_nodes * sizeof(double));
|
|
if (result == NULL) {
|
|
fprintf(stderr, "Memory allocation failed\n");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
result = pagerank(matrix, 1e-10, 0.35);
|
|
// Time 3
|
|
gettimeofday(&tv, NULL);
|
|
print_time_diff("finish", &tvstart, &tv);
|
|
}
|
|
|
|
int main() {
|
|
test_pagerank("./out/input.rb");
|
|
|
|
return 0;
|
|
}
|