当前位置:网站首页>Networkx drawing and common library function coordinate drawing
Networkx drawing and common library function coordinate drawing
2022-07-07 07:03:00 【lanmy_ dl】
explain : Not stitching , Mainly take notes by yourself , Recently learned about a process
1. The creation of a figure
G = nx.Graph() # Create an undirected graph
G = nx.DiGraph() # Create a directed graph
G = nx.MultiGraph() # Create multiple undirected graphs
G = nx.MultiDigraph() # Create multiple digraphs AttributeError: module ‘networkx’ has no attribute ‘MultiDigraph’
G.clear() # Empty map
2.Networkx Parameters of drawing and sorting function ,networkx, drawing , Function parameter
3.Networkx Library draws a directed graph , Customize and fix the coordinates of each node
If you want to use an undirected graph , When defining a graph, just change , Refer to below
Fixed coordinates
import networkx as nx
import matplotlib.pyplot as plt
def main():
G = nx.DiGraph()
# Add corresponding edges and points
for i in range(1, 10):
G.add_node(i, desc='v'+str(i)) # Node name cannot be str,desc Is the label, that is, the node name
G.add_edge(1, 2, name='6') # Add edge , Parameters name As the edge weights
G.add_edge(1, 3, name='4')
G.add_edge(1, 4, name='5')
G.add_edge(2, 5, name='1')
G.add_edge(3, 5, name='1')
G.add_edge(4, 6, name='2')
G.add_edge(5, 7, name='9')
G.add_edge(5, 8, name='7')
G.add_edge(6, 8, name='4')
G.add_edge(7, 9, name='2')
G.add_edge(8, 9, name='4')
pos = [(1, 3), (1, 3), (2, 4), (2, 2), (2, 1), (3, 3), (4, 1), (5, 4), (5, 2), (6, 3)] # pos The list starts at 0 Bit start , But my definition is from the node 1 Start , Here let the first two coordinates be the same
# Press pos Draw nodes at the specified position , No tag no value
nx.draw_networkx(G, pos, with_labels=None)
# Draw a label
node_labels = nx.get_node_attributes(G, 'desc')
nx.draw_networkx_labels(G, pos, labels=node_labels)
# Draw edge weights
edge_labels = nx.get_edge_attributes(G, 'name')
nx.draw_networkx_edge_labels(G, pos, edge_labels=edge_labels)
plt.title('AOE_CPM', fontsize=10)
plt.show()
if __name__ == '__main__':
main()
4.gephi、Graphviz And other drawing tools
The coder or the code draws points and lines according to the data , Tools are too troublesome , Never tried.
drawing tools
边栏推荐
- FPGA课程:JESD204B的应用场景(干货分享)
- main函数在import语句中的特殊行为
- 常用函数detect_image/predict
- MOS管参数μCox得到的一种方法
- MySQL SQL的完整处理流程
- How can flinksql calculate the difference between a field before and after update when docking with CDC?
- . Net core accesses uncommon static file types (MIME types)
- Brand · consultation standardization
- How to do sports training in venues?
- Jetpack Compose 远不止是一个UI框架这么简单~
猜你喜欢
MySQL view bin log and recover data
一文带你了解静态路由的特点、目的及配置基本功能示例
偏执的非合格公司
MATLAB小技巧(30)非线性拟合 lsqcurefit
This article introduces you to the characteristics, purposes and basic function examples of static routing
SolidWorks的GB库(钢型材库,包括铝型材、铝管等结构)安装及使用教程(生成铝型材为例)
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第一阶段答案
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
MYSQL----导入导出&视图&索引&执行计划
ANR 原理及实践
随机推荐
【mysqld】Can't create/write to file
How to do sports training in venues?
品牌·咨询标准化
Matlab tips (30) nonlinear fitting lsqcurefit
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
数据资产管理与数据安全国内外最新趋势
分布式id解决方案
带你刷(牛客网)C语言百题(第一天)
Abnova 免疫组化服务解决方案
[noi simulation] regional division (conclusion, structure)
Linear algebra (1)
Basic introduction of JWT
Networkx绘图和常用库函数坐标绘图
二十岁的我4面拿到字节跳动offer,至今不敢相信
. Net core accesses uncommon static file types (MIME types)
ip地址那点事
Multidisciplinary integration
Stack and queue-p79-10 [2014 unified examination real question]
Answer to the second stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
Graduation design game mall