当前位置:网站首页>networkx绘制度分布
networkx绘制度分布
2022-07-31 12:47:00 【fK0pS】
networkx绘制度分布
d = nx.degree(g1)
print("网络的度分布为:{}".format(d))
d = nx.degree(g1) print("网络的度分布为:{}".format(d)) degree_sequence = sorted((d for n, d in g1.degree()), reverse=True) import numpy as np fig, ax = plt.subplots() ax.bar(*np.unique(degree_sequence, return_counts=True)) ax.set_title("Degree histogram") ax.set_xlabel("Degree") ax.set_ylabel("# of Nodes") plt.show() print('plot normal graph finished!')
----
Degree Analysis — NetworkX 2.8.5 documentation
import networkx as nx import numpy as np import matplotlib.pyplot as plt G = nx.gnp_random_graph(100, 0.02, seed=10374196) degree_sequence = sorted((d for n, d in G.degree()), reverse=True) dmax = max(degree_sequence) fig = plt.figure("Degree of a random graph", figsize=(8, 8)) # Create a gridspec for adding subplots of different sizes axgrid = fig.add_gridspec(5, 4) ax0 = fig.add_subplot(axgrid[0:3, :]) Gcc = G.subgraph(sorted(nx.connected_components(G), key=len, reverse=True)[0]) pos = nx.spring_layout(Gcc, seed=10396953) nx.draw_networkx_nodes(Gcc, pos, ax=ax0, node_size=20) nx.draw_networkx_edges(Gcc, pos, ax=ax0, alpha=0.4) ax0.set_title("Connected components of G") ax0.set_axis_off() ax1 = fig.add_subplot(axgrid[3:, :2]) ax1.plot(degree_sequence, "b-", marker="o") ax1.set_title("Degree Rank Plot") ax1.set_ylabel("Degree") ax1.set_xlabel("Rank") ax2 = fig.add_subplot(axgrid[3:, 2:]) ax2.bar(*np.unique(degree_sequence, return_counts=True)) ax2.set_title("Degree histogram") ax2.set_xlabel("Degree") ax2.set_ylabel("# of Nodes") fig.tight_layout() plt.show()
边栏推荐
猜你喜欢
PyQt5快速开发与实战 10.1 获取城市天气预报
chroot命令
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
MySQL面试八股文(2022最新整理)
docker部署完mysql无法连接
Chrome开发自定义右键菜单实现快速跳转到指定页面
NameNode (NN) and SecondaryNameNode (2NN) working mechanism
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)解决办法
CentOS7 - yum install mysql
五种数据提交方式的优化
随机推荐
电商rpa是什么意思?跟电商rpi是一个意思吗?
centos7安装mysql5.7步骤(图解版)
How does the SAP ABAP OData service support the $filter (filter) operation trial version
行业案例 | 全面防护 赛宁助力能源工控安全建设
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
建情人节表白网站(超详细过程,包教包会)
串的基本概念与操作
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
NameNode故障处理的两种方法
CentOS7 - yum install mysql
Markdown编辑器语法
PyQt5快速开发与实战 9.7 UI层的自动化测试
查看Oracle数据库的用户名和密码
MySQL面试八股文(2022最新整理)
Character Functions and String Functions
Adding data nodes and decommissioning data nodes in the cluster
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
基于姿态估计的护具佩戴检测与动作识别
基于verilog的CRC校验(汇总)