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

边栏推荐
- Cognitive-exercise rehabilitation medical robot application design
- [core]-ARMV7-A、ARMV8-A、ARMV9-A 架构简介「建议收藏」
- Encapsulation of conversion between Json and objects (Gson)
- 初识QEMU
- 栈和队列的基本概念
- Selenium自动化测试之Selenium IDE
- 集群中增加数据节点与退役数据节点
- 函数递归1.0
- jmeter性能测试步骤入门(性能测试工具jmeter)
- CentOS7 installation MySQL graphic detailed tutorial
猜你喜欢

go中select语句

CentOS7 - yum install mysql

通过斐波那契数再谈函数递归2.0

365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal

五种数据提交方式的优化

Use docker to build mysql master-slave

Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes

Architecture Camp | Module 8

PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer

How does the SAP ABAP OData service support the $filter (filter) operation trial version
随机推荐
FIFO深度计算学习记录(汇总)
SAP message TK 248 solved
小试牛刀—猜数字游戏
基于稳态视觉诱发电位和注意力脑电的混合脑机接口系统
dosbox基础使用[通俗易懂]
IDEA连接MySQL数据库并执行SQL查询操作
Double non-one into bytes!!Pure dry goods sharing
Architecture Camp | Module 8
Banyan Tree Loan GPU Hardware Architecture
[core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
Indoor real-time laser SLAM control method based on biological excitation neural network
sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
Markdown编辑器语法
基本语法(二)
LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]
WPF中TabControl动态获取当前选中的TabItem
sqlalchemy determines whether a field of type array has at least one consistent data with an array
go中select语句
How does the SAP ABAP OData service support the $filter (filter) operation trial version
Quickly learn database management