简体   繁体   English

在 python 中使用 networkx 绘制边

[英]draw edges with networkx in python

I have a graph with float coordinate position(ex: (1.3, 2.75)) and draw my graph with nodes and some special edges.我有一个带有浮点坐标位置的图(例如:(1.3,2.75))并用节点和一些特殊边缘绘制我的图。 and G.edges is type of networkx.classes.reportviews.EdgeView, for example:而 G.edges 是 networkx.classes.reportviews.EdgeView 的类型,例如:

print(G.edges)

=>(((29.637096774193548, 61.74242424242425), (52.822580645161295, 35.76839826839827)),(...),...) and my code is: =>((((29.637096774193548, 61.74242424242425), (52.822580645161295, 35.76839826839827)),(...),...) 我的代码是:

nx.draw_networkx_edges(G, pos, edgelist=G.edges())

that

KeyError:(29.637096774193548, 61.74242424242425)密钥错误:(29.637096774193548,61.74242424242425)

it solved.它解决了。 the edges add with its keys in dictoinary (pos) and i add ((x1,y1),(x2,y2)) to edges.边缘用字典(pos)中的键添加,我将((x1,y1),(x2,y2))添加到边缘。 i change my code and add(0,1) to edges that 0 assign to (x1,y1) and 1 assign to (x2,y2) in nodelist or pos.我更改我的代码并将(0,1)添加到节点列表或pos中0分配给(x1,y1)和1分配给(x2,y2)的边。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM