【发布时间】: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 1和Son 2的边缘看起来很奇怪。我用dot -Tpng tree.dot 运行它。当我运行相同的代码here 时,我得到expected output。
我做错了吗?如何在不使用 Web 界面的情况下获得预期的输出(我可能有数百个节点)?换句话说,我怎样才能让 c0000 和 c0002 与 Son 1 和 Son 2 的中心对齐> 分别使它们的边缘连接到节点的中心顶部?
提前感谢您的帮助!
【问题讨论】:
-
@greedybuddha 我以前尝试过这两种方法;两者都不起作用。
标签: tree graphviz dot graph-visualization