当前位置:网站首页>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()
边栏推荐
猜你喜欢
字符函数和字符串函数
Exploring Plain Vision Transformer Backbones for Object Detection 论文阅读笔记
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
通过斐波那契数再谈函数递归2.0
SAP ABAP OData 服务如何支持 $filter (过滤)操作试读版
电脑重要文件很多,如何备份比较安全?
AMBA APB学习记录(AMBA 3/4)
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
JVM 运行时数据区与JMM 内存模型详解
随机推荐
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
WPF中报错:“未将对象引用设置到对象的实例。”
阿里三面:MQ 消息丢失、重复、积压问题,怎么解决?
Three-Phase PWM Rectifier Predictive Direct Power Control
字符函数和字符串函数
Adding data nodes and decommissioning data nodes in the cluster
Comparison of ipv4 and ipv6 (IPV4)
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
WPF中TabControl动态获取当前选中的TabItem
ERROR 1064 (42000) You have an error in your SQL syntax; check the manual that corresponds to your
Indoor real-time laser SLAM control method based on biological excitation neural network
The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!
MySQL面试八股文(2022最新整理)
FIFO深度计算学习记录(汇总)
查看Mysql数据库版本
AMBA APB学习记录(AMBA 2.0)
kernel syscore
PyQt5 rapid development and actual combat 9.7 Automated testing of UI layer
Qt鼠标穿透
SAP ABAP OData 服务如何支持 $filter (过滤)操作试读版