Reputation: 1
Can someone help me figure out why the following graph never generates in dot? I think the problem has something to do with the headport and tailport. It works if I take those out, but ideally I want those to stay for stylistic reasons.
digraph G {
nodesep = 0.5;
0 [width=0.75, height=0.75, fontsize=20];
1 [width=0.75, height=0.75, fontsize=20, shape=square];
2 [width=0.75, height=0.75, fontsize=20];
3 [width=0.75, height=0.75, fontsize=20];
4 [width=0.75, height=0.75, fontsize=20];
5 [width=0.75, height=0.75, fontsize=20, shape=square];
6 [width=0.75, height=0.75, fontsize=20];
7 [width=0.75, height=0.75, fontsize=20, shape=square];
8 [width=0.75, height=0.75, fontsize=20, shape=square];
9 [width=0.75, height=0.75, fontsize=20, shape=square];
10 [width=0.75, height=0.75, fontsize=20, shape=square];
11 [width=0.75, height=0.75, fontsize=20, shape=square];
12 [width=0.75, height=0.75, fontsize=20];
subgraph directed{
rankdir= LR;rank= max;
0->1->2->3->4->5->6->7->8->9->10->11->12;
}
subgraph undirected{
rankdir= LR;rank= min;edge[tailport=n,headport=n];
0->1[dir=none, color=red];
0->2[dir=none, color=red];
1->9[dir=none, color=red];
2->3[dir=none, color=red];
2->8[dir=none, color=red];
3->4[dir=none, color=red];
4->8[dir=none, color=red];
7->9[dir=none, color=red];
8->9[dir=none, color=red];
9->10[dir=none, color=red];
9->11[dir=none, color=red];
10->11[dir=none, color=red];
}
}
Upvotes: 0
Views: 167
Reputation: 6801
Unfortunately, this is hitting a long-standing bug related to certain edges that have both ports specified:
Warning: Unable to reclaim box space in spline routing for edge "4" -> "8". Something is probably seriously wrong.
Warning: Unable to reclaim box space in spline routing for edge "1" -> "9". Something is probably seriously wrong.
(https://gitlab.com/graphviz/graphviz/-/issues/241).
There are two edges that seem to hit this bug (4->8 & 1->9). The graph is correctly produced if [tailport=""] is set for these two edges.
Upvotes: 0
Reputation: 56566
Difficult to know what you are after. However, the graph has some problems:
rankdir
is a graph attribute and cannot be applied to a subgraphEdit
Following up on your comment, here's a version without any subgraphs. However, you won't like the routing of the edges, something which will be difficult to control.
The idea is to align the nodes in a straight line, then add the other edges with constraint=false
in order to not have them influence the ranking of the nodes.
digraph G {
nodesep = 0.5;
node[width=0.75, height=0.75, fontsize=20];
rankdir=LR;
0;
1 [shape=square];
2;
3;
4;
5 [shape=square];
6;
7 [shape=square];
8 [shape=square];
9 [shape=square];
10 [shape=square];
11 [shape=square];
12;
0->1->2->3->4->5->6->7->8->9->10->11->12;
edge[constraint=false, tailport=n,headport=n,dir=none, color=red];
0->1;
0->2;
1->9;
2->3;
2->8;
3->4;
4->8;
7->9;
8->9;
9->10;
9->11;
10->11;
}
Upvotes: 0
Reputation: 2031
Without spending a lot of time digging through the sources, it'd be difficult to say why, but you can move the troublesome elements out of the second subgraph to fix the problem:
Remove 1->9 and 2->8 from the undirected subgraph, and add them below it:
digraph G {
nodesep = 0.5;
0 [width=0.75, height=0.75, fontsize=20];
1 [width=0.75, height=0.75, fontsize=20, shape=square];
2 [width=0.75, height=0.75, fontsize=20];
3 [width=0.75, height=0.75, fontsize=20];
4 [width=0.75, height=0.75, fontsize=20];
5 [width=0.75, height=0.75, fontsize=20, shape=square];
6 [width=0.75, height=0.75, fontsize=20];
7 [width=0.75, height=0.75, fontsize=20, shape=square];
8 [width=0.75, height=0.75, fontsize=20, shape=square];
9 [width=0.75, height=0.75, fontsize=20, shape=square];
10 [width=0.75, height=0.75, fontsize=20, shape=square];
11 [width=0.75, height=0.75, fontsize=20, shape=square];
12 [width=0.75, height=0.75, fontsize=20];
subgraph directed{
rankdir= LR;rank= max;
0->1->2->3->4->5->6->7->8->9->10->11->12;
}
subgraph undirected{
rankdir= LR;rank= min;edge[tailport=n,headport=n];
0->1[dir=none, color=red];
0->2[dir=none, color=red];
2->3[dir=none, color=red];
3->4[dir=none, color=red];
4->8[dir=none, color=red];
7->9[dir=none, color=red];
8->9[dir=none, color=red];
9->10[dir=none, color=red];
9->11[dir=none, color=red];
10->11[dir=none, color=red];
}
1->9[dir="none", color="red", headport="n"];
2->8[dir="none", color="red", headport="n"];
}
Upvotes: 0