简体   繁体   中英

Directed Graph Structure in networkx with two edges between two nodes

I am looking to have two directed edges connecting two nodes going in opposite directions. Currently I have the following, but it only shows one edge with two arrows.

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()

I found an answer here: 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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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