我确实玩了很多,我认为没有完美的解决方案。有一些方法。
带有额外不可见边和节点的经典方法。这适用于小图,但在大图上变得非常难看。为确保这是可行的,您必须用不可见的节点填充整个网格。否则点引擎会否决你。
我期望解决的是这种方法
digraph {
edge [weight=1]
0->L
0->R
edge [weight=10]
L->LL
L->LR
R->RL
R->RR
edge [weight=100]
LL->LLL
LL->LLR
LR->LRL
LR->LRR
RL->RLL
RL->RLR
RR->RRL
RR->RRR
}
不幸的是,它没有。似乎点布局引擎试图最小化的不是边缘长度,而是水平部分,即子节点之间的任何父位置都被认为是理想的。
我试过的另一个是
digraph {
splines=line
style=dotted
edge [weight=1]
subgraph cluster_0 {
subgraph cluster_L {
subgraph cluster_LL {
LLL
LLM [style=dotted]
LLR
LL->LLL
LL->LLM [style=dotted weight=100]
LL->LLR
}
LM [style=dotted]
subgraph cluster_LR {
LRL
LRM [style=dotted]
LRR
LR->LRL
LR->LRM [style=dotted weight=100]
LR->LRR
}
L->LL
L->LM [style=dotted weight=100]
L->LR
}
M [style=dotted]
subgraph cluster_R {
subgraph cluster_RL {
RLL
RLM [style=dotted]
RLR
RL->RLL
RL->RLM [style=dotted weight=100]
RL->RLR
}
RM [style=dotted]
R->RL
R->RM [style=dotted weight=100]
R->RR
}
0->L
0->M [style=dotted weight=100]
0->R
}
}
这给了
似乎确实可行,水平顺序取决于外观。但是集群在许多其他结构中表现不佳,您必须尝试它是否适合您。
如果您省略集群,布局将横向更紧凑。不可见的中间节点仍然会阻止垂直边缘。
digraph {
splines=line
style=dotted
edge [weight=1]
LLL
LLM [style=dotted]
LLR
LL->LLL
LL->LLM [style=dotted weight=100]
LL->LLR
LM [style=dotted]
LRL
LRM [style=dotted]
LRR
LR->LRL
LR->LRM [style=dotted weight=100]
LR->LRR
L->LL
L->LM [style=dotted weight=100]
L->LR
M [style=dotted]
RLL
RLM [style=dotted]
RLR
RL->RLL
RL->RLM [style=dotted weight=100]
RL->RLR
RM [style=dotted]
R->RL
R->RM [style=dotted weight=100]
R->RR
0->L
0->M [style=dotted weight=100]
0->R
}
给了
最后剩下一件事,ERG 用于树布局的 gvpr 脚本。您可以在 marapets 中找到详细信息,回复此question。