Search code examples
recordgraphvizdot

Edges inside records in graphviz/dot


I want to highlight a relationship inside a record in graphviz (v 2.38.0) by running a straight edge between two of the elements in that record. However, dot does everything it can to run the edge outside the record node.

The following example shows my problem.

digraph {
  rankdir = LR;
  splines = line;

  i1; i2; i3;
  mux [shape=record,label="{  {<i1>i1|<i2>i2|<i3>i3} | MUX | <o1>o1}"];
  o;

  i1 -> mux:i1;
  i2 -> mux:i2;
  i3 -> mux:i3;
  mux:o1 -> o;

  mux:i1:e -> mux:o1:w [color=red];

}

enter image description here

I want the red edge to be a straight line between the ports, inside the record. I don't care if the edge overlays the record label.

Is there a way to force an edge to be a straight line ignoring obstacles, or otherwise instruct dot that an object should ignore if it's overlaying nodes/labels?

This issue is similar to Graphviz edges between ports belonging to the same record node look bad, which doesn't have an answer.


Solution

  • Try: splines = curved;

    digraph {
      rankdir = LR;
      splines = curved;
    
      i1; i2; i3;
      mux [shape=record,label="{  {<i1>i1|<i2>i2|<i3>i3} | MUX | <o1>o1}"];
      o;
    
      i1 -> mux:i1;
      i2 -> mux:i2;
      i3 -> mux:i3;
      mux:o1 -> o;
    
      mux:i1:e -> mux:o1:w [color=red];
    
    
    }
    

    png