-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.cpp
More file actions
60 lines (47 loc) · 1.4 KB
/
graph.cpp
File metadata and controls
60 lines (47 loc) · 1.4 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "graph.hpp"
using namespace std;
Graph::Graph(char *input_file, bool is_DG){
this->is_DG = is_DG;
if(is_DG){
read_data_graph(input_file);
}else{
read_schema_graph(input_file);
}
}
// -----------------------------
// Read Data Graph
// -----------------------------
void
Graph::read_data_graph(char *input_file){
ifstream finput;
finput.open(input_file, fstream::in | fstream::binary);
finput.read((char *)(&num_nodes), 4);
finput.read((char *)(&num_edges), 4);
nodes.resize(num_nodes);
edges.resize(num_edges);
weights.resize(num_edges);
finput.read((char *)(&nodes[0]), num_nodes*4);
finput.read((char *)(&edges[0]), num_edges*4);
finput.read((char *)(&weights[0]), num_edges*4);
finput.close();
}
// -----------------------------
// Read Schema Graph
// -----------------------------
void
Graph::read_schema_graph(char *input_file){
ifstream finput;
finput.open(input_file, fstream::in | fstream::binary);
finput.read((char *)(&num_nodes), 4);
finput.read((char *)(&num_edges), 4);
finput.read((char *)(&num_d_nodes), 4);
nodes.resize(num_nodes);
edges.resize(num_edges);
weights.resize(num_edges);
d2s.resize(num_d_nodes);
finput.read((char *)(&nodes[0]), num_nodes*4);
finput.read((char *)(&edges[0]), num_edges*4);
finput.read((char *)(&weights[0]), num_edges*4);
finput.read((char *)(&d2s[0]), num_d_nodes*4);
finput.close();
}