networknx

networknx

  • G=nx.Graph()
    -G=G.add_node()
  • G=.add_edge()

code

` python
import networkx as nx
G = nx.random_graphs.barabasi_albert_graph(1000,3) #生成一个n=1000,m=3的BA无标度网络
print G.degree(0) #返回某个节点的度
print G.degree() #返回所有节点的度
print nx.degree_histogram(G) #返回图中所有节点的度分布序列(从1至最大度的出现频次)

import matplotlib.pyplot as plt #导入科学绘图的matplotlib包
degree = nx.degree_histogram(G) #返回图中所有节点的度分布序列
x = range(len(degree)) #生成x轴序列,从1到最大度
y = [z / float(sum(degree)) for z in degree]

将频次转换为频率,这用到Python的一个小技巧:列表内涵,Python的确很方便:)

plt.loglog(x,y,color=”blue”,linewidth=2) #在双对数坐标轴上绘制度分布曲线
plt.show() #显示图表

http://blog.sciencenet.cn/blog-404069-337511.html
http://blog.sciencenet.cn/blog-404069-337689.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值