通过networkx分析网络中节点的概率分布

Analyzing the probability distribution of nodes in a network through networkx

我正在使用python的networkx来分析网络的属性,我想画一个幂律图distribution.This是我的代码。

degree_sequence=sorted(nx.degree(G).values(),reverse=True) 
plt.loglog(degree_sequence,marker='b*')
plt.show()

这是我的图表:

但这不是节点度数概率分布图,而是节点度数分布degree.How 转换画出节点度数概率分布图

你只需要构造一个度数的直方图,即 hist[x] = 度数为 x 的节点数,然后将 hist 归一化使其总和为 1。

或者翻转轴并归一化,使值总和为 1。