Skip to content

Conversation

IvanIsCoding
Copy link
Collaborator

This PR makes closeness_centrality and newman_weighted_closeness_centrality parallel for better performance. This is possible because the task is embarrassingly parallel.

We probably missed this in #593 but #1385 reminded me of it.

The parallelism is toggled via the parallel_threshold just like other centrality methods.

@coveralls
Copy link

coveralls commented Feb 28, 2025

Pull Request Test Coverage Report for Build 14346065276

Details

  • 89 of 89 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.5%) to 95.84%

Totals Coverage Status
Change from base Build 14345039299: 0.5%
Covered Lines: 18637
Relevant Lines: 19446

💛 - Coveralls

@IvanIsCoding
Copy link
Collaborator Author

Because #1387, I added a test to boost the coverage in the report. I am confident the Rust tests guarantee the correctness so for now that is a stop gap

@IvanIsCoding IvanIsCoding added this to the 0.17.0 milestone Mar 1, 2025
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM, it makes a lot of sense to run this with rayon. Thanks for doing this. I just left a couple of comments inline the main one is I think we can do this without a mutex using a rayon iterator collection into the vec which should be faster..

@IvanIsCoding IvanIsCoding requested a review from mtreinish March 19, 2025 12:52
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks much better to me now, thanks for making the change. I just had a couple of small inline comments about the release notes and the docstring updates. But code-wise I think this is good to go.

@IvanIsCoding IvanIsCoding requested a review from mtreinish April 8, 2025 03:39
Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks fine now, besides the lint failure. The RAYON_NUM_THREADS doesn't look like it's in the Python docs though, we normally document it there too because it's an env variable and works from python too.

@IvanIsCoding
Copy link
Collaborator Author

Let me update the Python docs and fix the formatting

@IvanIsCoding IvanIsCoding requested a review from mtreinish April 8, 2025 22:20
@mtreinish mtreinish added this pull request to the merge queue Apr 9, 2025
Merged via the queue into Qiskit:main with commit 08c21ec Apr 9, 2025
31 checks passed
@IvanIsCoding IvanIsCoding deleted the parallel-centrality branch May 17, 2025 17:59
SILIZ4 pushed a commit to SILIZ4/rustworkx that referenced this pull request Jul 4, 2025
* First look at parallel implementation

* Add parallel threshold parameter

* Add parllel_threshold to Python arguments

* Make weighted closeness centrality also parallel

* Add new argument to type stubs

* Document parameters for newman's type specific functions

* Add parallel tests to Python

* Add release notes for the change

* Boost coverage of Newman Weighted Centrality via unweighted test case

* Simplify implementation with .collect()

* Add parallel_threshold to docstring

* Fix cargo clippy warnings

* Document RAYON_NUM_THREADS

* Move reno section to upgrade

* Add rayon num threads detail to Python

* Update Python docstring as well

* Try to fix indentation
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.

3 participants