Graphviz中的箭头重叠节点 [英] Arrowhead overlaps node in Graphviz

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

问题描述

当您查看上图时,您可以轻松地看到a-> b的箭头与节点b重叠.箭头的尖端应在b节点框之前停止,就像c-> d一样.产生此结果的代码是:

When you look at the graph above you can easily see that the arrowhead from a->b overlaps the node b. The tip of the arrowhead should stop right before the b node box, like it is the case in c->d. The code that produces this result is:

digraph{
  node[shape="box"]
  a->b[color=blue, penwidth=20]
  c->d[color=blue]
}

正在使用的布局引擎是点"布局引擎.

The layout engine in use is the "dot" Layout Engine.

推荐答案

headclip (和tailclip)使笔划边缘的笔的中心在与笔形中心画的假想线交叉时停止.这是预期的行为.graphviz不能补偿笔的宽度,因为它可以进行图形布局.您必须发布流程或手动编辑点引擎(svg或点)的输出.

headclip (and tailclip) causes the center of the pen drawing the edge to stop when crossing the imaginary line drawn by the center of shape-pen. this is the expected behaviour. graphviz does not compensate for pen width as it is designed to do graph layout. you have to post process or manually edit the output of the dot engine (svg or dot).

digraph{ ranksep=0.5 nodesep=0.5 margin=0.5
  node[shape="box"]
  { node[penwidth=1] a c e}
  { node[penwidth=20] b d f}
  a->b->c [color=blue penwidth=20]
  d->e->f [color=blue]
}

png显示出笔尖的圆角(和令人讨厌的剪裁)

the png shows round pen edges (and nasty clipping)

svg在边缘和形状上显示出尖锐的尖端

the svg shows sharp tips on edges and shapes

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by graphviz version 2.38.0 (20140413.2041)
 -->
<!-- Title: %8851 Pages: 1 -->
<svg width="224pt" height="260pt"
 viewBox="36.00 36.00 188.00 224.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(40 220)">
<title>%8851</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-184 148,-184 148,4 -4,4"/>
<!-- a -->
<g id="node1" class="node"><title>a</title>
<polygon fill="none" stroke="black" points="54,-180 0,-180 0,-144 54,-144 54,-180"/>
<text text-anchor="middle" x="27" y="-158.3" font-family="Times New Roman,serif" font-size="14.00">a</text>
</g>
<!-- b -->
<g id="node4" class="node"><title>b</title>
<polygon fill="none" stroke="black" stroke-width="20" points="54,-108 0,-108 0,-72 54,-72 54,-108"/>
<text text-anchor="middle" x="27" y="-86.3" font-family="Times New Roman,serif" font-size="14.00">b</text>
</g>
<!-- a&#45;&gt;b -->
<g id="edge1" class="edge"><title>a&#45;&gt;b</title>
<path fill="none" stroke="blue" stroke-width="20" d="M27,-143.697C27,-135.983 27,-126.712 27,-118.112"/>
<polygon fill="blue" stroke="blue" stroke-width="20" points="44.5001,-118.104 27,-108.104 9.5001,-118.105 44.5001,-118.104"/>
</g>
<!-- c -->
<g id="node2" class="node"><title>c</title>
<polygon fill="none" stroke="black" points="54,-36 0,-36 0,-0 54,-0 54,-36"/>
<text text-anchor="middle" x="27" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">c</text>
</g>
<!-- e -->
<g id="node3" class="node"><title>e</title>
<polygon fill="none" stroke="black" points="144,-108 90,-108 90,-72 144,-72 144,-108"/>
<text text-anchor="middle" x="117" y="-86.3" font-family="Times New Roman,serif" font-size="14.00">e</text>
</g>
<!-- f -->
<g id="node6" class="node"><title>f</title>
<polygon fill="none" stroke="black" stroke-width="20" points="144,-36 90,-36 90,-0 144,-0 144,-36"/>
<text text-anchor="middle" x="117" y="-14.3" font-family="Times New Roman,serif" font-size="14.00">f</text>
</g>
<!-- e&#45;&gt;f -->
<g id="edge4" class="edge"><title>e&#45;&gt;f</title>
<path fill="none" stroke="blue" d="M117,-71.6966C117,-63.9827 117,-54.7125 117,-46.1124"/>
<polygon fill="blue" stroke="blue" points="120.5,-46.1043 117,-36.1043 113.5,-46.1044 120.5,-46.1043"/>
</g>
<!-- b&#45;&gt;c -->
<g id="edge2" class="edge"><title>b&#45;&gt;c</title>
<path fill="none" stroke="blue" stroke-width="20" d="M27,-71.6966C27,-63.9827 27,-54.7125 27,-46.1124"/>
<polygon fill="blue" stroke="blue" stroke-width="20" points="44.5001,-46.1042 27,-36.1043 9.5001,-46.1045 44.5001,-46.1042"/>
</g>
<!-- d -->
<g id="node5" class="node"><title>d</title>
<polygon fill="none" stroke="black" stroke-width="20" points="144,-180 90,-180 90,-144 144,-144 144,-180"/>
<text text-anchor="middle" x="117" y="-158.3" font-family="Times New Roman,serif" font-size="14.00">d</text>
</g>
<!-- d&#45;&gt;e -->
<g id="edge3" class="edge"><title>d&#45;&gt;e</title>
<path fill="none" stroke="blue" d="M117,-143.697C117,-135.983 117,-126.712 117,-118.112"/>
<polygon fill="blue" stroke="blue" points="120.5,-118.104 117,-108.104 113.5,-118.104 120.5,-118.104"/>
</g>
</g>
</svg>

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

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