graphviz - Graphviz 中的循环列表?或如何弯曲边缘
问题描述
我一直在尝试在 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];
}
解决方案
你需要一些辅助节点(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 表格标签并将图像添加到其中一个单元格来做尾部交叉
推荐阅读
- gremlin - Cosmos DB:图形 - 查询所有嵌套的顶点和边
- ios - 在表格视图单元格中放置多个项目时遇到问题
- database - Amazon DocumentDB 无法连接并出现错误“SSL 对等证书验证失败”
- javascript - React JS纸牌游戏,计数状态值
- android - 调用相机应用程序(权限拒绝:启动 Intent )
- excel - While 函数 - 根据变量迭代地添加天/月,占每个月的最大天数
- html - 为什么我的引导网格有太多边距?
- javascript - 如何在百里香中解析正则表达式?
- c# - 提交代码后从另一个页面关闭 iframe
- javascript - 我正在创建一个密码生成器并且在 javascript 上遇到了一些问题