Repository navigation
Optimise harmonic centrality - #8158
Merged
Merged
Conversation
amcandio
approved these changes
Jul 20, 2025
Contributor
|
I see some variance on the measurements of asv. You should probably retry your profiling making sure your computer is not overloaded with other tasks |
amcandio
approved these changes
Jul 21, 2025
rossbar
approved these changes
Jul 21, 2025
rossbar
left a comment
Contributor
There was a problem hiding this comment.
LGTM - I see no appreciable difference in performance but see no problem with the proposal either!
I'd propose to leave the comment, as it's useful IMO to remind readers that the condition can come about in multiple different ways (0-weight edges or self-loops). Thanks @akshitasure12 !
Co-authored-by: Ross Barnowski <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the current implementation of harmonic centrality, we compute
nbunch.intersection(dist)for every source node. This creates a temporary set at each iteration, which is unnecessary and slightly inefficient since we can achieve the same logic with a conditional check during iteration overdist.items().What I changed
I replaced:
with:
Benchmarking results
I ran the following benchmark command to compare performance:
[EDIT]:
The most notable performance improvement is observed for
wheel_graph(100)but other benchmarks also show modest improvements.