Graphviz 中的循环列表?或者如何弯曲边缘
Circular list in Graphviz? or how to bend the edge
我一直在尝试做我认为在 Graphviz 中很简单的事情,像这样:
(taken from https://tex.stackexchange.com/questions/394432/how-to-draw-circular-linked-list)
我正在尝试用 Graphviz 做一些类似的事情,这就是它现在的样子:
我阅读了文档并尝试使用 neato 和 circo 图但没有成功....我怎样才能按照我需要的方式弯曲边缘?我现在可以尝试使用坐标,例如 p3:e -> p1:w
,但这会从记录的中间删除起点。
到目前为止,这是我的代码:
digraph {
node[shape=record];
graph[pencolor=transparent];
rankdir=LR;
p1[label="{<data> 12|<next>}"];
p2[label="{<data> 99|<next>}"];
p3[label="{<data> 37|<next>}"];
edge[tailclip=false,arrowtail=dot,dir=both];
p1:next:c -> p2:data;
p2:next:c -> p3:data;
p3:next:c -> p1:data[constraint=false];
}
您需要一些辅助节点(p0 和 p4)
digraph {
node[shape=record];
graph[pencolor=transparent];
rankdir=LR;
p1[label="{<data> 12|<next>}"];
p2[label="{<data> 99|<next>}"];
p3[label="{<data> 37|<next>}"];
edge[tailclip=false,arrowtail=dot,dir=both];
{node[shape=point height=0] p0 p4} // make p0 and p4 to small to see
p0:n -> p1[arrowtail=none]
p0:s -> p4:s[dir=none] // add edge with no arrow to make it look like one long edge, also make p0 the tail so we don't have a recursition that may course dot to rearange the nodes
p1:next:c -> p2:data;
p2:next:c -> p3:data;
//p3:next:c -> p1:data[constraint=false];
p3:next:c -> p4:n[arrowhead=none]
}
您可以通过使用 html table 标签并在其中一个单元格中添加图像来在尾部画十字
我一直在尝试做我认为在 Graphviz 中很简单的事情,像这样:
我正在尝试用 Graphviz 做一些类似的事情,这就是它现在的样子:
我阅读了文档并尝试使用 neato 和 circo 图但没有成功....我怎样才能按照我需要的方式弯曲边缘?我现在可以尝试使用坐标,例如 p3:e -> p1:w
,但这会从记录的中间删除起点。
到目前为止,这是我的代码:
digraph {
node[shape=record];
graph[pencolor=transparent];
rankdir=LR;
p1[label="{<data> 12|<next>}"];
p2[label="{<data> 99|<next>}"];
p3[label="{<data> 37|<next>}"];
edge[tailclip=false,arrowtail=dot,dir=both];
p1:next:c -> p2:data;
p2:next:c -> p3:data;
p3:next:c -> p1:data[constraint=false];
}
您需要一些辅助节点(p0 和 p4)
digraph {
node[shape=record];
graph[pencolor=transparent];
rankdir=LR;
p1[label="{<data> 12|<next>}"];
p2[label="{<data> 99|<next>}"];
p3[label="{<data> 37|<next>}"];
edge[tailclip=false,arrowtail=dot,dir=both];
{node[shape=point height=0] p0 p4} // make p0 and p4 to small to see
p0:n -> p1[arrowtail=none]
p0:s -> p4:s[dir=none] // add edge with no arrow to make it look like one long edge, also make p0 the tail so we don't have a recursition that may course dot to rearange the nodes
p1:next:c -> p2:data;
p2:next:c -> p3:data;
//p3:next:c -> p1:data[constraint=false];
p3:next:c -> p4:n[arrowhead=none]
}
您可以通过使用 html table 标签并在其中一个单元格中添加图像来在尾部画十字