当前位置:网站首页>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 rapid development and actual combat 10.2 compound interest calculation && 10.3 refresh blog clicks
Centos7 install mysql5.7
Centos7 install mysql5.7 steps (graphical version)
PyQt5快速开发与实战10.2 复利计算 && 10.3 刷新博客点击量
这款悄然崛起的国产API接口管理工具,你一定要晓得
基于verilog的CRC校验(汇总)
Spark GC日志分析
【OpenCV】-边缘检测汇总示例
随机推荐
Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记
NameNode (NN) and SecondaryNameNode (2NN) working mechanism
硬盘分区,拓展C盘,不重装系统,不重装D盘软件的全教程。
列表页优化思路
关于我放弃考研这件事儿
基本语法(二)
Structural controllability of switched linear systems with symmetry constraints
查看Mysql数据库版本
快速学完数据库管理
SAP 电商云 Spartacus SSR Optimization Engine 几处 timeout 的执行顺序
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
电商rpa是什么意思?跟电商rpi是一个意思吗?
电脑重要文件很多,如何备份比较安全?
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
chroot命令
Using SQL Server FOR XML and FOR JSON syntax on other RDBMSs with jOOQ
尚硅谷–MySQL–基础篇(P1~P95)
jmeter性能测试步骤入门(性能测试工具jmeter)
CentOS7 —— yum安装mysql
docker部署完mysql无法连接