Graphviz 点垂直对齐节点

Ore*_*lom 8 dot graphviz

我有以下 graphviz 点输入文件:

digraph structs {
rankdir = LR;
node [shape=record];
hashTable [label="<f0>0|<f1>1|<f2>2|<f3>3|<f4>4|<f5>5|<f6>6|<f7>7|<f8>8"];
node_1_0 [label="<f0> one|<f1> two |<f2> three"];
node_1_1 [label="<f0> un |<f1> deux|<f2> trois"];
struct3 [label="<f0> einz|<f1> swei|<f2> drei"];
hashTable:f1 -> node_1_0:f0;
node_1_0:f2  -> node_1_1:f0;
hashTable:f4 -> struct3:f0;
}
Run Code Online (Sandbox Code Playgroud)

渲染如下:

在此输入图像描述

如何让[one|two|third]节点与[un|deux|trois]节点垂直对齐?谢谢!

vae*_*hen 7

在评论中澄清后进行编辑:这里具有强大权重的不可见边缘有助于保持节点对齐:

digraph structs2 
{
    rankdir = LR;
    node [shape=record];
    splines=false;       // optional; gives straight lines

    hashTable [label="<f0>0|<f1>1|<f2>2|<f3>3|<f4>4|<f5>5|<f6>6|<f7>7|<f8>8"];
    node_1_0 [label="<f0> one|<f1> two |<f2> three" ];
    node_1_1 [label="<f0> un |<f1> deux|<f2> trois"];
    struct3 [label="<f0> einz|<f1> swei|<f2> drei"];

    //
    node_1_0 -> node_1_1[ style = invis, weight= 10 ];
    //                    ^^^^^^^^^^^^^^^^^^^^^^^^^

    hashTable:f1 -> node_1_0:f0;
    node_1_0:f2  -> node_1_1:f0;
    hashTable:f4 -> struct3:f0;
}
Run Code Online (Sandbox Code Playgroud)

给你你想要的(我相信):

在此输入图像描述

............

原来的答案是:

从表面上回答你的问题,这可以通过将它们置于同一等级来快速实现:

digraph structs 
{
    rankdir = LR;
    node [shape=record];

    hashTable [label="<f0>0|<f1>1|<f2>2|<f3>3|<f4>4|<f5>5|<f6>6|<f7>7|<f8>8"];
    node_1_0 [label="<f0> one|<f1> two |<f2> three"];
    node_1_1 [label="<f0> un |<f1> deux|<f2> trois"];
    struct3 [label="<f0> einz|<f1> swei|<f2> drei"];

    {rank = same; node_1_0 node_1_1 }

    hashTable:f1 -> node_1_0:f0;
    node_1_0:f2  -> node_1_1:f0;
    hashTable:f4 -> struct3:f0;
}
Run Code Online (Sandbox Code Playgroud)

屈服

在此输入图像描述

  • 对于“rankdir = LR”,水平意味着依赖顺序,因此从层次上看,右侧低于左侧。‘rank = same’表示层次上相同的级别,因此必然是垂直对齐的。 (2认同)