我一直试图在Graphviz中做我认为简单的事情,就像这样:
(摘自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];
}
答案 0 :(得分:1)
你需要一些辅助节点(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表格标签并在其中一个单元格中添加图像来完成尾部的交叉