Graphviz中的布局

Eug*_*ene 3 graphviz

关键问题是如何在Graphviz图中控制元素的垂直和水平定位.

考虑一下这个图表的摘录(在wysiwig编辑器中创建).

在此输入图像描述

我试图在Graphviz中重现它,以确定它是否适合我的目的.

digraph G {
compound=true;
node [shape=box];
edge [dir=none];
    subgraph cluster_tmk_web6 {
        nginx [label="nginx-frontend TCP 0.0.0.0:80"];

        subgraph clusteradminapp {
            unicorn [label="unicorn_rails TCP 127.0.0.1:8080"];
            subgraph clusterROR {
            label="ROR v.2.1";
            brida [label="brida_face_client"];
            }
            label="Admin App";
        }

        memcached [label="memcached"];
        sphinx;
        mongodb;

        subgraph cluster_errbit {
            unicorn2;
            ror3;
        }

    label="tmk-web6.service.home";
    }       

nginx -> unicorn;
memcached -> brida [lhead=clusterROR];


}
Run Code Online (Sandbox Code Playgroud)

结果就像

在此输入图像描述

我省略了一些箭头,但定位对我来说至关重要.如何将"memcached"和"sphinx"移动到群集的底部?如何将'mongodb'转移到右边?最后,该图将包含大约6到10个这种大小的集群.如何控制布局,将一些簇连续放置在其他位置 - 上方和下方?我想我应该在这里使用"rank"属性,但不知道如何.请帮忙.

mar*_*pet 12

只需添加剩余边(以及两条不可见边),graphviz输出就会更接近您想要的结果:

digraph G {
compound=true;
node [shape=box];
edge [dir=none];
    subgraph cluster_tmk_web6 {
        nginx [label="nginx-frontend TCP 0.0.0.0:80"];

        subgraph clusteradminapp {
            unicorn [label="unicorn_rails TCP 127.0.0.1:8080"];
            subgraph clusterROR {
            label="ROR v.2.1";
            brida [label="brida_face_client"];
            }
            unicorn -> brida[style=invis];
            label="Admin App";
        }

        memcached [label="memcached"];
        sphinx;
        mongodb;

        subgraph cluster_errbit {
            unicorn2;
            ror3;
            unicorn2 -> ror3[style="invis"];
            label="Errbit";
        }

    label="tmk-web6.service.home";
    }       

nginx -> unicorn;
nginx -> unicorn2;
brida -> memcached [lhead=clusterROR];
brida -> sphinx [lhead=clusterROR];
ror3 -> mongodb;
}
Run Code Online (Sandbox Code Playgroud)

graphviz输出

添加一些颜色等,你几乎就在那里.

但请记住,Graphviz不是一个所见即所得的工具 - 它的优点在于节点的自动布局.