python - How to show cycles in networkx graph drawing -


i have simple graph constructed using networkx follows:

import networkx nx import matplotlib.pyplot plt  g = nx.digraph() g.add_edges_from([(0,1), (0,2), (1,1), (1,2)]) nx.draw_networkx(g) plt.show()  

when draw graph, image:

enter image description here

the graph has edge (1,1) not show edge on image. how can draw edge, too? think result of not using arrows. visualization bad. how can use arrows instead of bold lines?

graphviz great job of drawing arrows , self loops. (non-trivial implement in matplotlib). here example:

import networkx nx import matplotlib.pyplot plt  g = nx.digraph() g.add_edges_from(\[(0,1), (0,2), (1,1), (1,2)\]) nx.write_dot(g,'graph.dot')  # run dot -tpng graph.dot > graph.png 

enter image description here


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -