使用点语言在Graphviz中压缩图 [英] Compacting a digraph in Graphviz using Dot Language

查看:79
本文介绍了使用点语言在Graphviz中压缩图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现一个特定图形(对称排列组的Cayley图形)的可视化,就像在此处使用Graphviz 2.28和Dot一样.

I'm trying to achieve a visualization of a specific graph (a Cayley graph of a symmetric permutation group) as the one done here but using Graphviz 2.28 with Dot.


(来源: euclideanspace.com )


(source: euclideanspace.com)

digraph cayley {
    i -> x [color=red];
    i -> y [color=blue];
    x -> xx [color=red];
    x -> xy [color=blue];
    y -> yx [color=red];
    y -> yy [color=blue];
    xx -> xxx [color=red];
    xx -> xxy [color=blue];
    xy -> xyx [color=red];
    xy -> xyy [color=blue];
    yx -> yxx [color=red];
    yx -> xyx [color=blue];
    yy -> yyx [color=red];
    yy -> yyy [color=blue];
    xxx -> i [color=red];
    xxx -> xxxy [color=blue];
    xxy -> xxyx [color=red];
    xxy -> xxyy [color=blue];
    xyx -> xyxx [color=red];
    xyx -> xxyx [color=blue];
    xyy -> yy [color=red];
    xyy -> xyyy [color=blue];
    yxx -> yxxx [color=red];
    yxx -> xx [color=blue];
    yyx -> xxyy [color=red];
    yyx -> xyxx [color=blue];
    yyy -> yyyx [color=red];
    yyy -> i [color=blue];
    xxxy -> xxxyx [color=red];
    xxxy -> yyx [color=blue];
    xxyx -> yyy [color=red];
    xxyx -> xxxyx [color=blue];
    xxyy -> xyy [color=red];
    xxyy -> yxx [color=blue];
    xyxx -> xyxxx [color=red];
    xyxx -> xxx [color=blue];
    xyyy -> xyyyx [color=red];
    xyyy -> x [color=blue];
    yxxx -> y [color=red];
    yxxx -> xyyyx [color=blue];
    yyyx -> xxy [color=red];
    yyyx -> xyxxx [color=blue];
    xxxyx -> xyyy [color=red];
    xxxyx -> yx [color=blue];
    xyxxx -> xy [color=red];
    xyxxx -> yxxx [color=blue];
    xyyyx -> xxxy [color=red];
    xyyyx -> yyyx [color=blue];
}

我的点"生成以下布局:与上一个图形相比,它是一个非常大的图形.是否有任何属性可以将图形压缩得尽可能靠近第一个一个?

My Dot generates the following layout: which is a pretty huge graph compared with the previous one. Is there any attribute that can compact the graph as close as possible to the first one ?

推荐答案

我修改了图形,节点和边默认属性等代码,以使布局尽可能紧凑.也许有一个更完美的方法.顺便说一句,节点i位于左侧,但不位于右侧.

I modified the codes such as graph, node and edge default attributes to make the layout as compacted as possible. Maybe there is a more perfect approach. By the way, the node i is located at the left but not right.

digraph cayley {
    graph[rankdir=LR, center=true, margin=0.2, nodesep=0.1, ranksep=0.3]
    node[shape=circle, fontname="Courier-Bold", fontsize=10, width=0.4, height=0.4, fixedsize=true]
    edge[arrowsize=0.6, arrowhead=vee]
    i -> x [color=red];
    i -> y [color=blue];
    x -> xx [color=red];
    x -> xy [color=blue];
    y -> yx [color=red];
    y -> yy [color=blue];
    xx -> xxx [color=red];
    xx -> xxy [color=blue];
    xy -> xyx [color=red];
    xy -> xyy [color=blue];
    yx -> yxx [color=red];
    yx -> xyx [color=blue];
    yy -> yyx [color=red];
    yy -> yyy [color=blue];
    xxx -> i [color=red];
    xxx -> xxxy [color=blue];
    xxy -> xxyx [color=red];
    xxy -> xxyy [color=blue];
    xyx -> xyxx [color=red];
    xyx -> xxyx [color=blue];
    xyy -> yy [color=red];
    xyy -> xyyy [color=blue];
    yxx -> yxxx [color=red];
    yxx -> xx [color=blue];
    yyx -> xxyy [color=red];
    yyx -> xyxx [color=blue];
    yyy -> yyyx [color=red];
    yyy -> i [color=blue];
    xxxy -> xxxyx [color=red];
    xxxy -> yyx [color=blue];
    xxyx -> yyy [color=red];
    xxyx -> xxxyx [color=blue];
    xxyy -> xyy [color=red];
    xxyy -> yxx [color=blue];
    xyxx -> xyxxx [color=red];
    xyxx -> xxx [color=blue];
    xyyy -> xyyyx [color=red];
    xyyy -> x [color=blue];
    yxxx -> y [color=red];
    yxxx -> xyyyx [color=blue];
    yyyx -> xxy [color=red];
    yyyx -> xyxxx [color=blue];
    xxxyx -> xyyy [color=red];
    xxxyx -> yx [color=blue];
    xyxxx -> xy [color=red];
    xyxxx -> yxxx [color=blue];
    xyyyx -> xxxy [color=red];
    xyyyx -> yyyx [color=blue];
    { rank=same; x; y }
    { rank=same; xx; xy; yx; yy }
    { rank=same; xxx; xxy; xyx; xyy; yxx; yyx; yyy }
    { rank=same; xxxy; xxyx; xxyy; xyxx; xyyy; yxxx; yyyx }
    { rank=same; xxxyx; xyxxx; xyyyx }
}

图像如下所示.

这篇关于使用点语言在Graphviz中压缩图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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