我试图将元素定位在自动生成的流程图的形式。 一般而言,inputs
(绿色)应该在最左边,outputs
(红色)在最右边,其余的应按照布局放置在中间。 我为此使用rank=source
和rank=sink
。 在标准图形中,它很好地工作。graphviz三个行列布局与子图
但是,当我开始嵌套图形时,rank=source
似乎不起作用。我期望<>(电,开关,房间温度)的三个输入被放置在最左边(因为它在子图内发生)以及子图+状态(棕色圆圈)和输入和输出之间的蓝色框。
有没有指定“等级=中心”(或类似的东西?)
我已经通过了documentation,但没有找到正确的属性(并在指定他们)的方式。
digraph MyGraph {
node [fontsize=8 margin=".1,.01" width=.5 height=.5 shape=box]
edge [fontsize=8]
rankdir=LR;
ranksep = .25;
nodesep= .5;
subgraph cluster_4386357488 {
label = " <<GrowLamp>>"
style=solid
{rank=source;
4386357544 [label="electricity" style=filled fillcolor="#b5fed9"]
4386357712 [label="room_temperature" style=filled fillcolor="#b5fed9"]
4386357768 [label="switch" style=filled fillcolor="#b5fed9"]
}
{
4386357880 [label="off" style=filled fillcolor="#e2cbc1" shape=doublecircle]
4386357936 [label="on" style=filled fillcolor="#e2cbc1" shape=circle]
4386357656 [label="on_time" style=filled fillcolor="#d2ceef"]
}
{rank=sink;
4386357600 [label="light" style=filled fillcolor="#fcc5b3"]
4386357824 [label="temperature" style=filled fillcolor="#fcc5b3"]
}
4386357880 -> 4386357936
4386357936 -> 4386357880
{
subgraph cluster_4386357992 {
label = "<<Adder>>"
style=dashed
{rank=source;
4386358048 [label="heat_in" style=filled fillcolor="#b5fed9"]
4386358104 [label="room_temp_in" style=filled fillcolor="#b5fed9"]
}
{
4386358216 [label="state" style=filled fillcolor="#e2cbc1" shape=doublecircle]
}
{rank=sink;
4386358160 [label="temperature" style=filled fillcolor="#fcc5b3"]
}
4386358216 -> 4386358160 [style="dashed"]
}
subgraph cluster_4386358328 {
label = "<<HeatElement>>"
style=solid
{rank=source;
4386358384 [label="electricity" style=filled fillcolor="#b5fed9"]
}
{
4386358496 [label="on" style=filled fillcolor="#e2cbc1" shape=doublecircle]
}
{rank=sink;
4386358440 [label="heat" style=filled fillcolor="#fcc5b3"]
}
4386358496 -> 4386358440 [style="dashed"]
}
subgraph cluster_4386358608 {
label = "<<LightElement>>"
style=solid
{rank=source;
4386358664 [label="electricity" style=filled fillcolor="#b5fed9"]
}
{
4386358776 [label="off" style=filled fillcolor="#e2cbc1" shape=doublecircle]
4386358832 [label="on" style=filled fillcolor="#e2cbc1" shape=circle]
}
{rank=sink;
4386358720 [label="light" style=filled fillcolor="#fcc5b3"]
}
4386358776 -> 4386358832
4386358832 -> 4386358776
4386358776 -> 4386358720 [style="dashed"]
4386358832 -> 4386358720 [style="dashed"]
}
4386358160 -> 4386357824
4386357712 -> 4386358104
4386358440 -> 4386358048
4386358720 -> 4386357600
4386357936 -> 4386358384 [style="dashed"]
4386357936 -> 4386358664 [style="dashed"]
4386357936 -> 4386357656 [style="dashed"]
}
}
有希望的解决方案: 这里是我想和落得什么。请注意,绿框在各自子图的左侧如何,红框在右侧。在这之间应该有其他的元素,由graphviz定位。
没有一个排名=中心,但也有其他方法来获得节点对准你会的方式喜欢。我有一个关于如何帮助你的想法,但我对于希望的安排很不清楚。你想要左边的所有绿色框,中间的棕色圆圈和右边的橙色框?或者你只是以这种方式wan some他们?你可以添加一个你想要的元素排列的粗略草图吗? – Craig
我添加了一个图像来解释我想要的。在每个盒子里,绿色框(输入)应该在左边,红色框(输出)在右边,其余的在中心(如'dot'看起来合适)。因此,应该有一种从左到右的“流动”。 – stklik