Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimized Community Detection using Binary Search #1857

Conversation

arpanbiswas97
Copy link

@arpanbiswas97 arpanbiswas97 commented Mar 6, 2023

For finding the new cluster, we are currently doing a linear search to find all the elements greater than threshold

for idx, val in zip(top_idx_large.tolist(), top_val_large):

Since the array is sorted, I am using binary search here to find the last element which is greater than the threshold. This is causing a noticeable improvement in performance in some cases. Thanks to @arunpurohit3799 for the help.

- applied binary search  to get the new cluster
@tomaarsen
Copy link
Collaborator

Hello!

Thanks for proposing this PR! It showed me that there is interest/benefit in trying to improve the community detection. I realised that sorting is not even necessary, because we can use torch slicing to quickly get the "cutoff". I've implemented this in #2381. According to my tests, the fix in that PR is slightly faster than the one in this PR, so I will be closing this PR.

Semi-related, I also improved the performance heavily if you're using GPUs to compute the communities.

  • Tom Aarsen

@tomaarsen tomaarsen closed this Dec 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants