如何设置图形填充区域?
问题描述:
如何设置图形以尝试填充分配给它的区域?随着节点数量的增加,它的大小只是减小了,但仍保留在一行中,尽管垂直大小(40)允许向下放置.如果删除了rankdir,则它将垂直放置,但也将放置在一行中.
How to set the graph to try to fill the area allocated to it? With an increase in the number of nodes, it simply decreases in size, but also remains in one line, although the vertical size (40) allows placement down. If you remove the rankdir, then it places vertically, but also in one line.
digraph "test_graph"{
rankdir = LR;
bgcolor = whitesmoke;
graph [size = "15, 40"];
node [shape = circle,
style = filled,
margin = 0,
fontsize = 14,
color = sandybrown];
edge [fontsize = 10,
arrowhead = vee];
1->2 [label = "R"];
2->3 [label = "R"];
3->4 [label = "R"];
3->5 [label = "B"];
4->1 [label = "R"];
5->6 [label = "U"];
6->7 [label = "U"];
7->8 [label = "U"];
7->9 [label = "F"];
8->5 [label = "U"];
9->10 [label = "F"];
10->11 [label = "D"];
11->12 [label = "D"];
12->13 [label = "D"];
13->10 [label = "D"];
13->14 [label = "L"];
14->15 [label = "L"];
15->16 [label = "D"];
16->17 [label = "D"];
17->18 [label = "D"];
17->19 [label = "L"];
18->15 [label = "D"];
19->20 [label = "F"];
20->21 [label = "F"];
21->22 [label = "F"];
21->23 [label = "L"];
22->19 [label = "F"];
23->24 [label = "L"];
24->25 [label = "F"];
}
答
您将需要选择合适的节点
You will need to select suitable nodes that
- 通过一条边连接
- 以一种可以填充所需宽度的方式连接到其他节点
然后
- 通过不可见的边缘按所需顺序连接它们(以免graphviz对它们进行重新排序)
- 将它们放在同一个烤炉上,以便它们在另一个炉子的下方出现
具体而言,这意味着添加
In concrete terms this means that adding
1 -> 10 -> 19[ style = invis ];
{ rank = same; 1 10 19 }
紧接大括号之前,作为最后两行,将产生
just before the closing curly brace, as the last two lines, will produce
据我所知,这就是您想要的.
which is, as far as I understand your requirement, what you want.