【发布时间】:2020-10-26 09:24:12
【问题描述】:
我有以下 data 的数据框格式
a b
-510 -350
-300 -120
-350 -170
-170 30
30 210
-120 30
-690 -510
使用这些数据,我正在尝试使用 python 构建networkx 图形,到目前为止编写了以下代码
import networkx as nx
G1 = nx.DiGraph()
G1.add_edges_from(data)
data_1= nx.spring_layout(G1)
fig1=plt.figure(figsize=(5,2),dpi=300)
nx.draw(G1, data_1, node_size=1000, with_labels=True, node_color='y',vertex_label_size=100)
但出现以下错误Edge tuple start must be a 2-tuple or 3-tuple,这基本上是由于添加边。我尝试了一些谷歌搜索找不到任何合适的答案来解决这个问题。你能帮我解决这个问题吗?提前致谢。
【问题讨论】:
-
答案有帮助吗?不要忘记您可以投票并接受答案。见What should I do when someone answers my question?,谢谢!
标签: python networkx graph-theory