使用点记录节点表示带索引的数组(Graphviz)

时间:2016-06-22 13:19:58

标签: graphviz dot

我使用Graphviz来表示数组,使用subgraphsrecord个节点:

subgraph cluster_array
{
    label="my array"
    Array [shape="record", label="A | B | C | D"]
    Array
}

我想为每个数组元素添加外部索引,映射0 -> A1 -> B等等。

我想达到类似的结果:

enter image description here

我已在线搜索并尝试使用xlabel,但无法找到为每个记录元素正确添加标签的方法。我还尝试将索引作为标签的一部分,并使用lp移动标签,但它似乎对record节点没有影响。

是否可以使用GraphViz向record个节点添加外部元素标签?

1 个答案:

答案 0 :(得分:3)

对你的问题不是一个真正的答案(我认为,这将是"没有")但是一种可能会给你你想要的解决方法。我使用" parallel"没有边框的记录节点(或确切地说是纸张颜色边框),位于非常靠近并由不可见边连接:

digraph so
{
    subgraph cluster0
    {
        rank = same{ Array notes }
        color = white;
        Array [ shape = record, label = "{ A | B | C | D }"] ;
        notes [ shape = record, color = white, label = "{ a_1 | b_2 | c_3 | d_4 }" ];
        Array -> notes[ style = invis ];
    }
    nodesep = .0;
    X -> Array -> Z;
}

产生

enter image description here

相关问题