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

边栏推荐
- SAP 电商云 Spartacus UI 和 Accelerator UI 里的 ASM 模块
- IDEA的database使用教程(使用mysql数据库)
- NameNode (NN) and SecondaryNameNode (2NN) working mechanism
- 0x80070570文件或目录损坏且无法删除(0x80070091怎么删除)
- 求一份常见Oracle故障模拟场景
- ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
- NameNode (NN) 和SecondaryNameNode (2NN)工作机制
- AMBA APB学习记录(AMBA 2.0)
- 365-day challenge LeetCode1000 questions - Day 044 Maximum element in the layer and level traversal
- Google Chrome(谷歌浏览器)安装使用
猜你喜欢

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

Optimization of five data submission methods

系统集成项目管理工程师(软考中级)知识点总结【挣值分析】【关键路径】

A Week of Wonderful Content Sharing (Issue 14)

Architecture Camp | Module 8

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

SAP ABAP OData 服务如何支持 $filter (过滤)操作试读版

使用docker搭建mysql主从

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

CentOS7 —— yum安装mysql
随机推荐
阿里三面:MQ 消息丢失、重复、积压问题,怎么解决?
查看Oracle数据库的用户名和密码
The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!
NPM 使用介绍
Use IN List Population in Your JDBC Application to Avoid Cursor Cache Contention Issues
一文吃透哈希表
基于姿态估计的护具佩戴检测与动作识别
机器学习基本概念
求一份常见Oracle故障模拟场景
全动力学约束的机器人高效时间最优轨迹规划
CentOS7 —— yum安装mysql
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
Optimization of five data submission methods
Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记
建情人节表白网站(超详细过程,包教包会)
WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
【CPU设计实战】简单流水线CPU设计
Google Chrome(谷歌浏览器)安装使用
深度学习基本概念
查看Mysql数据库版本