问题
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.
回答1:
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]
}
the png shows round pen edges (and nasty clipping)
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->b -->
<g id="edge1" class="edge"><title>a->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->f -->
<g id="edge4" class="edge"><title>e->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->c -->
<g id="edge2" class="edge"><title>b->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->e -->
<g id="edge3" class="edge"><title>d->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>
来源:https://stackoverflow.com/questions/28947554/arrowhead-overlaps-node-in-graphviz