日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

网络图结构中节点度分布的散点图

發(fā)布時(shí)間:2023/12/14 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 网络图结构中节点度分布的散点图 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
import matplotlib.pyplot as plt #導(dǎo)入科學(xué)繪圖包 import networkx as nx G=nx.random_graphs.barabasi_albert_graph(1000,10)#生成n=1000,m=10的無標(biāo)度的圖 print ("某個(gè)節(jié)點(diǎn)的度:",G.degree(0))#返回某個(gè)節(jié)點(diǎn)的度 # print("所有節(jié)點(diǎn)的度:",G.degree())#返回所有節(jié)點(diǎn)的度 # print("所有節(jié)點(diǎn)的度分布序列:",nx.degree_histogram(G))#返回圖中所有節(jié)點(diǎn)的度分布序列(從1至最大度的出現(xiàn)頻次) degree=nx.degree_histogram(G)#返回圖中所有節(jié)點(diǎn)的度分布序列 x=range(len(degree))#生成X軸序列,從1到最大度 y=[z/float(sum(degree))for z in degree]#將頻次轉(zhuǎn)化為頻率,利用列表內(nèi)涵 plt.scatter(x,y,s=1,color=(1,0,0))#在雙對(duì)坐標(biāo)軸上繪制度分布曲線 plt.show()#顯示圖表

?

另外一種

%matplotlib inline import matplotlib.pyplot as plt # from matplotlib.ticker import FuncFormatter # from matplotlib.ticker import MultipleLocator #plt.style.use('seaborn-whitegrid') import numpy as np import networkx as nx import os graph_file = 'E:\\BlogCatalog.edge' G=nx.read_edgelist(graph_file) degree=nx.degree_histogram(G)#print(degree) font1 = {'family' : 'Times New Roman', 'weight' : 'normal', 'size' : 18, }xlabel="degree(d)" ylabel="Frequency" title=graph_file.split('\\')[-1].split('.')[0] tofile='E:\\'+title area=2x=range(len(degree)) d={}y=[z for z in degree] # x_major_locator=MultipleLocator() # #把x軸的刻度間隔設(shè)置為1,并存在變量里 # y_major_locator=MultipleLocator() # #把y軸的刻度間隔設(shè)置為10,并存在變量里 figsize=(5.8,5.2) plt.figure(figsize=figsize) plt.ylabel(ylabel,font1) plt.xlabel(xlabel,font1) plt.title(title,font1) plt.xticks(fontproperties = 'Times New Roman',size=14) plt.yticks(fontproperties = 'Times New Roman',size=14) #plt.loglog(x,y,color='blue',linewidth=2) plt.loglog(x,y,'.',c='blue') # plt.savefig(tofile+'.jpg') #nx.draw(G,node_color='y',with_labels=True) plt.show()

總結(jié)

以上是生活随笔為你收集整理的网络图结构中节点度分布的散点图的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。