-
Notifications
You must be signed in to change notification settings - Fork 8
/
new
59 lines (45 loc) · 1.63 KB
/
new
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
//Graph format:
//Simplified json format:
//src degree dest0 dest1 ...
//#include "graph.h"
#include "comm.h"
#include <fstream>
#include <omp.h>
#define FILE_NOT_EXIST 1
#define FILE_EXIST 0
using namespace std;
graph::graph(
string jsonfile)//,
{
cout<<"read from folder "<<jsonfile<<endl;
string s_begin = jsonfile+"/begin.bin";
string s_adj = jsonfile+"/adjacent.bin";
string s_head = jsonfile+"/head.bin";
string s_degree = jsonfile+"/degree.bin";
char* begin_file = const_cast<char*>(s_begin.c_str());
char* adj_file = const_cast<char*>(s_adj.c_str());
char* head_file = const_cast<char*>(s_head.c_str());
char* degree_file = const_cast<char*>(s_degree.c_str());
vert_count = fsize(begin_file)/sizeof(index_t) - 1;
edge_count = fsize(head_file)/sizeof(vertex_t);
cout<<"vert:"<< vert_count<<" edge: "<<edge_count<<endl;
FILE *pFile= fopen(adj_file,"rb");
adj_list = (vertex_t *)malloc(fsize(adj_file));
fread(adj_list,sizeof(vertex_t),edge_count,pFile);
fclose(pFile);
FILE *pFile1= fopen(head_file,"rb");
head_list = (vertex_t *)malloc(fsize(head_file));
fread(head_list,sizeof(vertex_t),edge_count,pFile1);
fclose(pFile1);
// FILE *pFile2= fopen(degree_file,"rb");
// adj_card = (index_t *)malloc(fsize(degree_file));
// fread(adj_card,sizeof(index_t),vert_count,pFile2);
// fclose(pFile2);
FILE *pFile3 = fopen(begin_file,"rb");
beg_pos = (index_t *)malloc(fsize(begin_file));
fread(beg_pos,sizeof(index_t),vert_count+1,pFile3);
fclose(pFile3);
count = (index_t *)malloc(256*256*sizeof(index_t));
// valid = (int *)malloc(vert_count*sizeof(int));
}
// H_ERR(cudaMalloc(&src_degree, vert_count*sizeof(index_t)) );