家谱的 Graphviz 点边缘端口 [英] Graphviz Dot Edge Ports for Family Tree

查看:15
本文介绍了家谱的 Graphviz 点边缘端口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

//文件:tree.dot有向图{边缘 [dir=none];节点 [fillcolor="black",fixedsize=true,shape=box,样式=圆形,填充",宽度= 2.0];样条=正交;//GEN -01{等级=相同;等级目录=LR;祖父"[常规=0];m0002 [label="",shape=diamond,regular=0,height=0.25,宽度=0.25,样式=填充",];祖母"[常规=0];{等级=相同;等级目录=LR;祖父"->m0002 ->祖母";}}m0002 ->c0001;//第 00 代{等级=相同;等级目录=LR;c0000 [标签=",形状=圆形,规则=0,高度=0.05,宽度=0.05,样式=填充"];c0001 [标签=",形状=圆形,规则=0,高度=0.05,宽度=0.05,样式=填充"];c0002 [标签=",形状=圆形,规则=0,高度=0.05,宽度=0.05,样式=填充"];{等级=相同;等级目录=LR;c0000 ->c0001 ->c0002;}}{等级=相同;等级目录=LR;"儿子 1" [常规 = 0];女儿1"[常规=0];"儿子 2" [常规 = 0];m0000 [label="",shape=diamond,regular=0,height=0.25,宽度=0.25,样式=填充"];其他女儿1"[常规=0];其他儿子 1" [常规 = 0];其他其他儿子 1" [常规 = 0];m0001 [label="",shape=diamond,regular=0,height=0.25,宽度=0.25,样式=填充"];《其他女儿2》[普通=0];{等级=相同;等级目录=LR;儿子 2"->m0000 ->其他女儿1";其他儿子 1"->m0001 ->《其他女儿2》;}}c0000 ->儿子1";c0001 ->女儿1";c0002 ->儿子2";}

上面的代码产生

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

I am very close to being able to generate a family tree that doesn't look terrible, but I'm running into the following problem.

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

The above code produces this image, which has edges to Son 1 and Son 2 that look weird. I ran it with dot -Tpng tree.dot. When I run the same code here, I get the expected output.

Am I doing something wrong? How can I get the expected output without using the web interface (I will have potentially hundreds of nodes)? In other words, how can I get c0000 and c0002 to line up with the center of Son 1 and Son 2, respectively, so that their edges attach to the center top of the nodes?

Thanks in advance for your help!

解决方案

You can specify where the edge connects using ports which use compass directions, n, s, e, w, nw, ne, sw, se.

Changing the following lines at the end of your dot file to include ports.

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

results in this image

This doesn't put the edges dead center, and changing the port locations to n doesn't work. But it no longer has edges pointing to an empty corner like your original. Part of GraphViz's utility is the autolayout but sometimes it seems to override user decisions (or is a bug).

这篇关于家谱的 Graphviz 点边缘端口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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