-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.cpp
108 lines (89 loc) · 2.64 KB
/
main.cpp
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
#include <KReach.h>
#include <DynamicKReach.h>
#include <ScalableKReach.h>
#include <DynamicScalableKReach.h>
#include <iostream>
#include <memory>
using namespace std;
void
equals(const Graph &graph, const AbstractKReach &lhs, const AbstractKReach &rhs) {
for (degree_t s = 0; s < graph.num_vertices(); ++s) {
for (degree_t t = 0; t < graph.num_vertices(); ++t) {
if (lhs.query(s, t) != rhs.query(s, t)) {
cout << "ERROR " << s << " " << t << " " << lhs.query(s, t) << " " << rhs.query(s, t)
<< endl;
}
}
}
}
int main() {
Graph graph;
graph.from_kreach("data/sample.kreach");
graph.compute_degree();
unique_ptr<AbstractKReach> indexes[4];
indexes[0].reset(new KReach(graph, 3));
indexes[1].reset(new DynamicKReach(graph, 3));
indexes[2].reset(new ScalableKReach(graph, 3, 1000, 10000));
indexes[3].reset(new DynamicScalableKReach(graph, 3, 1000, 10000));
for (auto &i : indexes){
i->construct();
}
vector<pair<vertex_t, vertex_t>> edges;
for (vertex_t s = 0; s < graph.num_vertices(); ++s) {
for (vertex_t t : graph.successors(s)) {
edges.push_back(make_pair(s, t));
}
}
/*
* Edge operations
*/
for (const auto &p : edges) {
auto s = p.first;
auto t = p.second;
cout << s << " " << t << endl;
graph.remove_edge(s, t);
for (auto &i : indexes){
i->remove_edge(s, t);
}
for (const auto &i : indexes){
for (const auto &j : indexes){
equals(graph, *i, *j);
}
}
graph.insert_edge(s, t);
for (auto &i : indexes){
i->insert_edge(s, t);
}
for (const auto &i : indexes){
for (const auto &j : indexes){
equals(graph, *i, *j);
}
}
}
/*
* Vertex operations
*/
for (vertex_t s = 0; s < graph.num_vertices(); ++s){
cout << s << endl;
auto out = move(graph.successors(s)), in = move(graph.predecessors(s));
graph.remove_vertex(s);
for (auto &i : indexes){
i->remove_vertex(s, out, in);
}
for (const auto &i : indexes){
for (const auto &j : indexes){
equals(graph, *i, *j);
}
}
graph.insert_vertex(s, out, in);
for (auto &i : indexes){
i->insert_vertex(s, out, in);
}
for (const auto &i : indexes){
for (const auto &j : indexes){
equals(graph, *i, *j);
}
}
}
return 0;
}