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

wrong normalization in betweenness_centrality(endpoints=True) #2709

Closed
leonardomaccari opened this issue Oct 13, 2017 · 4 comments
Closed

wrong normalization in betweenness_centrality(endpoints=True) #2709

leonardomaccari opened this issue Oct 13, 2017 · 4 comments

Comments

@leonardomaccari
Copy link

leonardomaccari commented Oct 13, 2017

I would expect that the normalized centrality should be in the [0,1] range, but when including the endpoints this does not happen.

g = nx.star_graph(2)
nx.betweenness_centrality(g)
{0: 1.0, 1: 0.0, 2: 0.0}
nx.betweenness_centrality(g, endpoints=True)
{0: 3.0, 1: 2.0, 2: 2.0}

The documentation (and code) says that the normalization multiplies by 2/((n-1)(n-2)). I spent some time to understand this number, and i tracked down the following:

In the original paper from Freeman (A set of measures of centrality based on betweenness, pag 38) he introduces a normalization by dividing per (n(n-1)*1/2)-(n-1) where:
n(n-1)*1/2 : number of shortest paths in the undirected graph
(n-1) : number of shortest paths ending/beginning in the node for which we compute centrality

this leads to division by (n*n - 3n + 2)*1/2 == (n-1)(n-2)*1/2 but, this implicitly removes the node we compute centrality on from the enpoints, as Freeman says. When centrality is computed with the endpoints, this term should be removed, and normalization should be applied simply with the potential number of paths: n(n-1)*1/2

In general, normalization could be done with whatever constant, but:

So I suggest normalization is changed when betweenness is computed including the endpoints.

@hagberg
Copy link
Member

hagberg commented Nov 23, 2017

Thanks for tracking this down. I agree with you that it is reasonable to normalize by the potential number of paths. This should be a pretty easy fix.

@manoelhortaribeiro
Copy link

Can I give it a try?

@hagberg
Copy link
Member

hagberg commented Dec 10, 2017

Yes, go for it.

@bakerwho
Copy link
Contributor

I'm interested in contributing and this does seem like it might have a simple fix. However, it looks @regstrtn has already tried a fix that has failed the Travis CI build. Any way I can help?

@dschult dschult added this to the networkx-2.2 milestone Feb 18, 2018
@dschult dschult removed the Needs PR label May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants