如何设置图形填充区域?

时间:2018-10-30 22:45:16

标签: graphviz dot

如何设置图形以尝试填充分配给它的区域?随着节点数量的增加,它的大小只是减小了,但仍保留在一条线上,尽管垂直大小(40)允许向下放置。如果删除了rankdir,则它将垂直放置,但也将放置在一行中。

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"];
}

1 个答案:

答案 0 :(得分:2)

您需要选择合适的节点

  • 通过一条边连接
  • 以一种可以填充所需宽度的方式连接到其他节点

然后

  • 通过不可见的边缘按所需顺序连接它们(以免graphviz对它们进行重新排序)
  • 将它们放在同一个烤炉上,以便它们在另一个炉子的下方出现

具体而言,这意味着添加

1 -> 10 -> 19[ style = invis ];
{ rank = same; 1 10 19 }

紧接大括号之前,作为最后两行,将产生

enter image description here

据我所知,这就是您想要的。