Question

I am trying to build a dependecy scheme of a program as a digraph in dot. Therefore I used the following code:

digraph LINK { 
    rankdir=LR; 
    ranksep=0.65;
    nodesep=0.40;
    splines=false; 
    overlap=false;
    concentrate=false; 
    node[shape=box]; 
    subgraph clusterAPP {
            label="Application"; 
            style=dashed; 
            nodeA[label="d = func(...);"]; 

    }; 
    subgraph clusterFB{
            color=red;
            label="Wrapper"; 
            style=dashed; 
            rank=same; 
            wrapper[label="wrapper"]; 
            real[label="pointer to\nreal func"]; 
            wrapper -> real [constraint=false,label="dlopen\ndlsym"]; 
    }
    subgraph clusterBACKEND {
            label="Backend"
            style=dashed; 
            func[label="float func(...)"]; 
    };
    nodeA -> wrapper; 
    real -> func[weight=10];  
    func->real[color=blue]; 
}

This results in enter image description here

The problems are now:

  • The egdes between real and func overlap. How can I separate them that they are easy to recognize.
  • Why has the edge from wrapper to real the wrong direction?
Was it helpful?

Solution

The answer to your first question has already been given elsewhere here on Stackoverflow, what it boils down to is you can either use ports postions or use the trick mentioned by the infamous marapet to add an extra edge in the same direction, remove it's constraint and reverse the edge's direction and hide the edge pointing back.

Or to put it in code:

real -> func [weight=10]                    // Remains unaltered  
real -> func [constraint=false, dir=back]   // Remove the constraint and reverse the edge
func -> real [style=invis]                  // Hide the edge pointing pack

As to why the other edge is pointing in the wrong direction, this has to do with a bug in relation to constraint and should be fixed in version 2.27. You may be working with an older version. (I know I am, as a lot of *NIX package managers still have 2.26.X by default).

To fix this you will either need to manually update your Graphviz to a newer version or (if you already have a newer version or can't/don't want to update) add dir=back to that nodes attribute.

Putting everything together the result is this:

enter image description here

Using the following DOT code:

digraph LINK { 
    rankdir=LR; 
    ranksep=0.65;
    nodesep=0.40;
    splines=false; 
    overlap=false;
    concentrate=false; 
    node[shape=box]; 
    subgraph clusterAPP {
            label="Application"; 
            style=dashed; 
            nodeA[label="d = func(...);"]; 

    }; 
    subgraph clusterFB{
            color=red;
            label="Wrapper"; 
            style=dashed; 
            rank=same; 
            wrapper[label="wrapper"]; 
            real[label="pointer to\nreal func"]; 
    }
    subgraph clusterBACKEND {
            label="Backend"
            style=dashed; 
            func[label="float func(...)"]; 
    };

    nodeA -> wrapper; 
    wrapper -> real [constraint=false, dir=back, label="dlopen\ndlsym"];  // Added reverse direction
    real -> func [weight=10]                    // Remains unaltered  
    real -> func [constraint=false, dir=back]   // Remove the constraint and reverse the edge
    func -> real [style=invis]                  // Hide the edge pointing pack

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top