英文:
Graphviz plotted graph has unnecessary edge crossings
问题
我有一个动态由代码生成的图形,我正在使用graphviz-java来绘制它。
但是绘制出来的图形存在不必要的边交叉,尽管生成的图形是平面的。
我搜索了类似的问题,但答案涉及使用诸如添加不可见边之类的技巧,由于在我的情况下图是由代码动态生成的,我无法使用这些技巧,是否有任何算法可以改善节点的摆放,以使边的交叉最小化?
这里是期望的输出与Graphviz生成的结果对比(期望的输出是手动绘制的):
英文:
I have a graph which is dynamically generated by code and I'm using graphviz-java to plot it.
but the plotted graph has unnecessary edge crossings despite the fact the generated graph was flat.
i searched similar questions but the answers involved using tricks like adding invisible edges, since in my case graph is generated by code dynamically I can't use those tricks is there any algorithm to improve node placements so that the edge crossings are minimized?
here is desired output vs. generated result by Graphviz (desired is drawn manually)
答案1
得分: 0
我通过将布局引擎更改为 NEATO,成功获得了所需的输出。
Graphviz.fromGraph(mg).engine(Engine.NEATO).render(Format.PNG).toImage();
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论