开发者

How to control node placement in graphviz (i.e. avoid edge crossings)

I'm using graphviz (dot) to generate the graph you can see below. The node in the lower left corner (red ellipse) causes annoy开发者_如何学运维ance as its edges cross several edges of the adjacent node. Is there a way to restrain node placement to a certain area?

How to control node placement in graphviz (i.e. avoid edge crossings)


You could create an invisible constraint, to cause the red node to appear to the left of all other nodes.

redNode -> leftmostNode [style=invis];

Before:

How to control node placement in graphviz (i.e. avoid edge crossings)

After:

How to control node placement in graphviz (i.e. avoid edge crossings)


I like @smokris' [style=invis] trick for persuading graphviz to put things where you want them, by adding edges which affect layout but aren't visible.


Another trick is the constraint attribute, which lets you add edges which are visible but don't affect layout.

If adding a new edge messes up your graph, set [constraint=false] on that edge: now graphviz will ignore it when placing nodes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜