graphviz 点:有两个集群,中间有节点
graphviz dot: have two clusters with nodes in between
我有下图
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
}
现在我想在这些集群之间添加节点并使用边连接它们:
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
do_some_stuff -> with_this -> do_that
then_do_that -> and_that -> and_some_stuff
and_other_stuff -> using_this -> and_this
}
但这并不是我预期的结果。我希望中间的节点与连接的节点处于相同的高度:让我们尝试对它们进行排名:
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
{rank=same; rankdir=LR; do_some_stuff -> with_this -> do_that}
{rank=same; then_do_that -> and_that -> and_some_stuff}
{rank=same; and_other_stuff -> using_this -> and_this}
}
嗯,它们在同一高度,但是簇消失了,中间一排的顺序错了。我该如何解决?
点布局引擎有自己的想法:-)
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
with_this -> and_that -> using_this [style=invis]
do_some_stuff -> with_this -> do_that [constraint=false]
then_do_that -> and_that -> and_some_stuff [constraint=false]
and_other_stuff -> using_this -> and_this [constraint=false]
}
给予
替代解决方案是
digraph { rankdir = LR
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
{ rank=same do_some_stuff -> and_some_stuff -> and_other_stuff }
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
{ rank=same do_that -> then_do_that -> and_this }
}
do_some_stuff -> with_this -> do_that
and_some_stuff -> and_that -> then_do_that [dir=back]
and_other_stuff -> using_this -> and_this
{ rank=same with_this -> and_that -> using_this [style=invis] }
}
并给予
我有下图
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
}
现在我想在这些集群之间添加节点并使用边连接它们:
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
do_some_stuff -> with_this -> do_that
then_do_that -> and_that -> and_some_stuff
and_other_stuff -> using_this -> and_this
}
但这并不是我预期的结果。我希望中间的节点与连接的节点处于相同的高度:让我们尝试对它们进行排名:
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
{rank=same; rankdir=LR; do_some_stuff -> with_this -> do_that}
{rank=same; then_do_that -> and_that -> and_some_stuff}
{rank=same; and_other_stuff -> using_this -> and_this}
}
嗯,它们在同一高度,但是簇消失了,中间一排的顺序错了。我该如何解决?
点布局引擎有自己的想法:-)
digraph {
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
do_some_stuff -> and_some_stuff -> and_other_stuff
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
do_that -> then_do_that -> and_this
}
with_this -> and_that -> using_this [style=invis]
do_some_stuff -> with_this -> do_that [constraint=false]
then_do_that -> and_that -> and_some_stuff [constraint=false]
and_other_stuff -> using_this -> and_this [constraint=false]
}
给予
替代解决方案是
digraph { rankdir = LR
subgraph cluster_party1 {
do_some_stuff
and_some_stuff
and_other_stuff
{ rank=same do_some_stuff -> and_some_stuff -> and_other_stuff }
}
with_this
and_that
using_this
subgraph cluster_party2 {
do_that
then_do_that
and_this
{ rank=same do_that -> then_do_that -> and_this }
}
do_some_stuff -> with_this -> do_that
and_some_stuff -> and_that -> then_do_that [dir=back]
and_other_stuff -> using_this -> and_this
{ rank=same with_this -> and_that -> using_this [style=invis] }
}
并给予