Skip to content

feat: implementation for group_degree_centrality, group_closeness_centrality, and group_betweenness_centrality#1565

Open
selmanozleyen wants to merge 7 commits intoQiskit:mainfrom
selmanozleyen:feat/group-centrality-wip
Open

feat: implementation for group_degree_centrality, group_closeness_centrality, and group_betweenness_centrality#1565
selmanozleyen wants to merge 7 commits intoQiskit:mainfrom
selmanozleyen:feat/group-centrality-wip

Conversation

@selmanozleyen
Copy link

@selmanozleyen selmanozleyen commented Mar 12, 2026

hi I added these three functions because I'd like to use them in squidpy instead of pure python version.

  • Add group_degree_centrality, group_closeness_centrality, and
    group_betweenness_centrality for both digraph and graph

Note

While writing cross-validation tests against NetworkX, I discovered that
NetworkX's group_betweenness_centrality is buggy on directed graphs that
are not strongly connected (returns negative values, crashes with KeyError).
Filed upstream: networkx/networkx#8559.
The NX comparison tests here only use strongly-connected directed graphs to
avoid this.

@CLAassistant
Copy link

CLAassistant commented Mar 12, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@selmanozleyen selmanozleyen changed the title Feat/group centrality wip feat: implementation for group_degree_centrality, group_closeness_centrality, and group_betweenness_centrality Mar 12, 2026
@selmanozleyen selmanozleyen marked this pull request as ready for review March 12, 2026 02:32
@selmanozleyen selmanozleyen marked this pull request as draft March 12, 2026 02:32
@selmanozleyen selmanozleyen marked this pull request as ready for review March 12, 2026 11:20
@IvanIsCoding
Copy link
Collaborator

Some preliminary thoughts:

  1. Fix clippy lints, naturally
  2. I'd decouple the tests from NetworkX. If you can just put the expected centrality in a dictionary that is fine. Naturally, document it with #obtained with: g_nx = nx.cycle_graph(6, create_using=nx.DiGraph) etc. so we can reproduce the numbers

Using NetworkX as a ground source of truth is a great idea. But it's also nice not to be affected by their API changes. We had to do that for other centrality methods.

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