我正在尝试使用 Dot/Graphviz 从数据库中生成家谱可视化。第一个结果看起来很有希望,但有一个布局问题我还不能解决。
当我使用下面列出的代码时,它会产生
我对此非常满意。但是一旦我尝试在 F4/M4/M5 和 F2/M2 家族之间添加另一个节点,这可以通过在下面的代码中取消注释两行来完成,它会给我
现在将 Male2 放置在远离 Female2 且位于 Female4 和 Male4 之间的位置。因此,F2/M2 和 F4/M4/M5 家族彻底分裂。我尝试增加家庭连接的权重(值为 100)以确保家庭 F2/M2 和 F4/M4/M5 放在一起,但这不起作用。到目前为止,更改节点或连接的顺序也没有帮助。最好的解决方案是,如果 F4/M4/M5 系列可以放在左侧,MaleX 放在中间,F2/M2 系列放在右侧。
有人有建议吗?我宁愿不更改代码中定义节点和连接的顺序,因为这是由脚本完成的,并且是由数据库结构预定义的。
graph Test {
rankdir = BT;
splines = ortho;
center = true;
{
rank = same;
NodeFemale1 [label = Female1];
NodeMale1 [label = Male1];
ConnectionFemale1Male1 [shape = box, label = "", height = 0, width = 1, margin = 0, penwidth = 1];
NodeFemale1 -- ConnectionFemale1Male1 -- NodeMale1 [weight = 100, penwidth = 2];
}
ConnectionChildren11 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
ConnectionFemale1Male1 -- ConnectionChildren11 [penwidth = 2];
{
rank = same;
NodeFemale2 [label = Female2];
NodeMale2 [label = Male2];
ConnectionFemale2Male2 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
NodeFemale2 -- ConnectionFemale2Male2 -- NodeMale2 [weight = 100, penwidth = 2];
}
ConnectionChildren11 -- NodeMale2 [penwidth = 2];
ConnectionChildren22 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
ConnectionFemale2Male2 -- ConnectionChildren22 [penwidth = 2];
NodeMale3 [label = Male3];
ConnectionChildren22 -- NodeMale3 [weight = 10, penwidth = 2];
NodeFemale3 [label = Female3];
ConnectionChildren22 -- NodeFemale3 [penwidth = 2];
// NodeMaleX [label = MaleX];
// ConnectionChildren11 -- NodeMaleX [weight = 10, penwidth = 2];
{
rank = same;
NodeFemale4 [label = Female4];
NodeMale4 [label = Male4];
NodeMale5 [label = Male5];
ConnectionFemale4Male4 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
NodeFemale4 -- ConnectionFemale4Male4 -- NodeMale4 [weight = 100, penwidth = 2];
ConnectionMale4Male5 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
NodeMale4 -- ConnectionMale4Male5 -- NodeMale5 [weight = 100, penwidth = 2];
}
ConnectionChildren11 -- NodeFemale4 [penwidth = 2];
ConnectionChildren44 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
ConnectionFemale4Male4 -- ConnectionChildren44 [penwidth = 2];
NodeFemale6 [label = Female6];
ConnectionChildren44 -- NodeFemale6 [weight = 10, penwidth = 2];
NodeFemale7 [label = Female7];
ConnectionChildren44 -- NodeFemale7 [penwidth = 2];
ConnectionChildren45 [shape = box, label = "", height = 0, width = 0, margin = 0, penwidth = 1];
ConnectionMale4Male5 -- ConnectionChildren45 [penwidth = 2];
NodeFemale8 [label = Female8];
ConnectionChildren45 -- NodeFemale8 [penwidth = 2];
}