Skip to content

Commit b052dd4

Browse files
authored
fix(analytical): Fix Louvain algorithm's stop condition (#4387)
<!-- Thanks for your contribution! please review https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before opening an issue. --> ## What do these changes do? <!-- Please give a short brief about these changes. --> When using Louvain algorithm, I found a question with its stop condition, the Louvain algotithm's quality may be 0, 0.85, 0.80, I want to stop the iterations at 0.80 as the quality has started to decrease, but the current stop condition can't do that. Besides, the change is consistent with [NetworkX's implementation](https://github.com/networkx/networkx/blob/c34400f1ea5b9daa733b971f7f5ef7072fe410a9/networkx/algorithms/community/louvain.py#L216) ## Related issue number <!-- Are there any issues opened that will be resolved by merging this change? --> Fixes
1 parent f8250fb commit b052dd4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

analytical_engine/apps/pregel/louvain/louvain_app_base.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ class LouvainAppBase
226226
// after one pass if already decided halt, that means the pass yield no
227227
// changes, so we halt computation.
228228
if (current_super_step <= 14 ||
229-
std::fabs(actual_quality - ctx.prev_quality()) <
230-
min_quality_improvement) {
229+
(actual_quality - ctx.prev_quality()) <= min_quality_improvement) {
231230
// turn to sync community result
232231
ctx.compute_context().set_superstep(sync_result_step);
233232
syncCommunity(frag, ctx, messages);

0 commit comments

Comments
 (0)