使用Graphviz/yed生成时间线+;图表

使用Graphviz/yed生成时间线+;图表,graphviz,Graphviz,我有一个想法,表示类似于家谱的东西,其中节点通过有向图连接,但在y轴上增加额外的时间维度。想象一下,页面顶部代表1900,一直到底部是2020 在Graphviz或yed中有没有这样的方法?基本上自动布局指定的有向图,但y轴上节点的位置与时间相关?以下是shells.gv-源的一部分: digraph shells { size="7,8"; node [fontsize=24, shape = plaintext]; 1972 -> 1976; 197

我有一个想法,表示类似于家谱的东西,其中节点通过有向图连接,但在y轴上增加额外的时间维度。想象一下,页面顶部代表1900,一直到底部是2020


在Graphviz或yed中有没有这样的方法?基本上自动布局指定的有向图,但y轴上节点的位置与时间相关?

以下是shells.gv-源的一部分:

digraph shells {
    size="7,8";
    node [fontsize=24, shape = plaintext];

    1972 -> 1976;
    1976 -> 1978;
    1978 -> 1980;
    1980 -> 1982;
    1982 -> 1984;
    1984 -> 1986;
    1986 -> 1988;
    1988 -> 1990;
    1990 -> future;

    node [fontsize=20, shape = box];
    { rank=same;  1976 Mashey Bourne; }
    { rank=same;  1978 Formshell csh; }
    { rank=same;  1980 esh vsh; }
    { rank=same;  1982 ksh "System-V"; }
    { rank=same;  1984 v9sh tcsh; }
    { rank=same;  1986 "ksh-i"; }
    { rank=same;  1988 KornShell Perl rc; }
    { rank=same;  1990 tcl Bash; }
    { rank=same;  "future" POSIX "ksh-POSIX"; }

    Thompson -> Mashey;
    Thompson -> Bourne;
    Thompson -> csh;
    csh -> tcsh;
    Bourne -> ksh;
    Bourne -> esh;
    Bourne -> vsh;
    Bourne -> "System-V";
    Bourne -> v9sh;
    v9sh -> rc;
    Bourne -> Bash;
    "ksh-i" -> Bash;
    KornShell -> Bash;
    esh -> ksh;
    vsh -> ksh;
    Formshell -> ksh;
    csh -> ksh;
    KornShell -> POSIX;
    "System-V" -> POSIX;
    ksh -> "ksh-i";
    "ksh-i" -> KornShell;
    KornShell -> "ksh-POSIX";
    Bourne -> Formshell;

    edge [style=invis];
    1984 -> v9sh -> tcsh ;
    1988 -> rc -> KornShell;
    Formshell -> csh;
    KornShell -> Perl;
}
制作此文件:

在Graphviz中需要的图形非常简单,只需打开
dir=TD
,将节点分成子图,并在其中使用
rank=same
强制它们处于同一级别

棘手的部分可能是在示例中实现
Z
节点。您可以在标签中使用类似HTML的表来完成。示例图片的完整graphviz解释如下所示:

digraph  {
    node [shape=rect style=filled fillcolor="#d2deee" fontname="Arial"]
    edge [color="#658bb2"]
    dir = TD
    1900 -> 1950 -> 2020 [style=invis]
    subgraph 1900 {
        rank=same
        1900 [
            fillcolor="#efefef"
            fontcolor="#182697"
            fontname="Arial bold"
        ]
        A
    }
    subgraph 1950 {
        rank=same
        1950 [
            fillcolor="#efefef"
            fontcolor="#182697"
            fontname="Arial bold"
        ]
        B
    }
    subgraph 2020 {
        rank=same
        2020 [
            fillcolor="#efefef"
            fontcolor="#182697"
            fontname="Arial bold"
        ]
        C
    }
    Z [
        shape=plain
        label=<
            <table cellspacing="0">
                <tr>
                    <td cellpadding="15" border="0" width="70" port="p1"></td>
                    <td border="0">Z</td>
                    <td cellpadding="15" border="0" width="70" port="p2"></td>
                </tr>
            </table>
        >
    ]
    A -> Z:p1
    B -> Z:p2
    Z -> C
    C
}
有向图{
节点[shape=rect style=fillcolor=“#d2deee”fontname=“Arial”]
边缘[color=“#658bb2”]
dir=TD
1900->1950->2020[style=invi]
子图1900{
等级=相同
1900 [
fillcolor=“#efefef”
fontcolor=“#182697”
fontname=“Arial粗体”
]
A.
}
子图1950{
等级=相同
1950 [
fillcolor=“#efefef”
fontcolor=“#182697”
fontname=“Arial粗体”
]
B
}
子图2020{
等级=相同
2020 [
fillcolor=“#efefef”
fontcolor=“#182697”
fontname=“Arial粗体”
]
C
}
Z[
形状=普通
标签=<
Z
>
]
A->Z:p1
B->Z:p2
Z->C
C
}
这将使您:


好极了!这几乎正是我想要的。一个简单的问题:我看到您使用“秩”属性来保持水平对齐,但在接近终点时,我看到一些不可见边的使用?这两者的目的是相同的吗?我发布了一个相关的问题:我不能为这张图打分,我只知道在哪里可以找到它。我认为不可见边有助于管理子图中的节点放置。把它们评论出来,看看有什么变化没关系。知道该往哪里看是值得表扬的!:)