【问题标题】:Graphviz Dot Edge Ports for Family Tree用于家谱的 Graphviz 点边缘端口
【发布时间】:2018-02-05 21:35:15
【问题描述】:

非常能够生成看起来并不可怕的家谱,但我遇到了以下问题。

//file: tree.dot
digraph {
    edge [dir=none];
    node [
        fillcolor="black",fixedsize=true,shape=box,
        style="rounded,filled",width=2.0
    ];
    splines=ortho;
    // GEN -01
    {
        rank=same; rankdir=LR;
        "Grandfather" [regular=0];
        m0002 [
            label="",shape=diamond,regular=0,height=0.25,
            width=0.25,style="filled",
        ];
        "Grandmother" [regular=0];
        {
            rank=same; rankdir=LR;
            "Grandfather" -> m0002 -> "Grandmother";
        }
    }
    m0002 -> c0001;
    // GEN  00
    {
        rank=same; rankdir=LR;
        c0000 [
            label="",shape=circle, regular=0, height=0.05,
            width=0.05,style="filled"
        ];
        c0001 [
            label="",shape=circle, regular=0, height=0.05,
            width=0.05,style="filled"
        ];
        c0002 [
            label="",shape=circle, regular=0, height=0.05,
            width=0.05, style="filled"
        ];
        {
            rank=same; rankdir=LR;
            c0000 -> c0001 -> c0002;
        }
    }
    {
        rank=same; rankdir=LR;
        "Son 1" [regular=0];
        "Daughter 1" [regular=0];
        "Son 2" [regular=0];
        m0000 [
            label="",shape=diamond,regular=0,height=0.25,
            width=0.25,style="filled"
        ];
        "Other Daughter 1" [regular=0];
        "Other Son 1" [regular=0];
        "Other Other Son 1" [regular=0];
        m0001 [
            label="",shape=diamond,regular=0,height=0.25,
            width=0.25, style="filled"
        ];
        "Other Daughter 2" [regular=0];
        {
            rank=same; rankdir=LR;
            "Son 2" -> m0000 -> "Other Daughter 1";
            "Other Other Son 1" -> m0001 -> "Other Daughter 2";
        }
    }
    c0000 -> "Son 1";
    c0001 -> "Daughter 1";
    c0002 -> "Son 2";
}

上面的代码生成this image,它与Son 1Son 2的边缘看起来很奇怪。我用dot -Tpng tree.dot 运行它。当我运行相同的代码here 时,我得到expected output

我做错了吗?如何在不使用 Web 界面的情况下获得预期的输出(我可能有数百个节点)?换句话说,我怎样才能让 c0000c0002Son 1Son 2 的中心对齐> 分别使它们的边缘连接到节点的中心顶部?

提前感谢您的帮助!

【问题讨论】:

标签: tree graphviz dot graph-visualization


【解决方案1】:

您可以使用端口指定边缘连接的位置,这些端口使用罗盘方向,n、s、e、w、nw、ne、sw、se。

将点文件末尾的以下行更改为包含端口。

    c0000 -> "Son 1" [headport=ne];
    c0002 -> "Son 2":nw; // Shorthand for [headport=nw]

此图像中的结果

这不会使边缘处于死点,并且将端口位置更改为n 不起作用。但它不再像原来的那样有指向空角的边缘。 GraphViz 实用程序的一部分是自动布局,但有时它似乎会覆盖用户决策(或者是一个错误)。

【讨论】:

  • 是的,我也试过了;它更好,但仍然不完美。我也尝试过为splines 使用不同的参数,但没有运气。
猜你喜欢
  • 2015-09-19
  • 1970-01-01
  • 2011-01-17
  • 2012-10-05
  • 1970-01-01
  • 2012-10-10
  • 1970-01-01
  • 2010-12-03
  • 2012-07-02
相关资源
最近更新 更多