更好的点状框图节点布局
在上一个问题(带点/Graphviz的框图布局)之后,我有进一步的问题。编译如下:
dot -Gsplines=none test.gv | neato -n -Gsplines=ortho -Tpng -otest.png
digraph G {
graph [rankdir = LR];
node[shape=record, style=filled];
bar[label="Bar", height=1.3636363636363635];
tea[label="Tea", height=1.3636363636363635];
brew[label="Brew", height=3.6363636363636362];
bar1[label="Bar1", height=2.2727272727272725];
baz[label="Baz", height=1];
foo[label="Foo", height=5.0];
darjeeling[label="Darjeeling", height=3.1818181818181817];
example[label="Example", height=17.727272727272727];
bar -> example [label="bar_clk"];
bar -> example [label="bar_bar"];
example -> tea [label="bli1"];
example -> tea [label="blo2"];
example -> tea [label="blo3"];
example -> brew [label="bli"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
bar1 -> example [label="bar1_foo"];
bar1 -> example [label="bar1_bar"];
bar1 -> example [label="bar1_baz"];
bar1 -> example [label="bar1_baz1"];
bar1 -> example [label="bar1_bar2"];
baz -> example [label="baz_foo"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> bar [label="blu"];
example -> baz [label="ble"];
darjeeling -> example [label="darjeeling_bli1"];
darjeeling -> example [label="darjeeling_blo2"];
darjeeling -> example [label="darjeeling_blo3"];
darjeeling -> example [label="darjeeling_bli1"];
darjeeling -> example [label="darjeeling_blo2"];
example -> darjeeling [label="bla"];
darjeeling -> example [label="darjeeling_blo3"];
}
我的问题是如何将 Baz 和 Darjeeling 节点移动到左侧以降低中间节点的高度。我不知道是什么决定了这一点。我知道这是一个有向图,所以该图的一般“流程”是从左到右,我只是想要更多的控制。
这些图表将自动生成,因此最好解释如何按照我的意愿布局以及为什么,而不是使其适用于这个特定示例的代码片段。
After a previous question (Block diagram layout with dot/Graphviz) I have further questions. The following is compiled like so:
dot -Gsplines=none test.gv | neato -n -Gsplines=ortho -Tpng -otest.png
digraph G {
graph [rankdir = LR];
node[shape=record, style=filled];
bar[label="Bar", height=1.3636363636363635];
tea[label="Tea", height=1.3636363636363635];
brew[label="Brew", height=3.6363636363636362];
bar1[label="Bar1", height=2.2727272727272725];
baz[label="Baz", height=1];
foo[label="Foo", height=5.0];
darjeeling[label="Darjeeling", height=3.1818181818181817];
example[label="Example", height=17.727272727272727];
bar -> example [label="bar_clk"];
bar -> example [label="bar_bar"];
example -> tea [label="bli1"];
example -> tea [label="blo2"];
example -> tea [label="blo3"];
example -> brew [label="bli"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
example -> brew [label="blo"];
bar1 -> example [label="bar1_foo"];
bar1 -> example [label="bar1_bar"];
bar1 -> example [label="bar1_baz"];
bar1 -> example [label="bar1_baz1"];
bar1 -> example [label="bar1_bar2"];
baz -> example [label="baz_foo"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> foo [label="bla"];
example -> bar [label="blu"];
example -> baz [label="ble"];
darjeeling -> example [label="darjeeling_bli1"];
darjeeling -> example [label="darjeeling_blo2"];
darjeeling -> example [label="darjeeling_blo3"];
darjeeling -> example [label="darjeeling_bli1"];
darjeeling -> example [label="darjeeling_blo2"];
example -> darjeeling [label="bla"];
darjeeling -> example [label="darjeeling_blo3"];
}
My question is how I could take the, say, Baz and Darjeeling nodes and move them to the left side to decrease the height of the middle node. I don't know what determines this. I understand this is a directional graph, so the general "flow" of the diagram is left to right, I'd just like more control.
These diagrams will be generated automatically, so an explanation on how to lay it out as I wish and why, as opposed to a code snippet that makes it work for this particular example, is preferred.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几点:
通过为从 Example 到 Baz< 的边缘设置
constraint=false
/em> 和 大吉岭,或者通过使用rank=min
将出现在示例左侧的所有节点分组到子图中。您可能会说这不是一个合适的解决方案(至少不是带有
constraint=false
的解决方案),因为,我完全理解(去过很多次) - 但同时,你希望
,因此图形仍然不是完全自动生成的(如何计算示例所需的高度?)。
我也不完全确定 - Baz 也可能在左边。
令人惊讶的是,在某些情况下,节点的出现顺序会改变布局。例如,如果您向上移动大吉岭节点的定义,它将出现在左侧(并且Bar将出现在右侧)。
编辑:这是代码片段...
第三种可能性是按右顺序(从上到下/从左到右)定义所有边,并装饰这些边使用
dir=back
返回。如果将这 3 行更改
为
或 为
(并更改
example
的高度),您将得到
A couple of points:
By setting
constraint=false
for the edges going from Example to Baz and Darjeeling, or by grouping all the nodes to appear left of Example in a subgraph withrank=min
.You may say that this is not a suitable solution (at least not the one with
constraint=false
) becauseand I completely understand (been there many times) - but at the same time, you wish
which is set manually, so the graph still is not fully auto-generated (how do you calculate the height needed for Example?).
I'm not completely sure neither - Baz could might as well be on the left.
Surprisingly, the order of appearance of the nodes changes the layout in some cases. For example, if you move up the definition of the Darjeeling node, it will appear on the left side (and Bar gets to be at the right side).
Edit: Here comes the code snippet...
A third possibility is to define all edges in the right order (top-down/left-right) and decorate the edges going back with
dir=back
.If you change these 3 lines
into
or into
(and change the height of
example
)You'll get