Cam K
Cam K

Reputation: 127

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

Upvotes: 0

Views: 926

Answers (1)

Cam K
Cam K

Reputation: 127

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

Upvotes: 0

Related Questions