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

边栏推荐
- 五种数据提交方式的优化
- Fully Dynamically Constrained Robot Efficient Time-Optimal Trajectory Planning
- PyQt5快速开发与实战 9.7 UI层的自动化测试
- sqlalchemy 判断一个array 类型的字段是否和一个array有至少一个一致的数据
- dosbox基础使用[通俗易懂]
- Character Functions and String Functions
- 最长算术(暑假每日一题 11)
- 365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal
- centos7安装mysql5.7
- Wearing detection and action recognition of protective gear based on pose estimation
猜你喜欢

go中select语句

centos7安装mysql5.7

CentOS7 installation MySQL graphic detailed tutorial

深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!

Ali on three sides: MQ message loss, repetition, backlog problem, how to solve?

CWE4.8 -- 2022年危害最大的25种软件安全问题

IDEA的database使用教程(使用mysql数据库)

How does the SAP ABAP OData service support the $filter (filter) operation trial version

The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!

NameNode (NN) 和SecondaryNameNode (2NN)工作机制
随机推荐
dosbox基础使用[通俗易懂]
基于verilog的CRC校验(汇总)
SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
Character Functions and String Functions
集群的安全模式
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
Exploring Plain Vision Transformer Backbones for Object Detection Paper Reading Notes
anaconda虚拟环境安装pytorch gpu版本
全动力学约束的机器人高效时间最优轨迹规划
串的基本概念与操作
NameNode (NN) 和SecondaryNameNode (2NN)工作机制
使用docker搭建mysql主从
log4j2的使用
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]
Cognitive-exercise rehabilitation medical robot application design
立一个flag
三相PWM整流器预测直接功率控制
Two methods of NameNode failure handling
Google Chrome(谷歌浏览器)安装使用