Graphviz:安排节点 [英] Graphviz: arranging nodes

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

问题描述

是否可以告诉GraphViz(点​​)尝试布置图的节点而不拉伸任何一个维?例如,如果我创建一个具有25个节点且没有边缘的图形,则GraphViz会将其所有节点都显示在一行中.我想要的是获得5 x 5的节点场".

Is it possible to tell GraphViz (Dot) to try arranging nodes of the graph without stretching either of the dimensions? For example, if I create a graph with 25 nodes and no edges, GraphViz visualizes it with all nodes in a single row. What I want is to get a 5 x 5 "field" of nodes.

推荐答案

rank = same 和不可见的边缘是您的朋友:

rank=same in conjunction with invisible edges are your friend:

digraph Test 
{
    nodesep = 0.5;                 // even node distribution
    node [ shape = circle, width = 0.7 ];
    edge [ style = invis ];

    { rank = same; A; B; C; D; E }
    { rank = same; F; G; H; I; J }
    { rank = same; K; L; M; N; O }
    { rank = same; P; Q; R; S; T }
    { rank = same; U; V; W; X; Y }

    C -> { F G H I J } 
    H -> { K L M N O }
    M -> { P Q R S T }
    R -> { U V W X Y }
}

代替最后四行,您只需使用

Instead of the last four lines, you could simply use

A -> F -> K -> P -> U;

对于给定的节点,这将导致相同的结果,但是当节点大小变化时,稳定性可能会降低.

This would lead to the same result with the given nodes but may be less stable when node sizes are varying.

这篇关于Graphviz:安排节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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