ink*_*994 4 tree dot graphviz graph-visualization
我非常接近能够生成一个看起来并不糟糕的家谱,但我遇到了以下问题。
//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";
}
Run Code Online (Sandbox Code Playgroud)
上面的代码生成了这个图像,它的Son 1和Son 2的边缘看起来很奇怪。我用 运行它dot -Tpng tree.dot。当我在这里运行相同的代码时,我得到了预期的输出。
难道我做错了什么?如何在不使用 Web 界面的情况下获得预期的输出(我可能有数百个节点)?换句话说,如何让c0000和c0002分别与Son 1和Son 2的中心对齐,以便它们的边缘连接到节点的中心顶部?
在此先感谢您的帮助!
您可以使用使用罗盘方向 n、s、e、w、nw、ne、sw、se 的端口指定边缘的连接位置。
更改点文件末尾的以下行以包含端口。
c0000 -> "Son 1" [headport=ne];
c0002 -> "Son 2":nw; // Shorthand for [headport=nw]
Run Code Online (Sandbox Code Playgroud)
结果在这张图片中
这不会将边缘置于死点,并且将端口位置更改为n不起作用。但它不再像原来那样有指向空角的边缘。GraphViz 实用程序的一部分是自动布局,但有时它似乎会覆盖用户的决定(或者是一个错误)。