34 initial_threshold_ = initial_threshold;
35 thresholds_.reserve(kMaxVerticesNum);
37 thresholds_table_.resize(kMaxThresholdsNum);
38 thresholds_table_[0] = std::numeric_limits<float>::max();
39 for (
size_t i = 1; i < kMaxThresholdsNum; ++i) {
40 thresholds_table_[i] = GetThreshold(i, initial_threshold_);
45 Edge* edges,
bool need_sort) {
46 if (edges ==
nullptr) {
47 AERROR <<
"Input Null Edges.";
52 std::sort(edges, edges + num_edges);
55 universe_.
Reset(num_vertices);
57 thresholds_.assign(num_vertices, initial_threshold_);
58 for (
int i = 0; i < num_edges; ++i) {
59 Edge& edge = edges[i];
60 int a = universe_.
Find(edge.
a);
61 int b = universe_.
Find(edge.
b);
65 if (edge.
w <= thresholds_[a] && edge.
w <= thresholds_[b]) {
67 a = universe_.
Find(a);
68 int size_a = universe_.
GetSize(a);
70 edge.
w + (size_a < static_cast<int>(kMaxThresholdsNum)
71 ? thresholds_table_[size_a]
72 : GetThreshold(size_a, initial_threshold_));