用graphviz布置一个大图 [英] laying out a large graph with graphviz
问题描述
我的女儿们玩的游戏与井字游戏没什么两样.当然,当我和他们一起玩的时候,我开始蛮横地强迫它……
My daughters have made a game not unlike tic-tac-toe. Of course as I played it with them I started brute-forcing it in my head...
所以在午餐时间,我做了一个简短的Python脚本来解决"游戏.我想以图形方式查看结果,因此生成了所有合法举动的点文件:
So at lunchtime I made a quick little Python script to 'solve' the game. And I wanted to see the results graphically, so I generated a dot file of all legal moves:
当我尝试使用dot
进行渲染时,它会花费很长时间,并且几个小时后我将其中止.
When I try and render it using dot
, it takes forever and I abort it after a few hours.
如果我使用neato
或sfdp
等渲染它,则需要花费几秒钟或更短的时间,但实际上无法读取布局:
If I render it using neato
or sfdp
etc, it takes a few seconds or less but the layout is impossible to actually read:
sfdp -x -Tpng data.dot > data.png
neato -x -Tpng data.dot > data.png
我很高兴得到的图像达到几百万像素.
I would be happy for the resulting image to be several megapixels.
如何布置并渲染这么大的图?我愿意接受非点式建议,例如也可以进行布局的Python库.
How can I lay out and render such a big graph? I am open to non-dot suggestions, like Python libraries that can do the layout too.
(一些相关链接)
添加:我的Python脚本解决游戏并生成点文件
Added: my Python script to solve the game and generate the dot file
推荐答案
尝试一下:
sfdp -x -Goverlap=scale -Tpng data.dot > data.png
-Goverlap
保留布局,但均匀地缩放,直到没有更多的节点重叠为止.缩小时,我可以得到一个约77MB的PNG.
The -Goverlap
preserves the layout but uniformly scales things up until there are no more node overlaps. I was able to get a ~77MB PNG that looks like this when you zoom out.
这篇关于用graphviz布置一个大图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!