Introduction to Network Analysis in Python
Eric Ma
Data Carpentry instructor and author of nxviz package
import networkx as nx G = nx.erdos_renyi_graph(n=20, p=0.2)
len(G.edges())
29
len(G.nodes())
20
nx.degree_centrality(G)
{0: 0.15789473684210525,
1: 0.15789473684210525,
2: 0.15789473684210525,
3: 0.10526315789473684,...
nx.betweenness_centrality(G)
{0: 0.01949317738791423,
1: 0.060916179337231965,
2: 0.1276803118908382,
3: 0.03313840155945419,...
Introduction to Network Analysis in Python