Skip to content

BUG: group betweenness gives incorrect values for undirected connected graph - #8879

Merged
rossbar merged 3 commits into
networkx:mainfrom
dschult:group_btwn_sigma_typo
Aug 29, 2026
Merged

rossbar merged 3 commits into
networkx:mainfrom
dschult:group_btwn_sigma_typo

Conversation

@dschult

@dschult dschult commented Aug 29, 2026 •

Copy link
Copy Markdown
Member

This splits off the simplest bug reported in #8666 and #8559 and fixes it. Related discussion in #8827.
I'm hoping splitting these up makes review simple.

The bug is that sigma is used instead of sigma_m in two places where the symmetry of the formulas makes it clear that it should have been sigma_m. This corrects an easily checked test where no shortest paths between non-group nodes pass through the group. So GBC==0. It was giving 0.125.

I also added a test that checks many groups at once and compares singleton groups with the BC values from betweenness_centrality to ensure they are the same. That test passes before or after this fix, but I found it helpful to see that symmetry so I included it in this PR.

Upcoming PRs: (todo list)

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @dschult - splitting these out does indeed make this easier to review & digest. This particular fix is very straightforward and has been extensively discussed; in it goes! Thanks again for the research and breaking down the problem - looking forward to the next steps!

@rossbar
rossbar merged commit 73cb92b into networkx:main Aug 29, 2026
43 checks passed
@dschult dschult added this to the 3.7 milestone Aug 29, 2026
@dschult
dschult deleted the group_btwn_sigma_typo branch August 30, 2026 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants