Question

I am using DOT to generate a directed graph like the one shown below. I want all edges to have a south tailport and an north headport so all the edges originate from the bottom of a node and go into the top of a node.

As you can see from the image on the left, the edges from node 2 to both 4 and 6 go straight up along the side of the nodes and doesn't look great, I would have hoped the layout would have routed the edges away from the nodes (like my image on the right)

How can I get edges routed away from nodes?

Example graph:

enter image description here

My DOT file for the above graph is as follows:

digraph g {
graph [
    center=true,
    nodesep=1.2,
    ranksep="1.2 equally",
    sep=6.2,
    splines=polyline
];
node [label="\N"];
0    [area=2,
    fixedsize=true,
    height=0.69444,
    label=0,
    margin=1.2,
    shape=box,
    width=1.3889];
1    [area=2,
    fixedsize=true,
    height=1.3889,
    label=1,
    margin=1.2,
    shape=box,
    width=1.3889];
0:s -> 1:n;
2    [area=2,
    fixedsize=true,
    height=1.3889,
    label=2,
    margin=1.2,
    shape=box,
    color="blue",
    width=1.3889];
0:s -> 2:n;
3    [area=2,
    fixedsize=true,
    height=0.69444,
    label=3,
    margin=1.2,
    shape=box,
    width=1.3889];
0:s -> 3:n;
4    [area=2,
    fixedsize=true,
    height=0.69444,
    label=4,
    margin=1.2,
    shape=box,
    color="red",
    width=1.3889];
1:s -> 4:n;
2:s -> 4:n;
6    [area=2,
    fixedsize=true,
    height=1.3889,
    label=6,
    margin=1.2,
    shape=box,
    color="red",
    width=1.3889];
2:s -> 6:n;
5    [area=2,
    fixedsize=true,
    height=0.69444,
    label=5,
    margin=1.2,
    shape=box,
    width=1.3889];
4:s -> 5:n;
4:s -> 6:n;
7    [area=2,
    fixedsize=true,
    height=0.69444,
    label=7,
    margin=1.2,
    shape=box,
    width=1.3889];
5:s -> 7:n;
6:s -> 7:n;
6:s -> 2:n;
7:s -> 7:n;
8    [area=2,
    fixedsize=true,
    height=0.69444,
    label=8,
    margin=1.2,
    shape=box,
    width=1.3889];
7:s -> 8:n;
}
Was it helpful?

Solution

I was able to get the separation you want between the node and the edge line with spines=spline but it makes the edge lines curvy instead of straight.

graph [
    center=true,
    nodesep=1.2,
    ranksep="1.2 equally",
    sep=6.2,
    splines=spline
];

enter image description here

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