graphviz change orientation of a specific shape in a digraph

1k Views Asked by At

How can i place all "parallelogram" [see my code] on the top of the S boxes with graphviz dot langage?

So basically the output should look like a straight line with all M1 M2 and Mn on the top of the graph.

Actual output: enter image description here Desired output: enter image description here

digraph ER {

node [group=M; shape=parallelogram]; M1; M2; M_n;
node [group=I, shape=none]; "...";
node [group=V, shape=egg]; IV; V1; V2;
node [group=C, shape=box]; "S1";  "S2";  "S_n"; f;
node [group=F, shape=hexagon]; "FINAL";


    IV -> "S1";
    M1 -> "S1";
    "S1" -> V1;
    V1 -> "S2";
    M2 -> "S2";
    "S2" -> V2;
    V2 -> "...";
    "..." -> "S_n";
    M_n -> "S_n";
    "S_n" -> f;
    f -> "FINAL"

    rankdir=LR;
}
1

There are 1 best solutions below

0
On BEST ANSWER

The rank attribute allows constraining two (or more) nodes of the same subgraph to the same rank. With that in mind:

digraph ER {

rankdir=LR;

node [shape=none]; "...";
node [shape=egg]; IV; V1; V2;
node [shape=box]; f;
{rank=same; "S1"; M1[shape=parallelogram];}
{rank=same; "S2"; M2[shape=parallelogram];}
{rank=same; "S_n"; M_n[shape=parallelogram];}
node [shape=hexagon]; "FINAL";

    IV -> "S1";
    M1 -> "S1";
    "S1" -> V1;
    V1 -> "S2";
    M2 -> "S2";
    "S2" -> V2;
    V2 -> "...";
    "..." -> "S_n";
    M_n -> "S_n";
    "S_n" -> f;
    f -> "FINAL"

}