networkx中的有向图结构,两个节点之间有两个边

时间:2020-08-03 10:16:28

标签: python graph networkx

我正在寻找两个指向两个方向相反的节点的有向边。目前,我有以下内容,但仅显示带有两个箭头的一条边。

import networkx as nx
import itertools

abc=[n1 for n1 in itertools.permutations([1,2,3],2)]
G1 = nx.MultiDiGraph()
G1.add_edges_from(abc)
nx.draw_networkx(G1)
plt.show()

1 个答案:

答案 0 :(得分:0)

我在这里找到了答案:Drawing multiple edges between two nodes with networkx

import networkx as nx
import itertools

abc=[n1 for n1 in itertools.permutations([1,2,3],2)]
G1 = nx.MultiDiGraph()
G1.add_edges_from(abc)

pos = nx.spring_layout(G1)
nx.draw_networkx(G1,pos,with_labels=True,connectionstyle='arc3, rad = 0.1')
plt.show()