-
Notifications
You must be signed in to change notification settings - Fork 2
/
DynDSAlgAddRem.h
92 lines (69 loc) · 1.93 KB
/
DynDSAlgAddRem.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
/*
* DynDSAlgAddRem.h
*
* Created on: Oct 21, 2014
* Author: aepasto
*/
#ifndef DYNDSALGADDREM_H_
#define DYNDSALGADDREM_H_
#include "DynGraph.h"
#include "UDynGraph.h"
#include "DSAlgs.h"
#include "DynGraphUtils.h"
#include <unordered_set>
#include <iostream>
using namespace std;
// Class implementing the dynamic densest subgraph
class DynDSAddRem {
public:
const double EPS_ERR;
explicit DynDSAddRem(const double epsilon);
virtual ~DynDSAddRem();
bool add_edge(const int u, const int v);
bool remove_edge(const int u, const int v);
inline double beta() const {
return beta_;
}
inline double density_subgraph() const {
double dens =
0.0 ? densest_subgraph_set_.empty() : static_cast<double>(edges_in_densest_subgraph_)
/ static_cast<double>(densest_subgraph_set_.size());
if (!(edges_in_densest_subgraph_ > 0 || graph_.num_edges() == 0)) {
cerr << "|E(S)| =" << edges_in_densest_subgraph_ << endl;
cerr << "|S| =" << densest_subgraph_set_.size() << endl;
cerr << "|E| =" << graph_.num_edges() << endl;
cerr.flush();
assert(false);
}
assert(dens > 0 || graph_.num_edges() == 0);
return dens;
}
inline int max_in_degree_upperbound() const {
return orientation_.max_in_deg_upperbound();
}
inline const unordered_set<int>& densest_subgraph() const {
return densest_subgraph_set_;
}
inline long num_edges() const {
return graph_.num_edges();
}
inline unsigned int size_densest() const {
return densest_subgraph_set_.size();
}
private:
void Construct(bool use_add_only_graph);
void Check(int node);
void valide_upperbound();
DynGraph orientation_;
UDynGraph graph_;
//UDynGraph graph_only_add_; //TODO NOT USED
double epsilon_original_;
double epsilon_;
unordered_set<int> densest_subgraph_set_;
double beta_;
unordered_map<int, int> level_map_;
int removals_last_;
int threshold_removals_;
unsigned long long edges_in_densest_subgraph_;
};
#endif /* DYNDSALGADDREM_H_ */