Introduction to Network Analysis in Python
Eric Ma
Data Carpentry instructor and author of nxviz package
$$\frac{\text{num. shortest paths through node}}{\text{all possible shortest paths}}$$
import networkx as nx G = nx.barbell_graph(m1=5, m2=1)
nx.betweenness_centrality(G)
{0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.5333333333333333,
5: 0.5555555555555556,
6: 0.5333333333333333,
7: 0.0,
8: 0.0,
9: 0.0,
10: 0.0}
import networkx as nx G = nx.barbell_graph(m1=5, m2=1)
nx.betweenness_centrality(G)
{0: 0.0,
1: 0.0,
2: 0.0,
3: 0.0,
4: 0.5333333333333333,
5: 0.5555555555555556,
6: 0.5333333333333333,
7: 0.0,
8: 0.0,
9: 0.0,
10: 0.0}
Introduction to Network Analysis in Python