graphguy
graphguy

Reputation: 21

How to force neato engine to reverse node order?

I'm trying to draw a graph where the shorter word "Myth" is in the top right, however the neato engine is recalcitrant and refuses to accept pos inputs (with or without !) and rank inputs. When appending ! to my pos inputs, it will just stretch the graph out really far, and keep "Hominids" in the top row, while putting "Myth" in the bottom.

enter image description here

digraph G {
layout="neato";
center="true";
fontpath="C:\Windows\Fonts";
node [fontsize="14"];
node [fontname="Abode Jenson Pro"];
graph [size="10,10!"];
rankdir=LR;
meme [shape=ellipse,label="Myth",rank="min",pos="3,0!"];
gene [shape=ellipse,label="Hominids",rank="max",pos="7,10!"];
meme -> gene [arrowsize="0.5",label="increases \n survival of",fontsize="8",constraint="true"];
gene -> meme [arrowsize="0.5",label="  generate \n venerate",fontsize="8",constraint="false"];
}

Upvotes: 2

Views: 228

Answers (1)

Dany
Dany

Reputation: 4730

Graphviz counts coordinates as on the orthogonal graph with 0 being at the bottom left corner. So in pos attribute first coordinate is distance from left side to right →, and the second one — from bottom to top ↑.

Look at you current coordinate values:

So it's logical that your nodes appear as on the picture: you've forced their positions to be so! If you inverse the pos values you will get the result you need:

digraph G {
    layout="neato";
    center="true";
    fontpath="C:\Windows\Fonts";
    node [fontsize="14"];
    node [fontname="Abode Jenson Pro"];
    graph [size="10,10!"];
    meme [shape=ellipse,label="Myth",rank="min",pos="7,10"];
    gene [shape=ellipse,label="Hominids",rank="max",pos="3,0"];
    meme -> gene [arrowsize="0.5",label="increases \n survival of",fontsize="8",constraint="true"];
    gene -> meme [arrowsize="0.5",label="  generate \n venerate",fontsize="8",constraint="false"];
}

Also note that rankdir attribute you used, won't have any effect in neato. As stated in the documentation it only works with dot layout.

Upvotes: 3

Related Questions