Graphviz:相交但非递归集群

问题描述 投票:0回答:2

我想知道是否可以在 Graphviz 中做这样的事情:

如您所见,节点“二”位于两个集群内,而集群不是递归的。

注意:图像是用 Dia 制作的。

graphviz intersection subgraph
2个回答
4
投票

不,目前不可能,这个其他答案简要描述了原因。

只是重写 Jens' 评论作为答案。


3
投票

虽然 Graphviz 不会直接生成重叠簇,但它允许您通过一些编辑来创建重叠簇。 (有关更多信息,请参阅:https://www.graphviz.org/faq/#FaqDotWithCoords

开始于:

digraph o {
  graph [newrank=true nodesep=.5]

  subgraph cluster1 {
    graph [margin=50 label="Subgraph 1"]
    {rank=same
      one-> two [style=invis]
    }
  }
  subgraph cluster2 {
    graph [label="Subgraph 2"]
    three
  }
 
  {rank=same
    one two three
  }
}

运行此命令:

dot -Tdot myfile.gv >myfile.dot

然后编辑 myfile.dot 以更改 cluster2 的边界框。像这样:

digraph o {
    graph [bb="0,0,398,175",
        newrank=true,
        nodesep=.5
    ];
    node [label="\N"];
    {
        graph [rank=same];
        one [height=0.5,
            pos="85,76",
            width=0.75827];
        two [height=0.5,
            pos="176,76",
            width=0.77632];
        three   [height=0.5,
            pos="340,76",
            width=0.99297];
    }
    subgraph cluster1 {
        graph [bb="8,8,254,167",
            label="Subgraph 1",
            lheight=0.21,
            lp="131,155.5",
            lwidth=1.17,
            margin=50
        ];
        {
            graph [rank=same];
            one;
            two;
            one -> two  [pos="e,147.67,76 112.37,76 120.74,76 129.1,76 137.46,76",
                style=invis];
        }
    }
    subgraph cluster2 {
        graph [bb="135,50,390,125",  // X1 edited
            label="Subgraph 2",
            lheight=0.21,
            lp="340,113.5",
            lwidth=1.17
        ];
        three;
    }
}

在编辑的文件上运行此命令:

neato -n2 -Tpng myfile.dot >myfile.png

给予:

© www.soinside.com 2019 - 2024. All rights reserved.