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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -