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

边栏推荐
猜你喜欢

kernel syscore

深度学习基本概念

Selenium自动化测试之Selenium IDE

alert(1) (haozi.me)靶场练习

【OpenCV】-边缘检测汇总示例

WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)

log4j2的使用
![LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]](/img/ad/dd80541514d6fedde8c730218fdf5a.png)
LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]

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

荣耀手机参数写错,客服认为没错
随机推荐
SAP message TK 248 solved
初识QEMU
Three-Phase PWM Rectifier Predictive Direct Power Control
docker部署完mysql无法连接
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
阿里三面:MQ 消息丢失、重复、积压问题,怎么解决?
基于verilog的CRC校验(汇总)
Markdown编辑器语法
Qt鼠标穿透
CameraToolUnity中两种摄像机的两种观察控制方式
A Week of Wonderful Content Sharing (Issue 14)
Use docker to build mysql master-slave
Encapsulation of conversion between Json and objects (Gson)
alert(1) (haozi.me)靶场练习
查看Oracle数据库的用户名和密码
PyQt5 rapid development and actual combat 10.1 Get city weather forecast
Fully Dynamically Constrained Robot Efficient Time-Optimal Trajectory Planning
CentOS7 - yum install mysql
带有对称约束切换线性系统的结构可控性
求一份常见Oracle故障模拟场景