子图簇在点中的排名 [英] subgraph cluster ranking in dot

查看:51
本文介绍了子图簇在点中的排名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在媒体Wiki上使用graphviz作为软件的文档工具.

I'm trying to use graphviz on media wiki as a documentation tool for software.

首先,我记录了一些效果很好的类关系.一切都按预期垂直排列.

First, I documented some class relationships which worked well. Everything was ranked vertically as expected.

但是,然后,我们的一些模块是dll,我想将它们分隔成一个盒子.当我将节点添加到群集时,它们变得边缘化,但是群集似乎具有LR排名规则.或被添加到群集中时,该群集现在出现在图的侧面,从而破坏了节点的TB排名.

But, then, some of our modules are dlls, which I wanted to seperate into a box. When I added the nodes to a cluster, they got edged, but clusters seem to have a LR ranking rule. Or being added to a cluster broke the TB ranking of the nodes as the cluster now appears on the side of the graph.

此图表示我要执行的操作:此刻,cluster1和cluster2出现在cluster0的右侧.

This graph represents what I am trying to do: at the moment, cluster1 and cluster2 appear to the right of cluster0.

我希望/需要它们出现在下面.

I want/need them to appear below.

<graphviz>
digraph d {
    subgraph cluster0 {
      A -> {B1 B2}
      B2 -> {C1 C2 C3}
      C1 -> D;
    }
    subgraph cluster1 {
      C2 -> dll1_A;
      dll1_A -> B1;
    }
    subgraph cluster2 { 
      C3 -> dll2_A;
    }
    dll1_A -> dll2_A;
}
</graphviz>

推荐答案

布局是Dot尝试使整体高度最小化的一种尝试.

The layout is an attempt by Dot to minimise the overall height.

比要求的布局更紧凑的原因之一是使用了从 dll1_a B1 的相反方向的边.它尝试将群集拉回尽可能靠近目标节点的位置.为避免此边缘影响图形,请如图所示放松上边缘的 constraint 或在正方向上绘制边缘并使用 dir 属性反转箭头

One reason for the more compact than required layout is the use of the edge that goes in the reverse direction from dll1_a to B1. It tries to pull the cluster as close back to the destination node as possible. To avoid this edge affecting the graph, either relax the constraint on the upwards edges as shown, or draw the edge in the forward direction and use the dir attribute to reverse the arrow.

这将有助于许多布局,但仅靠它不足以解决给出的示例.为了防止Dot保持紧凑的布局,您可以向应该保持(接近)垂直的边添加 minlen 属性.通常,这可能很难计算,但对于手动调整的布局很实用.

This will help with many layouts but it alone is not sufficient to fix the example given. To prevent Dot from maintaining the compact layout it prefers you can add a minlen attribute to edges that should remain (near) vertical. This may be difficult to calculate in general but is practical for manually tuned layouts.

digraph d {
    subgraph cluster0 {
        A -> {B1 B2}    
        B2 -> {C1 C2 C3}
        C1 -> D;
    }
    subgraph cluster1 {
        C2 -> dll1_A [minlen = 2];
        dll1_A -> B1 [constraint = false];
        /* B1 -> dll1_A [dir = back]; */
    }
    subgraph cluster2 {
        C3 -> dll2_A;
    }
    dll1_A -> dll2_A;
}

这篇关于子图簇在点中的排名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆