Prodiction
Prodiction

Reputation: 187

Graphviz dot-file crazy edge positioning

I have a problem with the positions of the edges in my dot-file. enter image description here

In the dot-file I used contrainsts=false to exclude the edges m and l from the ranking and gave it some headport and tailport (with pygraphviz: headport='e', tailport='e'. They got a crazy shape. I want to have them on the right side of the nodes.

This is the dot-file:

strict digraph "" {
graph [bb="0,0,717.03,767.02",
    edges="{'arrowsize': '4.0'}",
    rankdir=LR,
    size="100,100",
];
cen0
   [height=0.5,
    label=a,
    rank=0,
    ];
3    [
    label=b,
    rank=1,
    ];
cen0 -> 3
   [label=z,
    pos=e];
0
   [label=c,
    rank=1,
    ];
cen0 -> 0
   [label=z,
    pos=e];
cor22
   [label=d,
    rank=2,
    ];
3 -> cor22
   [label=2,
    pos=e];
con23
   [label=e,
    rank=2,
    ];
3 -> con23
   [label=1,
    ];
cor2
   [label=g,
    rank=2,
    ];
0 -> cor2
   [label=4];
con4
   [label=h,
    rank=2,
    ];
0 -> con4
   [label=3];
1
   [label="Why I can't delete the attribute 'width' 
from this node?:
   Warning: Unable to reclaim box space in spline 
routing for edge \"con4\" ->\"con23\". Something is 
probably seriously wrong.
",
    rank=2,
    width=2.5731];
0 -> 1
   [label=k];
cor2:e -> cor22:e
   [constraint=false,
   rank=3
    label=l];
con4:e -> con23:e
   [constraint=false,
    rank=3
    label="Why this way?"];
}

I also wondered about why there comes that warning, when I delete the one last "width"-attribute. How could I get my edges in the way, I expected?

Upvotes: 1

Views: 1468

Answers (2)

Prodiction
Prodiction

Reputation: 187

The missing attribute is splines=curved, added to my graphviz code gives: enter image description here

Upvotes: 1

vaettchen
vaettchen

Reputation: 7659

This is probably an automatically generated product with a lot of "noise" - I have taken the liberty to almost completely re-write the code, to make it easier for me to work and test, and to concentrate on the essentials. You will add what is important for you back in and find out whether or not some of that breaks it.

With a good amount of trial and error, I found four major changes necessary:

  • The four third level nodes need to be in the same rank (rank = 3 does not help)
  • They need to be connected in the desired order by invisible edges
  • The edges between these nodes need to maintain the right hierarchical level, with the arrow pointing backwards
  • xlabels rather than labels need to be used for the edges

So here my largely edited code

digraph so 
{
    rankdir = LR;
    // edge[ arrowsize = 4 ];           // you don't want that

    cen0[ label = "a" ];
    3   [ label = "b" ];
    0   [ label = "c" ];
    cen0 -> { 3 0 }[ label = "z" ];

    cor22[ label = "d" ];
    con23[ label = "e" ];
    3 -> cor22[ label = "2" ];
    3 -> con23[ label = "1" ];

    cor2[ label = "g" ];
    con4[ label = "h" ];
    1   [ label = "Why I can't delete the attribute 'width' from this node?:\nWarning: Unable to reclaim box space in spline routing for edge \"con4\" ->\"con23\".\nSomething is probably seriously wrong.\n---  Width attribute not present here!  ---" ];
    0 -> cor2[ label = "4"];
    0 -> con4[ label = "3" ];
    0 -> 1[ label = "k" ];

    {rank = same; cor22 con23 cor2 con4 1 }
    cor22 -> con23 -> cor2 -> con4[ style = invis ]
    cor22:e -> cor2:e[ dir = back, xlabel = "   l" ];
    con23:e -> con4:e[ dir = back, xlabel = "   Is this better?" ];
}

and here is the result:

enter image description here

Upvotes: 2

Related Questions