Search code examples
graphviz

What does the `:e` and `:w` in `key:i1:e -> key2:i1:w` mean?


In this answer, there are edges with :e and :w in the code:

key:i1:e -> key2:i1:w

What do they mean? I suppose they are this line in The DOT Language | Graphviz:

compass_pt : (n | ne | e | se | s | sw | w | nw | c | _)

But I don't understand this. Googling compass_pt GraphViz doesn't yield any useful information.


Solution

  • See https://www.graphviz.org/doc/info/attrs.html#k:portPos
    Ports are used to explicitly position head/tail of edges. Ports are specified by compass points n(north), sw (southwest), etc and denote where on a node the edge is to terminate.

    graph p {
     // node names (e.g. ne) are not Graphviz instructions, but are just for the reader
     n--P:n
     ne--P:ne
     nw--P:nw
     s--P:s
     se--P:se
     sw--P:sw
     w--P:w
     e--P:e
     c--P:c
     }
    

    gives: enter image description here