Graphviz Dot中奇怪的边缘位置 [英] Strange edge placement in Graphviz Dot

查看:174
本文介绍了Graphviz Dot中奇怪的边缘位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个模块可以自动输出(以点格式)用某种汇编语言编写的函数(我的编译器的IR)。节点是使用记录形状打印的基本块。例如:

  digraph {
node [shape = record] ;
n0 [label ={< name> entry |< body> store i,0 \ storestore,0 \ ngoto test | {< target> target}}]];
n1 [< name> test |< body> t2 = load i \ nif t4,body,done | {< true> true |< false> false}}]
n2 [label ={< name> body |< body> t5 = load sum \\\
goto test | {< target> target}}];
N3 [色= firebrick3,标记= {<名称>完成|<身体GT; T9 =负载sum\\\
ret T9}}];
n0:target:s - > n1:名称:n
n1:true:s - > n2:名称:n
n1:false:s - > n3:名称:n
n2:目标:s - > n1:name:n
}

和一张图片:

http://img529.imageshack.us/img529/ 3780 / graphviz.png



我能做些什么,以便从'target'到'test'的边缘位于左侧?

解决方案

最简单的非上师的方式是强迫那些任性的链接附加在西方两侧。

  n2:target:w  - > n1:姓名:w 

这可能对这种情况起作用。更通用的方式,但需要更多的思考和编码,但会允许边缘附加到:s和:n如果您需要,添加零大小的不可见节点(color = white,或者可能存在可见性属性),并使用两条边从n2到n1。只有其中一个有箭头。不可见节点将不得不坐在n1或n2的左侧。唉,我的graphvis-fu不够强大,无法创建一个工作示例;也许其他人可以创建一个。




I have a module that automatically outputs (in dot format) functions written in some kind of assembly language (the IR of my compiler). The nodes are the basic blocks printed using the 'record' shape. The problem is that the edges take a strange route, for example:

digraph {
node [shape = record];
n0[label="{<name> entry | <body> store i, 0\nstore sum, 0\ngoto test | {<target> target}}"];
n1[label="{<name> test | <body> t2 = load i\nif t4, body,   done | {<true> true | <false> false}}"]
n2[label="{<name> body | <body> t5 = load sum\ngoto test | {<target> target}}"];
n3[color=firebrick3, label="{<name> done | <body> t9 = load sum\nret t9}}"];
n0:target:s -> n1:name:n
n1:true:s -> n2:name:n
n1:false:s -> n3:name:n
n2:target:s -> n1:name:n
}

And an image:

http://img529.imageshack.us/img529/3780/graphviz.png

What can I do so that the edge from 'target' to 'test' is placed on the left side?

解决方案

The simplest non-guru way is force that wayward link to attach on the "west" sides.

n2:target:w -> n1:name:w

This might work okay for this case. A more general way, but takes more thinking and coding, but would allow the edge to attach to the :s and :n if you desire that, is add an invisible node of size zero (color=white, or there might be a visibility attribute) and get from n2 to n1 using two edges. Have the arrowhead on only one of them. The invisible node would have to sit to the left of n1 or n2. Alas, my graphvis-fu is not strong enough to create a working example; maybe someone else can create one.

这篇关于Graphviz Dot中奇怪的边缘位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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