强制“主线"进入节点在Graphviz(或替代方法)中成一条直线 [英] Forcing "main line" nodes into a straight line in Graphviz (or alternatives)

查看:122
本文介绍了强制“主线"进入节点在Graphviz(或替代方法)中成一条直线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Graphviz点(但愿意使用其他方式)来生成带有长主线"节点和许多小分支的图形.我希望主线从左到右是笔直的,上方或下方是小分支.但是,Graphviz平衡"了这两个分支,所以我最终得到了一个弯曲的图.

I'm trying to use Graphviz dot (but am willing to use something else) to generate a graph with a long "main line" of nodes, and many small branches. I'd like the main line to be straight from left to right, with the small branches above or below it. However, Graphviz "balances" the two branches, so I end up with a crooked graph.

为说明起见,这是我目前所得到的草图:

To illustrate, here's a sketch similar to what I currently get:

这就是我真正想要的:

有没有办法强迫或鼓励Graphviz生成类似于第二个图形的图形?我也许可以使用虚拟"第二个分支使它进行三向布局,然后在以后隐藏/删除假人,但是如果有更好的选择,那将是更好的选择.

Is there any way to force or encourage Graphviz to generate a graph like the second one? I may be able to use "dummy" second branches to have it do a 3-way layout, and then hide/delete the dummies afterward, but if there's a better option that would be preferable.

推荐答案

以下是使用边缘的 weight 属性的解决方案:

Here is a solution using the weight attribute of edges:

digraph G {
    rankdir="LR";
    node[width=0.15, height=0.15, shape=point];
    edge[weight=2, arrowhead=none];
    1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8;
    edge[weight=1];
    2 -> 9 -> 10 ;
    5-> 11 -> 12;
}

结果:

这篇关于强制“主线"进入节点在Graphviz(或替代方法)中成一条直线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆