-
Notifications
You must be signed in to change notification settings - Fork 2
/
queryGraph.cuh
78 lines (78 loc) · 1.8 KB
/
queryGraph.cuh
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include<iostream>
#include<stdlib.h>
#include<vector>
#include "utils.h"
#include<fstream>
#include<string.h>
using namespace std;
class queryGraph{
public:
uint32_t vertex_num;
vector<uint8_t> vertex_label;
vector<vector<uint32_t>> adj_list;
vector<vector<uint32_t>> order_list;
vector<uint32_t> core;
vector<uint32_t> satellite;
void readFromFile(const char filename []) {
std::ifstream file_read;
file_read.open(filename, std::ios::in);
file_read >> vertex_num;
//cout << vertex_num << endl;
for (uint32_t i = 0; i < vertex_num; i ++) {
uint32_t label_now;
file_read >> label_now;
//cout << label_now << " ";
vertex_label.push_back((uint8_t)label_now);
}
//cout << endl;
for (uint32_t i = 0; i < vertex_num; i ++) {
vector<uint32_t> v;
uint32_t nbr_size;
file_read >> nbr_size;
//cout << nbr_size << " ";
uint32_t nbr_now;
for (uint32_t j = 0; j < nbr_size; j ++) {
file_read >> nbr_now;
//cout << nbr_now << " ";
v.push_back(nbr_now);
}
adj_list.push_back(v);
//cout << endl;
}
for (uint32_t i = 0; i < vertex_num; i ++) {
vector<uint32_t> v;
uint32_t nbr_size;
file_read >> nbr_size;
//cout << nbr_size << " ";
uint32_t order_nbr_now;
for (uint32_t j = 0; j < nbr_size; j ++) {
file_read >> order_nbr_now;
//cout << order_nbr_now << " ";
v.push_back(order_nbr_now);
}
order_list.push_back(v);
//cout << endl;
}
file_read.close();
for (uint32_t i = 0; i < vertex_num; i ++) {
if (adj_list[i].size() > 1) {
core.push_back(i);
}
else {
satellite.push_back(i);
}
}
return ;
}
void clear() {
for (uint32_t i = 0; i < vertex_num; i ++) {
adj_list[i].clear();
order_list[i].clear();
}
adj_list.clear();
order_list.clear();
core.clear();
satellite.clear();
return ;
}
};