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

边栏推荐
- CameraToolUnity中两种摄像机的两种观察控制方式
- 【CPU设计实战】简单流水线CPU设计
- CentOS7 - yum install mysql
- 想吃菌子,当然是自己上山找了
- A Week of Wonderful Content Sharing (Issue 14)
- [core]-ARMV7-A、ARMV8-A、ARMV9-A 架构简介「建议收藏」
- Double non-one into bytes!!Pure dry goods sharing
- [core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
- 基于姿态估计的护具佩戴检测与动作识别
- AMBA APB学习记录(AMBA 2.0)
猜你喜欢
随机推荐
Markdown编辑器语法
亲测可用!!!WPF中遍历整个窗口的所有TextBox组件,对每个输入框做非空判断。
Use IN List Population in Your JDBC Application to Avoid Cursor Cache Contention Issues
[core]-ARMV7-A, ARMV8-A, ARMV9-A Architecture Introduction "Recommended Collection"
WPF中报错:“未将对象引用设置到对象的实例。”
Quickly learn database management
建情人节表白网站(超详细过程,包教包会)
认知—运动康复医疗机器人应用设计
电商rpa是什么意思?跟电商rpi是一个意思吗?
Chrome开发自定义右键菜单实现快速跳转到指定页面
LRU缓存[线性表 -> 链表 -> hash定位 -> 双向链表]
NPM 使用介绍
sqlalchemy determines whether a field of type array has at least one consistent data with an array
Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
榕树贷款GPU 硬件架构
CWE4.8 -- 2022年危害最大的25种软件安全问题
dosbox基础使用[通俗易懂]
PHP序列化:eval
SAP ABAP OData 服务如何支持 $filter (过滤)操作试读版









