帮我修改一下这段代码的错误import networkx as nx G = nx.DiGraph() start = [1, 3, 5, 7] to = [2, 4, 6, 8] for j in range(len(start)): G.add_edge(start[j], to[j]) nx.draw(G, with_lables=True)
时间: 2023-06-16 11:02:30 浏览: 135
Python库 | networkx-1.4rc1-py3.2.egg
5星 · 资源好评率100%
import networkx as nx
G = nx.DiGraph()
start = [1, 3, 5, 7]
to = [2, 4, 6, 8]
for j in range(len(start)):
G.add_edge(start[j], to[j])
nx.draw(G, with_labels=True)
# 你在原来的代码中写成了 with_lables,正确的参数名称应该是 with_labels。此外,你需要在绘图之前先添加边。
阅读全文