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

边栏推荐
- WebGL给Unity传递参数问题1: Cannot read properties of undefined (reading ‘SendMessage‘)
- [Shader] Shader official example [easy to understand]
- Caused by: 类找不到: org.apache.flink.table.planner.delegation.ParserFactory或者ExecutorFactory
- Google Chrome(谷歌浏览器)安装使用
- Json和对象之间转换的封装(Gson)
- AMBA APB学习记录(AMBA 3/4)
- Full GC (Ergonomics)排查分析
- PyQt5 rapid development and actual combat 10.1 Get city weather forecast
- The function of SQL GROUP BY dependence
- 关于我放弃考研这件事儿
猜你喜欢
随机推荐
CameraToolUnity中两种摄像机的两种观察控制方式
分布式监视 Zabbix 和 Prometheus 到底怎么选?千万别用错了!
PyQt5快速开发与实战 10.1 获取城市天气预报
The 2nd activity of the TOGAF10 Standard Reading Club continues wonderfully, and the highlights will be reviewed!
攻防演练丨赛宁红方管控平台走进广东三地 助力数字政府网络安全建设
Optimization of five data submission methods
IDEA版Postman插件Restful Fast Request,细节到位,功能好用
查看Mysql数据库版本
ERROR 2003 (HY000) Can‘t connect to MySQL server on ‘localhost3306‘ (10061)
golang八股文整理(持续搬运)
尚硅谷–MySQL–基础篇(P1~P95)
Fully Dynamically Constrained Robot Efficient Time-Optimal Trajectory Planning
centos7安装mysql5.7步骤(图解版)
深圳某游戏研发公司每个工位都装监控,网友:堪比“坐牢”!
纷享销客罗旭对话元气森林黄晓枫:零售数字化的终点不是创新,而是数据
CentOS7 —— yum安装mysql
立方体IV(暑假每日一题 10)
SAP message TK 248 solved
0x80070570文件或目录损坏且无法删除(0x80070091怎么删除)
消息队列面试题(2022最新整理)









