Como você forçar classificação em um nó no ponto?
-
12-09-2019 - |
Pergunta
Eu tenho um número de gráficos relativamente simples (gerados automaticamente) em formato graphviz ponto. Estes mostram o caminho através de uma máquina de estado, mas dot tem o hábito um pouco confuso de decidir que dois nós devem estar na mesma posição quando eu gostaria que o gráfico para estar em ordem estatal. Eu tentei um monte de configurações (incluindo o :n
e :s
eo weight
listados abaixo), mas eu não posso convencer ponto para colocar o Terceiro Estado acima o quarto estado.
Eu tenho esse problema com um monte de gráficos: parece haver algo interno para ponto que decide que seria melhor se dois nós estávamos na mesma posição e não há nada que pode ser feito para substituí-lo. Eu mesmo tive código que especifica que um nó deve ser um rank=sink
, mas dot decidiu colocar outro nó abaixo de qualquer maneira.
Existe alguma maneira de sugerir a ponto de que é mais importante que os nós estão em ordem do que qualquer outra restrição?
O código que foi usado para gerar a aparência do gráfico como este:
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"];
}
O gráfico atualmente se parece com isso:
Solução
Use "restrição = false".
http://www.graphviz.org/doc/info/ attrs.html # d: restrição
Em seu gráfico:
FourthSTATE -> ThirdSTATE [label="No" constraint=false] ;
Você vai ter:
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 -> FourthSTATE;
FourthSTATE -> FifthSTATE [label="Yes" ];
FourthSTATE -> ThirdSTATE [label="No" constraint=false] ;
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"];
}