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:

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 
Comments
Post a Comment