import matplotlib.pyplot as plt #導入科學繪圖包
import networkx as nx
G=nx.random_graphs.barabasi_albert_graph(1000,10)#生成n=1000,m=10的無標度的圖
print ("某個節點的度:",G.degree(0))#返回某個節點的度
# print("所有節點的度:",G.degree())#返回所有節點的度
# print("所有節點的度分佈序列:",nx.degree_histogram(G))#返回圖中所有節點的度分佈序列(從1至最大度的出現頻次)
degree=nx.degree_histogram(G)#返回圖中所有節點的度分佈序列
x=range(len(degree))#生成X軸序列,從1到最大度
y=[z/float(sum(degree))for z in degree]#將頻次轉化爲頻率,利用列表內涵
plt.scatter(x,y,s=1,color=(1,0,0))#在雙對座標軸上繪製度分佈曲線
plt.show()#顯示圖表