1
votes

Hi I'm trying to get the centrality score from NetworkX. However, in the latest update i.e. NetworkX 2.1, the function looks like this:

nx.loseness_centrality(G, u=None, distance=None, wf_improved=True, reverse=False)

However, in NetworkX 1.9, the function had a normalize=False function:

nx.closeness_centrality(G, u=None, distance=None, normalized=True)

The documentation says that:

"The closeness centrality is normalized to (n-1)/(|G|-1) where n is the number of nodes in the connected part of graph containing the node. If the graph is not completely connected, this algorithm computes the closeness centrality for each connected part separately scaled by that parts size."

How do I un-normalize the centrality scores? Thanks!

1
do you want to un-normalize just one node, or all nodes? (the fastest approach if you just want one node is not the fastes if you want to do all nodes). - Joel
Thanks! I wanted to do it for all the nodes! - Dawei Wang

1 Answers

2
votes

The old "normalization" was not well named (see discussion) and was updated in version 2.0; the equivalent flag is wf_improved. In both the old and new versions the "normalize" only makes a difference in graphs with >1 component, as explained in the documentation note you quoted.

# 2.1
nx.closeness_centrality(G, u=None, distance=None, wf_improved=False, reverse=False)

does the same as

# 1.9
nx.closeness_centrality(G, u=None, distance=None, normalized=False)