Question

J'ai un certain nombre de graphiques relativement simples (générées automatiquement) au format dot Graphviz. Ceux-ci montrent le chemin à travers une machine d'état, mais point a une habitude un peu déroutant de décider que deux nœuds doivent être sur le même rang que je voudrais le graphique pour être dans l'ordre de l'Etat. J'ai essayé beaucoup de paramètres (y compris les :n et :s et le weight ci-dessous), mais je ne peux persuader point de placer l'État tiers ci-dessus l'État quatrième.

J'ai ce problème avec beaucoup de graphiques: il semble y avoir quelque chose d'interne à point qui décide qu'il serait mieux si deux nœuds étaient sur le même rang et il n'y a rien qui peut être fait pour la remplacer. J'ai même eu un code qui spécifie qu'un nœud doit être un rank=sink, mais point a décidé de mettre un autre nœud en dessous de toute façon.

Est-il possible de proposer à point qui il est plus important que les nœuds sont dans l'ordre que toute autre contrainte?

Le code qui a été utilisé pour générer le graphique ressemble à ceci:

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

Le graphique ressemble actuellement à ceci: Dot Graph

Était-ce utile?

La solution

Utilisez "contrainte = false".

http://www.graphviz.org/doc/info/ attrs.html # d: contrainte

Dans votre graphique:

FourthSTATE -> ThirdSTATE [label="No" constraint=false] ;

Vous obtenez:

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"];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top