Skip to content

Instantly share code, notes, and snippets.

@fish8
Created October 6, 2021 17:23
Show Gist options
  • Save fish8/78a37bd964f8782a326b23afd41434d4 to your computer and use it in GitHub Desktop.
Save fish8/78a37bd964f8782a326b23afd41434d4 to your computer and use it in GitHub Desktop.
draw networkx graph with graphviz
from networkx.drawing.nx_agraph import graphviz_layout, to_agraph
from PIL import Image
from io import BytesIO
A = to_agraph(g2)
A.layout(prog='dot')
# graphviz_layout(prog=neato)
img = A.draw(format='png')
image = Image.open(BytesIO(img))
image.show(title="Graph")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment