python - Is there a way to add arrows for nx. draw in networkx? -


i using networkx in python , using nx.draw function takes in arrows=true parameter, arrows don't seem show up. when doing this, using g=nx.graph(), when use g = nx.digraph(), arrows show up, default network shape lost. there way preserve default network layout comes nx.draw , have arrows?

yes, have fix positions yourself, see below example using circular_layout.

import networkx nx import matplotlib.pyplot plt g = nx.erdos_renyi_graph(20, 0.2) pos = nx.circular_layout(g) nx.draw_networkx(g, pos=pos) plt.show() 

plot of simple graph pos dictionary nodes keys , coordinates values. plot digraph (with same node set):

g1 = nx.digraph(g) nx.draw_networkx(g1, pos=pos) plt.show() 

plot digraph


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -