Search code examples
graphvizdot

How to control the position of the nodes


Just two short questions. Let's consider the following code from Graphviz:

digraph EXAMPLE {

splines="line";
node[shape=circle, fontname="Verdana"];
ranksep=1;

SC -> {00, 01} -> {02, 03} -> {FC}
SU -> {13, 12, 10} -> {11} -> {FU}
SD -> {22} -> {23, 21, 20} -> {FD}
ST -> {31, 32} -> {33, 30} -> {FT}

S -> {SC ; SU ; SD ; ST}
{FC ; FU ; FD ; FT} -> F

}

That is rendering the following:

Graphviz

I have two questions:

  1. How can I make that node "11" appears in the same vertical level as node "12"?
  2. How can attain that the horizontal distance between nodes "SC", "SU", "SD", and "ST" would be the same?

Thank you in advance!!


Solution

  • digraph EXAMPLE {
    
    splines="line";
    node[shape=circle, fontname="Verdana"];
    ranksep=1;
    
    {node [group=gA] 11 12 }
    SC -> {00, 01} -> {02, 03} -> {FC}
    SU -> {13, 12, 10} -> {11} -> {FU}
    SD -> {22} -> {23, 21, 20} -> {FD}
    ST -> {31, 32} -> {33, 30} -> {FT}
    
    {
    edge[weight=10]
    S -> {SC ; SU ; SD ; ST}
    }
    {FC ; FU ; FD ; FT} -> F
    
    }
    

    Giving:
    enter image description here