2

I'm attempting to create function call graphs for specific code execution paths within Linux. I have the following digraph, which uses record fields (they are deprecated, I know, I just started using graphviz and only recently saw that):

digraph {
  node[fontsize=9,shape=Mrecord,style=filled,fillcolor=white];

  subgraph cluster_0 {
    style=filled; fillcolor=lightgrey;
    open[label="open.c|{<f0>do_sys_open()}"];
    namei[label="namei.c|{<f0>do_filp_open()\l|\
                          <f1>path_lookup_open()\l|\
                          <f2>do_path_lookup()\l}"];
    file_table[label="file_table.c|{<f0>get_empty_filp()}"];
    open:f0->namei:f0;
    namei:f0:e->namei:f1:e;
    namei:f1:e->namei:f2:e;
    namei:f1:e->file_table:f0;
  }
}

The generated image:

enter image description here

As the image shows, the arrows pointing between ports of the same record node always come out at an angle. Is there any way to "simplify" them so that they come out straight, or to somehow otherwise make this look neater?

TylerH
  • 20,799
  • 66
  • 75
  • 101

1 Answers1

0

In dot layout engine you can use the graph's attribute nodesep as was written in this answer. In this case the edges will remain curved.

For straight lines, you could use graph [splines=ortho] if it drew normally, but it doesn't work as expected:

The answer should be splines=ortho (https://graphviz.org/docs/attrs/splines). But in this case (both ports on same node) it fails miserably (try it). splines=polyline also fails. It is possible to post-process the curved splines to make 90 degree angles (I'd use GVPR), but that is probably more effort than you want.

To make the beginning of the edge path more visible, you can reduce the size (arrowsize=0.5) and the type of the arrow (arrowhead=vee) that overlaps that path.
Image:
edges between ports belonging to the same record node look good made with graphviz dot
Script:

digraph {
    graph[nodesep=1];
    
    node[fontsize=9,shape=Mrecord,style=filled,fillcolor=white];

    subgraph cluster_0 {
      style=filled;
      fillcolor=lightgrey;
      
      open[label="open.c|{<f0>do_sys_open()}"];
      namei[label="namei.c|{<f0>do_filp_open()|<f1>path_lookup_open()|<f2>do_path_lookup()}"];
      file_table[label="file_table.c|{<f0>get_empty_filp()}"];
    
      open:f0->namei:f0;
      namei:f0:e->namei:f1:e [arrowhead=vee arrowsize=0.5];
      namei:f1:e->namei:f2:e [arrowhead=vee arrowsize=0.5];
      namei:f1:e->file_table:f0;
  }
}
kirogasa
  • 627
  • 5
  • 19