2009-07-09 8 views
6

J'ai un certain nombre de graphiques relativement simples (générés automatiquement) au format point graphviz. Ceux-ci montrent le chemin à travers une machine d'état, mais le point a une habitude légèrement confuse de décider que deux nœuds doivent être au même rang quand je voudrais que le graphique soit dans l'ordre de l'état. J'ai essayé beaucoup de paramètres (y compris le :n et :s et le weight énumérés ci-dessous), mais je ne peux pas persuader le point pour placer le troisième état au-dessus de le quatrième état.Comment forcez-vous le rang sur un noeud dans le point?

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

Y at-il un moyen de suggérer au point qu'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

Répondre

10

Utilisez "contrainte = false".

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

Dans votre graphique:

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

Vous obtiendrez:

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

fantastique: merci! – DrAl

Questions connexes