Fix bug of label_propagation (#302)

Fix bug of issue #297
This commit is contained in:
FuJiaJie123 2025-04-18 03:22:24 +08:00 committed by GitHub
parent f66893fe2f
commit 9ca7ff6cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -101,9 +101,13 @@ def label_propagation(projection: dict[str, list[Neighbor]]) -> list[list[str]]:
]
community_lst.sort(reverse=True)
community_candidate = community_lst[0][1] if len(community_lst) > 0 else -1
new_community = max(community_candidate, curr_community)
candidate_rank, community_candidate = (
community_lst[0] if community_lst else (0, -1)
)
if community_candidate != -1 and candidate_rank > 1:
new_community = community_candidate
else:
new_community = max(community_candidate, curr_community)
new_community_map[uuid] = new_community