# How improve tikZ graphs arrows rendering?

I have the following tikZ graph:

produced by:

\tikzset{actor/.style={
rectangle,
minimum size=6mm,
very thick,
draw=red!50!black!50,
top color=white,
bottom color=red!50!black!20
}}
\tikzset{arrow/.style={
-latex, thick
}}
\begin{tikzpicture}[
background rectangle/.style={fill=yellow!10,rounded corners=1ex},        show background rectangle,
node distance=5mm and  8mm
]
\node (Input) [align=center]{GZip\\Stream};
\node (Inflate) [actor, right=of HeaderParser] {Inflate};
\node (Crc) [actor,above =of Inflate] {Crc};
\node (FooterParser) [actor,right=of Inflate] {Footer Parser};
\node (Output) [right=of FooterParser,align=center]{Decoded\\Stream};
\draw[arrow] (Inflate.north)--(Crc.south);
\draw[arrow] (Inflate.east)--(FooterParser.west);
\draw[arrow] (FooterParser.east)--(Output.west);
\draw[arrow] (Crc.east)--(FooterParser.west);
\end{tikzpicture}


I am almost happy with it excepted about the arrows. I don't like the arrows end and the 2 arrows ending on the same node. How can I improve this ?

-

The shorten keys allows for more space around the nodes (without using outer sep and other hacks). This can really clean up a figure.

Secondly make the downward arrow go in straight lines using -| (|- for the other way).

And lastly, you do not need the east|north|south|west unless you are using curved lines, an -- will be interpreted as the shortest path between the two objects (which in this case are east -- west and south -- north).

So basically I would do:

\tikzset{actor/.style={
rectangle,
minimum size=6mm,
very thick,
draw=red!50!black!50,
top color=white,
bottom color=red!50!black!20
},
arrow/.style={
-latex, thick, shorten <=2pt,shorten >=2pt
}
}
\begin{tikzpicture}[background rectangle/.style={
fill=yellow!10,rounded corners=1ex
},
node distance=5mm and 8mm]
\node (Input) [align=center]{GZip\\Stream};
\node (Inflate) [actor, right=of HeaderParser] {Inflate};
\node (Crc) [actor,above =of Inflate] {Crc};
\node (FooterParser) [actor,right=of Inflate] {Footer Parser};
\node (Output) [right=of FooterParser,align=center]{Decoded\\Stream};
\draw[arrow] (Inflate)--(Crc);
\draw[arrow] (Inflate)--(FooterParser);
\draw[arrow] (FooterParser)--(Output);
\draw[arrow] (Crc)-|(FooterParser);
\end{tikzpicture}


Which gives:

A last way out is to join the two lines before FooterParser, for this you need the calc library:

\draw[thick,shorten <=2pt] (Crc)-|($(Inflate.east)!.5!(FooterParser.west)$);


This will yield:

-
Thanks for the clear and complete answer. just one more thing, the "rounded" effect of arrows end causes "rendering issue" depending on zoom level of the PDF viewer. The screen shot I took is viewing the PDF with zoom = 100%. How can I change that ? – Manuel Selva Sep 12 '12 at 8:02
Rendering of zoom has nothing to do with the TikZ code, search around for this issue. It has been brought up several times and is an issue with the rendering machine in the viewer. :) – zeroth Sep 12 '12 at 8:09
Yes I understand that ;-) so what viewer did you use to take your screenshot, they are nice ? – Manuel Selva Sep 12 '12 at 8:12
I didn't take a screenshot :) I used imagemagick. convert -trim -density <resolution> <filename>.pdf <filename>.png. – zeroth Sep 12 '12 at 8:16
This looks very nice and professional, +1. – Alexander Sep 12 '12 at 13:51

If you don't like the end arrow you can change it: there's an entire section dedicated to this on the pgfmanual (see 23 Arrow Tip Library, version October 25, 2010).

For what concern the ending connection point for the FooterParser node, one could even specify the boundary angle in which the arrow ends. To better understand this, see the following answer: Alignments by means of the tikzmark macro.

See the following MWE (BTW: the one posted is not a minimal working example) in which as arrow tip I used stealth and as end connection point FooterParser.175:

 \documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows,backgrounds,positioning}

\tikzset{actor/.style={
rectangle,
minimum size=6mm,
very thick,
draw=red!50!black!50,
top color=white,
bottom color=red!50!black!20
}}
\tikzset{arrow/.style={
-stealth, thick
}}

\begin{document}

\begin{tikzpicture}[
background rectangle/.style={fill=yellow!10,rounded corners=1ex},        show background rectangle,
node distance=5mm and  8mm
]
\node (Input) [align=center]{GZip\\Stream};
\node (Inflate) [actor, right=of HeaderParser] {Inflate};
\node (Crc) [actor,above =of Inflate] {Crc};
\node (FooterParser) [actor,right=of Inflate] {Footer Parser};
\node (Output) [right=of FooterParser,align=center]{Decoded\\Stream};