Reputation: 183
Here is the code for my graphviz digraph I am trying to create. An example image of what this creates is below, and I want to switch node 'a' with 'e' and I need to switch node 'b' with 'd'. I have tried changing their position in code and other stuff too. Examples of what I currently have and what I desire are in links below.
digraph {
graph[nodesep=1.75, ranksep=1.25, pad=".5", rankdir=LR];
node[shape=circle];
F[label=f];
A[label=a];
E[label=e];
B[label=b];
D[label=d];
C[label=c];
{rank=min; F};
{rank=same; A; E};
{rank=same; B; D};
{rank=max; C};
F -> {D};
A -> {B D F};
E -> {D F};
B -> {C F};
D -> {B};
C -> {D};
}
Upvotes: 1
Views: 777
Reputation: 183
I corrected my code above and solved my own problem in combination with @JLH answer.
digraph {
graph[nodesep=1, ranksep=1, pad=".5"];
rankdir="LR";
node[shape=circle];
F[label=f];
A[label=a];
E[label=e];
B[label=b];
D[label=d];
C[label=c];
{rank=min; F};
{rank=same; A E}
{rank=same; B D}
{rank=max; C};
F -> {D};
A -> {B D F};
E -> {D F};
B -> {C F}
D -> {B};
C -> {D};
edge[style=invis];
A -> E
E -> B
B -> D
}
The key to the answer is adding an invisible connection between E and B which pulls E back into the loop of things.
Upvotes: 3
Reputation: 7409
I got very close with this implementation, though still having a hard time aligning E horizontally with D. But this scheme gets the nodes in the order you specify using invisible directional links that enforce order according to rank.
digraph {
rankdir=LR;
node[shape=circle];
nodesep=1.75; ranksep=1.25; pad=0.5;
{rank=same; rank=min; F; }
{rank = same; A -> E [style=invis]; }
{rank= same; B -> D [style=invis]; }
{rank=same; rank=max; C;}
F[label=f];
A[label=a];
E[label=e];
B[label=b];
D[label=d];
C[label=c];
A -> B;
A -> D;
A-> F;
B-> C;
B-> F;
C-> D;
D-> B;
F-> D;
nodesep=0.75;
E -> D;
E-> F;
}
Upvotes: 3