Reputation: 633
Good evening, I'm trying to generate graph using graphviz.
I can't figure out how to model horizontal edges between some nodes. I use the next code to generate this graph:
digraph{ rankdir=LR;
//{rank=same; "[0]"; "[10B1]"; "[62]"; "[8]"; "[9]"; "[10]";}
"[0]"->"[37]"; "[37]"->"[4]"; "[37]"->"[8]";
"[8]"->"[9]"; "[9]"->"[10]"; "[62]"->"[8]";
"[0]"->"[10B1]"; "[10B1]"->"[62]"; "[0]"->"[2]";
"[2]"->"[3]"; "[7]"->"[8]"; "[4]"->"[7]";
}
I would like to align the nodes [8], [10B1], [62] [8], [9] and [10] in one horizontal line.
Upvotes: 10
Views: 8176
Reputation: 56466
An other solution is to have the nodes which have to be aligned share the same value of the group
attribute:
digraph{
rankdir=LR;
node[group=main];
"[0]"; "[10B1]"; "[62]"; "[8]"; "[9]";
node[group=""];
"[0]"->"[37]";
"[37]"->"[4]";
"[37]"->"[8]";
"[8]"->"[9]";
"[9]"->"[10]";
"[62]"->"[8]";
"[0]"->"[10B1]";
"[10B1]"->"[62]";
"[0]"->"[2]";
"[2]"->"[3]";
"[7]"->"[8]";
"[4]"->"[7]";
}
You could achieve something similar by adjusting weight
or using constraint=false
for some edges.
Here's an other example using group, and an other example using weight (same question).
Upvotes: 7