Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting an edge from within a node

digraph foo {
a [label="<first> A | <rest> rest", shape=record];
b [label="<first> B | <rest> rest", shape=record];
a:rest -> b [label="foo", arrowtail=dot, dir=both];
}

I would like to start the tail of the edge (a to b) from within a:rest (ideally in the center), is this possible?

I am trying to draw linked lists using box and pointer like notation.

like image 999
wmercer Avatar asked Apr 24 '26 17:04

wmercer


1 Answers

Yes, this is possible. The attribute to use is called tailclip:

If true, the tail of an edge is clipped to the boundary of the tail node; otherwise, the end of the edge goes to the center of the node, or the center of a port, if applicable.

Just change your last line to

a:rest -> b [label="foo", arrowtail=dot, dir=both, tailclip=false];

Edit: As @Kyborek mentions in the comments, an additional compass point is needed for current versions of graphviz:

a:rest:c -> b [label="foo", arrowtail=dot, dir=both, tailclip=false];

See also this answer

like image 164
marapet Avatar answered Apr 30 '26 02:04

marapet