How to set the 'spring' force with graphviz for compact graph layouts

与世无争的帅哥 提交于 2019-12-03 12:27:21

问题


I'm generating diagram with graphviz and I have a problem - there are several nodes that are very large - and large number of small nodes. I tried generating png with neato and fdp but both generate very large graphics, which are mostly blank (nodes are very far apart). Is there a way to set a larger spring 'strength' for these tools to force nodes closer together?


回答1:


When using neato, you may fiddle with the overlap and with the sep attribute.

overlap can be set to false, compress, scalexy, and more.

sep may either designate an additive margin when used with a preceding plus sign, otherwise the margin is defined by scaling the node's size with 1 + the value of sep. It seems that the default

Don't hesitate to post a sample graph. Not knowing your particular graph, I made an example containing some big and some small nodes:

layout=neato;
overlap=scalexy; //false, compress, ...
sep="+1"; // 0.1, +1

node[label="Large node", width=2, height=2];
l1; l2; l3;
node[label="\N", width=0.5, height=0.3];
1 -> l1;
2 -> l1;
3 -> l1;
4 -> l1;
5 -> l1;
5 -> l2;
6 -> l2;
7 -> l2;
8 -> l2;
8 -> l3;
9 -> l3;
10 -> l3;



来源:https://stackoverflow.com/questions/5551867/how-to-set-the-spring-force-with-graphviz-for-compact-graph-layouts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!