Проблема с графвизом никогда не завершается
Может ли кто-нибудь помочь мне понять, почему следующий график никогда не генерирует точки? Я думаю, что проблема как-то связана с портом и портом. Это сработает, если я достану их, но в идеале я хочу, чтобы они остались по стилистическим соображениям.
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];
}
}
3 ответа
Не тратя много времени на копание источников, трудно сказать почему, но вы можете убрать проблемные элементы из второго подграфа, чтобы решить проблему:
Удалите 1->9 и 2->8 из неориентированного подграфа и добавьте их под ним:
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"];
}
Трудно понять, что вы после. Однако у графа есть некоторые проблемы:
- Узлы не могут быть частью нескольких подграфов - они либо на графике, либо на подграфе, где бы они ни появлялись первыми. Где твои должны появиться?
rankdir
является атрибутом графика и не может быть применен к подграфу
редактировать
В продолжение вашего комментария, вот версия без каких-либо подграфов. Тем не менее, вам не понравится маршрутизация ребер, что будет трудно контролировать.
Идея состоит в том, чтобы выровнять узлы по прямой линии, а затем добавить другие ребра с constraint=false
чтобы они не влияли на ранжирование узлов.
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;
}
К сожалению, это связано с давней ошибкой, связанной с некоторыми ребрами, для которых указаны оба порта:
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).
Есть два ребра, которые, кажется, затрагивают эту ошибку ( 4->8 и 1->9 ). Граф создается правильно, если для этих двух ребер установлено [tailport=""].