From 290b443e8486f95e393eb95608d97916536cd055 Mon Sep 17 00:00:00 2001 From: Chuck Hastings <45364586+ChuckHastings@users.noreply.github.com> Date: Mon, 29 Apr 2024 11:49:23 -0400 Subject: [PATCH] Fix bad Leiden result (#4376) Once the termination criteria is met, the last level of the dendrogram contains a partitioning that reduces the overall modularity. This update overwrites the final dendrogram level with a k to k mapping. This bug had a consequence of the numbering of the flattened Leiden partitions being non-consecutive integers. This should now be resolved. Closes #4368 Authors: - Chuck Hastings (https://github.com/ChuckHastings) Approvers: - Seunghwa Kang (https://github.com/seunghwak) URL: https://github.com/rapidsai/cugraph/pull/4376 --- cpp/src/community/leiden_impl.cuh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cpp/src/community/leiden_impl.cuh b/cpp/src/community/leiden_impl.cuh index c07f9f6ffba..c1b8fe1d7d3 100644 --- a/cpp/src/community/leiden_impl.cuh +++ b/cpp/src/community/leiden_impl.cuh @@ -561,6 +561,13 @@ std::pair>, weight_t> leiden( louvain_of_refined_graph.size(), false); } + } else { + // Reset dendrogram. + // FIXME: Revisit how dendrogram is populated + detail::sequence_fill(handle.get_stream(), + dendrogram->current_level_begin(), + dendrogram->current_level_size(), + current_graph_view.local_vertex_partition_range_first()); } copied_louvain_partition.resize(0, handle.get_stream());