将宽图的相同等级上的节点分布到不同的线 [英] Distribute nodes on the same rank of a wide graph to different lines

查看:106
本文介绍了将宽图的相同等级上的节点分布到不同的线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图(组织图),这是怎么回事:

I have a graph (organigram) how this:

digraph G {
nodesep=0.3;
ranksep=0.2;
margin=0.1;
node [shape=rectangle];
edge [arrowsize=0.8];
1 -> 2;
1 -> 3;
1 -> 4;
1 -> 5;
1 -> 6;
1 -> 7;
1 -> 8;
1 -> 9;
1 -> 10;
}

我有70个人的组织结构图,不可能在A4上打印.我如何将节点放在2或3行中?

I have organigrams with 70 people and it's impossible to print in A4. How would I put nodes in 2 or 3 lines?

推荐答案

有两种可能性(另请参见此问题 ):

Here are two possibilities (see also this question):

Graphviz提供了一个名为 unflatten 的工具.如果您使用以下命令行预处理图形:

Graphviz provides a tool called unflatten. If you pre-process your graph using this command line:

unflatten -l 3 wide.gv | dot -Tpng -o wide.png

输出图像将类似于下图.宽度稍小一些,您可以使用-l选项.

the output image will be similar to the below picture. This is slightly less wide, and you may play with the -l option.

您可以使用标准技术使自动布局的图看起来更像您想要的那样:

You may use the standard techniques to make a automatically layed out graphs look more like you want it to:

  • rank=same子图中的节点分组,并定义哪些节点应该在同一行上
  • 不可见的边缘,以确保不同的子图出现在不同的等级上
  • 某些边缘可能会constraint=false会影响布局
  • 节点的
  • group属性可鼓励直线边缘.
  • rank=same to group nodes in subgraphs and to define which nodes should be on the same line
  • invisible edges to ensure that the different subgraphs appear on different ranks
  • maybe some constraint=false for some edges to influence the layout
  • group attributes of nodes to encourage straight edges.

输出图不一定漂亮...

The output graph will not necessarily be prettier...

这是一个例子,您可能会做得更好.此外,如果动态生成图形,这可能不太实用.

Here's an example, you can probably do better. Also, this may not be very practical if the graph is generated dynamically.

digraph G {
nodesep=0.3;
ranksep=0.2;
margin=0.1;
node [shape=rectangle];
edge [arrowsize=0.8];


edge[style=invis];
node[group=a];
2->5->8;
node[group=b];
1->3->6->9;
node[group=c];
4->7->10;


edge[style=solid];
1 -> 2;
1 -> 3;
1 -> 4;
edge[constraint=false];
1 -> 5;
1 -> 6;
1 -> 7;
1 -> 8;
1 -> 9;
1 -> 10;
}

这篇关于将宽图的相同等级上的节点分布到不同的线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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