Search code examples
graphviz

Graphviz - Fixed Node Origin and End Point


Is there any way to ensure that all edges start from the same place on a node, and end on the same node in graphviz (see my primitive mockup)? I've been looking through the graphviz documentation, and I can't seem to find a parameter to fit this use-case. mockup


Solution

  • You are probably looking for node ports, specifically compass points.

    Ports and compass points are defined in the dot language grammar. A detailed description with examples can be found in the dot guide, page 18, "3.1 Node ports":

    A node port is a point where edges can attach to a node.

    There are two types of ports. Ports based on the 8 compass points "n", "ne", "e", "se", "s", "sw", "w" or "nw" can be specified for any node.

    In addition, nodes with a recordshape can use the record structure to define ports, while HTML-like labels with tables can make any cell a port using the PORT attribute of a element.

    Two examples of using ports with compass points:

    a:e -> b:w
    
    a -> b [tailport=e, headport=w]
    

    See also the headport and tailport attribute description