-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathincremental_topk.h
129 lines (103 loc) · 3.11 KB
/
incremental_topk.h
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// Created by andrea on 20/12/22.
//#
#ifndef INCREMENTAL_TOPK_H
#define INCREMENTAL_TOPK_H
#include <vector>
#include <tuple>
#include <sys/time.h>
#include <stdint.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <queue>
#include <set>
#include <limits>
#include "progressBar.h"
#include "networkit/graph/Graph.hpp"
#include <string>
#include "mytimer.h"
using vertex = uint32_t;
using dist = uint16_t;
using edge_id = uint32_t;
class IncrementalTopK{
struct index_t{
std::vector<std::pair<vertex,dist>> label_offset;
std::vector<std::vector<dist>> d_array;
index_t(){
label_offset.clear();
d_array.clear();
}
~index_t(){
label_offset.clear();
d_array.clear();
}
};
public:
IncrementalTopK(NetworKit::Graph*, dist, bool, dist, bool);
~IncrementalTopK();
void build();
// int query(vertex, vertex, dist, std::vector<dist> &);
void query(vertex, vertex, std::vector<dist> &);
// int query(vertex, vertex, dist);
// int query(vertex, vertex);
vertex x;
vertex y;
void update_loops();
void update_lengths();
uint64_t compute_index_size();
double n_reached_nodes();
double n_reached_nodes_mbfs();
// void mod_bfs(vertex, vertex, std::vector<dist>&);
double loops_time;
double lengths_time;
vertex loop_entries;
vertex length_entries;
vertex aff_hubs;
vertex aff_cycles;
void deallocate_aux();
private:
std::vector<dist> dists;
std::vector<vertex> updated;
std::queue<std::tuple<vertex, vertex, dist, dist, bool, vertex>> new_labels;
std::set<vertex> vertices_to_update;
bool is_from_scratch_only;
std::vector<dist> tmp_v;
void verify_sizes();
void pruned_bfs (vertex, bool);
void reset_temp_vars(vertex, bool);
void set_temp_vars(vertex, bool);
bool prune(vertex, dist, bool);
void compute_loop_entries(vertex);
void resume_pbfs(vertex, vertex, dist, bool);
void allocate_label(vertex, vertex, dist, dist, bool);
void extend_label(vertex, vertex, dist, dist, bool, size_t);
void extend_label_repair(vertex, vertex, dist, dist, bool);
static const dist null_distance;
static const vertex null_vertex;
std::queue<vertex> * node_que;
vertex* ordering;
vertex* reverse_ordering;
std::pair<double,vertex>* ordering_rank;
vertex total;
NetworKit::Graph * graph;
dist K;
bool directed;
dist ordering_type;
std::vector<std::pair<vertex,dist>> old_label_a;
std::vector<std::pair<vertex,dist>> old_label_b;
std::vector<std::vector<dist>> old_distances_a;
std::vector<std::vector<dist>> old_distances_b;
std::vector<vertex> reached_nodes;
std::vector<vertex> reached_mbfs;
std::vector<dist>* loop_labels;
index_t ** length_labels;
bool* tmp_pruned;
dist* tmp_offset;
vertex* tmp_count;
std::vector<dist>* tmp_dist_count;
dist* tmp_s_offset;
std::vector<dist>* tmp_s_count;
dist* visited_in_update_loops;
};
#endif //INCREMENTAL_TOPK_H