-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcluster_vertex.hpp
70 lines (52 loc) · 1.36 KB
/
cluster_vertex.hpp
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
#pragma once
#include "types.hpp"
#include "require.hpp"
class ClusterVertex {
public:
ClusterVertex(): m_center(0), m_is_center(false), m_probability(-100.0) {};
bool is_covered() const {
return m_probability >= 0.0;
}
ugraph_vertex_t center() const {
REQUIRE(is_covered(), "The node is uncovered");
return m_center;
}
bool is_center() const {
return m_is_center;
}
probability_t probability() const {
REQUIRE(is_covered(), "The node is uncovered");
return m_probability;
}
probability_t unreliable_probability() const {
REQUIRE(!is_covered(), "The node is covered, its probability is reliable");
if (m_probability < -1.0) {
return 0.0;
} else {
return -m_probability;
}
}
void make_center(ugraph_vertex_t id) {
REQUIRE(!is_covered(), "The node is already covered");
m_center = id;
m_is_center = true;
m_probability = 1.0;
}
void force_make_center(ugraph_vertex_t id) {
m_center = id;
m_is_center = true;
m_probability = 1.0;
}
void cover(ugraph_vertex_t center, probability_t prob) {
m_center = center;
m_probability = prob;
}
void unreliable_cover(ugraph_vertex_t center, probability_t prob) {
m_center = center;
m_probability = -prob;
}
private:
ugraph_vertex_t m_center;
bool m_is_center;
probability_t m_probability;
};