我有一些相对简单的(自动生成的)graphviz dot 格式的图表。这些显示了通过状态机的路径,但是当我希望图形处于状态顺序时,dot 有一个稍微令人困惑的习惯,即决定两个节点必须处于同一等级。我尝试了很多设置(包括:n
and:s
和weight
下面列出的),但我无法说服 dot 将第三状态置于第四状态之上。
我对很多图表都有这个问题: dot 似乎有一些内部因素决定如果两个节点处于同一等级并且没有什么可以覆盖它会更好。我什至有代码指定一个节点应该是 a rank=sink
,但是 dot 决定在它下面放置另一个节点。
有什么方法可以建议节点有序比任何其他约束更重要?
用于生成图表的代码如下所示:
digraph {
ERROR [label="Error"];
FirstSTATE [label="Initial State" URL="\ref FirstSTATE"];
FirstSTATE -> SecondSTATE;
SecondSTATE [label="Second State" URL="\ref SecondSTATE"];
SecondSTATE -> ThirdSTATE;
ThirdSTATE [label="Third State" URL="\ref ThirdSTATE"];
FourthSTATE [label="Fouth State?" shape="diamond"];
ThirdSTATE:s -> FourthSTATE:n [weight=50];
FourthSTATE -> FifthSTATE [label="Yes" ];
FourthSTATE -> ThirdSTATE [label="No"];
FifthSTATE [label="Fifth State" URL="\ref FifthSTATE"];
SixthSTATE [label="Sixth State?" shape="diamond"];
SixthSTATE -> ERROR [label="Yes" ];
SixthSTATE -> SeventhSTATE [label="No"];
FifthSTATE -> SixthSTATE;
SeventhSTATE [label="Seventh State" URL="\ref SeventhSTATE"];
SeventhSTATE -> EighthSTATE;
EighthSTATE [label="Eighth State" URL="\ref EighthSTATE"];
NinthSTATE [label="Ninth State?" shape="diamond"];
NinthSTATE -> TenthSTATE [label="Yes" ];
NinthSTATE -> EighthSTATE [label="No"];
EighthSTATE -> NinthSTATE;
TenthSTATE [label="Tenth State" URL="\ref TenthSTATE"];
EleventhSTATE [label="Eleventh State?" shape="diamond"];
EleventhSTATE -> ERROR [label="Yes" ];
EleventhSTATE -> TwelfthSTATE [label="No" ];
TenthSTATE -> EleventhSTATE;
TwelfthSTATE [label="Twelfth State" URL="\ref TwelfthSTATE"];
}
该图当前如下所示: