Skip to content

Conversation

@akshitasure12
Copy link
Contributor

This PR addresses issue #99 by adding a condition to return an empty dictionary {} for empty graphs in the following functions:

  1. betweenness_centrality
  2. edge_betweenness_centrality

I am planning to implement similar checks for other functions as well.
Let me know if I should tweak it any further!

@dschult dschult added the type: Bug fix Something isn't working label Mar 25, 2025
for chunk in node_chunks
)

if not bt_cs:
Copy link
Member

Choose a reason for hiding this comment

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

I think we should probably put this right after we update G. For this one, that is line 43. We avoid extra work by checking len(G) == 0 and returning {} in that case. Thoughts?

@Schefflera-Arboricola Schefflera-Arboricola changed the title Changed the return type to {} for empty graphs Handling empty graph edge-case for betweenness_centrality and edge_betweenness_centrality Mar 25, 2025
@akshitasure12
Copy link
Contributor Author

I'm a bit unsure about how these checks are failing since the only change I made was moving the empty graph check. Could you help me understand if I might be missing something?

Copy link
Member

@Schefflera-Arboricola Schefflera-Arboricola left a comment

Choose a reason for hiding this comment

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

Thanks @akshitasure12 and @dschult !

The failing CI tests are due to the recent changes in PR networkx/networkx#7908 and could be handled in a separate PR. refer Issue #101

@Schefflera-Arboricola Schefflera-Arboricola merged commit 88ee3d2 into networkx:main Mar 26, 2025
2 of 11 checks passed
@Schefflera-Arboricola Schefflera-Arboricola added this to the 0.4 milestone May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Bug fix Something isn't working

Development

Successfully merging this pull request may close these issues.

Ensure nx-parallel's consistency with NetworkX for empty graph handling

3 participants