使用点记录节点以图形表示带有索引的数组(Graphviz) [英] Represent array with indices using dot record nodes (Graphviz)

查看:241
本文介绍了使用点记录节点以图形表示带有索引的数组(Graphviz)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Graphviz来表示数组,并使用subgraphsrecord节点:

I'm using Graphviz to represent arrays, using subgraphs and record nodes:

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

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

I would like to add external indices for each array elements, mapping 0 -> A, 1 -> B and so on.

我想获得类似于以下结果:

I want to achieve a result similar to:

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

I've searched online and tried using xlabel but couldn't find a way to correctly add a label for each record element. I've also tried making the indices part of the label, and moving the label with lp, but it seems to have no effect on record nodes.

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

Is it possible to add external element labels to record nodes using GraphViz?

推荐答案

这不是您问题的真实答案(我认为这是否"),但是可以解决您的问题.我使用一个无边界(准确地说是纸色边界)的平行"记录节点,该节点非常靠近并由不可见的边缘连接:

Not a real answer to your question (which, I think, would be "no") but a workaround that may give you what you want. I use a "parallel" record node with no borders (or paper color borders, to be exact), located very close and connected by an invisible edge:

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;
}

产生

这篇关于使用点记录节点以图形表示带有索引的数组(Graphviz)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆