【问题标题】:Graphviz Linked list arrow tail originGraphviz 链表箭头尾原点
【发布时间】:2013-03-19 20:37:30
【问题描述】:

我想画一个垂直对齐的链表,就像来自 Wikimedia Commons 的链表:

到目前为止我最好的镜头是:

digraph foo {
        rankdir=LR;
        node [shape=record];
        a [label="{ <data> 12 | <ref> }"]
        b [label="{ <data> 99 | <ref> }"];
        c [label="{ <data> 37 | <ref> }"];
        d [shape=box];
        a:ref -> b:data [arrowhead=vee, arrowtail=dot, dir=both];
        b:ref -> c:data [arrowhead=vee, arrowtail=dot, dir=both];
        c:ref -> d      [arrowhead=vee, arrowtail=dot, dir=both];
}

这给出了:

如何将箭头点设置为源自记录内,并将d 记录设置为X 节点?

我试过tailclip=false,但没有成功。

【问题讨论】:

标签: linked-list graphviz


【解决方案1】:

您需要设置tailclip=false 并且为边缘的尾端指定一个罗盘点

digraph foo {
        rankdir=LR;
        node [shape=record];
        edge [tailclip=false];
        a [label="{ <data> 12 | <ref> }"]
        b [label="{ <data> 99 | <ref> }"];
        c [label="{ <data> 37 | <ref> }"];
        d [shape=box];
        a:ref:c -> b:data [arrowhead=vee, arrowtail=dot, dir=both];
        b:ref:c -> c:data [arrowhead=vee, arrowtail=dot, dir=both];
        c:ref:c -> d      [arrowhead=vee, arrowtail=dot, dir=both];
}

很遗憾,最后一个节点所需的形状不包含在可用的default shapes 中。您可以使用 postscript 或位图图像添加 custom shape,如果使用 SVG 输出,甚至可以添加 SVG

【讨论】:

  • 我注意到 X 也不是标准的箭头形状。有这个聪明的主意。一些作者只是在空节点的框中使用“NULL”这个词而不是一个叉号。如果我这十年写过 PostScript 代码,我会为您制作一个足以满足自定义节点形状的 EPS 文件。
  • 根据您需要的输出,您可以使用 SVG 制作一些好看的东西。否则,只需将一个巨大的 X 放入一个框中,更改该节点的字体及其大小......我知道这是一个 hack :(
  • 啊哈,我认为使用 Inkscape 等矢量图形编辑器创建自定义节点形状所需的 EPS 文件既简单又实用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多