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

Add Katz Centrality #797

Merged
merged 21 commits into from
Jun 1, 2023
Merged

Add Katz Centrality #797

merged 21 commits into from
Jun 1, 2023

Conversation

IvanIsCoding
Copy link
Collaborator

Related to #441

Add the Katz centrality to both rustworkx and rustworkx-core. I mostly forked the code from eigenvector_centrality and made the adaptations

@coveralls
Copy link

coveralls commented Jan 31, 2023

Pull Request Test Coverage Report for Build 5139295387

  • 189 of 206 (91.75%) changed or added relevant lines in 3 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.08%) to 96.506%

Changes Missing Coverage Covered Lines Changed/Added Lines %
rustworkx-core/src/centrality.rs 55 62 88.71%
src/centrality.rs 132 142 92.96%
Files with Coverage Reduction New Missed Lines %
src/shortest_path/all_pairs_bellman_ford.rs 1 98.88%
src/shortest_path/all_pairs_dijkstra.rs 1 98.54%
Totals Coverage Status
Change from base Build 5138032148: -0.08%
Covered Lines: 15079
Relevant Lines: 15625

💛 - Coveralls

@mtreinish mtreinish self-assigned this Feb 4, 2023
@mtreinish mtreinish added this to the 0.13.0 milestone May 10, 2023
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 LGTM, it's a simple modification to the eigenvector centrality to compute the katz centrality. Just a couple comments inline.

src/centrality.rs Outdated Show resolved Hide resolved
src/centrality.rs Outdated Show resolved Hide resolved
rustworkx-core/src/centrality.rs Show resolved Hide resolved
for node_index in graph.node_identifiers() {
let node = graph.to_index(node_index);
if !beta.contains_key(&node) {
return Ok(None); // beta_map was provided but did not include all nodes
Copy link
Member

Choose a reason for hiding this comment

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

Should this be an error instead of None? It feels like a user error if they pass in a mapping that's incomplete here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

None means it’s not defined… it map to an error in Python but in Rust we let the caller handle it

rustworkx-core/src/centrality.rs Outdated Show resolved Hide resolved
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.

LGTM, thanks for making the updates

@mtreinish mtreinish merged commit 2482563 into Qiskit:main Jun 1, 2023
@IvanIsCoding IvanIsCoding deleted the katz-centrality branch June 1, 2023 12:19
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