当前位置:网站首页>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()

边栏推荐
- 基本语法(一)
- [Shader] Shader official example [easy to understand]
- FastAPI encapsulates a generic response
- 尚硅谷–MySQL–基础篇(P1~P95)
- Centos7 install mysql5.7 steps (graphical version)
- 2022年最新重庆建筑安全员模拟题库及答案
- 0x80070570 The file or directory is damaged and cannot be deleted (how to delete 0x80070091)
- Indoor real-time laser SLAM control method based on biological excitation neural network
- PyQt5快速开发与实战10.2 复利计算 && 10.3 刷新博客点击量
- WPF中TabControl动态获取当前选中的TabItem
猜你喜欢
随机推荐
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
go中select语句
Wearing detection and action recognition of protective gear based on pose estimation
线性表的基本概念
纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据
Architecture Camp | Module 8
CentOS7 - yum install mysql
通过斐波那契数再谈函数递归2.0
0x80070570文件或目录损坏且无法删除(0x80070091怎么删除)
Chrome开发自定义右键菜单实现快速跳转到指定页面
基于生物激励神经网络的室内实时激光SLAM控制方法
chroot命令
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
函数递归1.0
Anaconda安装labelImg图像标注软件
golang八股文整理(持续搬运)
The function of SQL GROUP BY dependence
LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]
imx6ull看门狗使用
PyQt5快速开发与实战 9.7 UI层的自动化测试









