Graphviz绘制的图中存在不必要的边交叉。

huangapple go评论80阅读模式
英文:

Graphviz plotted graph has unnecessary edge crossings

问题

我有一个动态由代码生成的图形,我正在使用graphviz-java来绘制它。

但是绘制出来的图形存在不必要的边交叉,尽管生成的图形是平面的。

我搜索了类似的问题,但答案涉及使用诸如添加不可见边之类的技巧,由于在我的情况下图是由代码动态生成的,我无法使用这些技巧,是否有任何算法可以改善节点的摆放,以使边的交叉最小化?

这里是期望的输出与Graphviz生成的结果对比(期望的输出是手动绘制的):

Graphviz绘制的图中存在不必要的边交叉。 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)

Graphviz绘制的图中存在不必要的边交叉。 Graphviz绘制的图中存在不必要的边交叉。

答案1

得分: 0

我通过将布局引擎更改为 NEATO,成功获得了所需的输出。

Graphviz.fromGraph(mg).engine(Engine.NEATO).render(Format.PNG).toImage();
英文:

I managed to get the desired output by changing the Layout Engine to NEATO.

Graphviz.fromGraph(mg).engine(Engine.NEATO).render(Format.PNG).toImage();

Graphviz绘制的图中存在不必要的边交叉。

huangapple
  • 本文由 发表于 2020年7月23日 16:49:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/63050403.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定