如何在点中控制子图的布局? [英] How to control subgraphs' layout in dot?

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

问题描述

i有一个digraph,它由许多大小不同的独立且简单的subgraphs组成. dot将所有这些子图水平放置,因此我得到一个40000x200的输出文件,例如:

i have a digraph composed of many independant and simple subgraphs of various sizes. dot lays all these subgraphs horizontally, so i end up with a 40000x200 output file, e.g:

G1 G2 G3 G.....4 G5

我如何告诉dot在两个维度上布局这些子图以获得类似的内容:

How do i tell dot to layout these subgraphs in both dimensions to get something like:

G1 G2 G3
G.....4
G5

谢谢.

推荐答案

实现此目标的步骤使用了可以通过管道连接的多个graphviz工具.

The steps to achieve this uses multiple graphviz tools which can be piped together.

以下一行是可能的配置, graph.dot 是包含您的图形的文件.您可能不得不弄弄这些选项.

The following line is a possible configuration, graph.dot being the file which contains your graph(s). You may have to fiddle with the options.

ccomps -x graph.dot | dot | gvpack -array3 | neato -Tpng -n2 -o graph.png

这是解释:

工具: ccomps

将图分解为它们的连接组件

decomposes graphs into their connected components

可能只需要-x选项(仅打印连接的组件,作为单独的图形).

工具:

每个有向图都一张一张地布置.需要执行此步骤才能获得节点和边的位置.

Each directed graph is layed out, one by one. This step is needed to get the position of the nodes and edges.

工具: gvpack

读取图形流,将图形合并为一个布局, 并生成一个图作为输入图的并集.

reads in a stream of graphs, combines the graphs into a single layout, and produces a single graph serving as the union of the input graphs.

您应该阅读此工具选项的文档,并使用这些选项.例如,-array用于以类似于网格的方式对图形进行布局,并提供几个标志来控制布局.

You should read the documentation of the options for this tool and play with the options. For example, -array is used to lay out the graphs in a grid like manner, and offers several flags to control the layout.

工具: neato

选项-n2告诉neato不要布局输入图,而要使用现有的位置属性.

The option -n2 tells neato to not layout the input graphs but to use the existing position attributes.

示例图:

digraph G {
 subgraph G1 {
    a->{b; c;};
 }
 subgraph G2 {
    d -> {e; f;};
 }
 subgraph G3 {
    g -> h;
 }
 subgraph G4 {
    i -> j;
 }
 subgraph G5 {
    {k; l;} -> m;
 }
}


编辑:对gvpack中的图进行排序


Sorting the digraphs in gvpack

为了确定gvpack创建的组合布局中子图的出现顺序,每个子图都需要一个sortv属性.

In order to determine the order of appearance od the subgraphs in the combined layout created by gvpack, each subgraph will need a sortv attribute.

例如,以下图形:

digraph G1 {
 sortv=1;
 a->{b; c;};
}
digraph G2 {
 sortv=2;
 d -> {e; f;};
}
digraph G3 {
 sortv=3;
 g -> h;
}
digraph G4 {
 sortv=4;
 i -> j;
}
digraph G5 {
 sortv=5;
 {k; l;} -> m;
}

可以使用

dot graph.dot | gvpack -array_u | neato -Tpng -n2 -o graph.png

导致

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

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