Created
October 6, 2021 17:23
-
-
Save fish8/78a37bd964f8782a326b23afd41434d4 to your computer and use it in GitHub Desktop.
draw networkx graph with graphviz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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