15

I am getting something like this: enter image description here

This certainly doesn't look good. Curved arrows cross the blocks. Is there any better way of drawing curved arrows or any other solution?

I am putting my code:

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[margin=15mm]{geometry}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}


\begin{document}

\begin{tikzpicture}[thick]
\tikzset{input/.style={}}
\tikzset{block/.style={rectangle,draw}}
\tikzstyle{pinstyle} = [pin edge={to-,thick,black}]

\node [input, name=input] {};
\node [block, right=0.5 cm of input,minimum width=1.5cm, minimum height=2.5cm] (a) {};
\node [block, right of=a,minimum width=1.5cm, minimum height=5cm,node distance=3cm] (b) {};
\node [block, right of=b, minimum width=2cm, minimum height=5cm,node distance=3cm] (c) {};
\node [block, right of=c,minimum width=1.5cm, minimum height=5cm,node distance=3cm] (d) {};
\node [block, right of=d, minimum width=2cm, minimum height=5cm,node distance=3cm] (e) {};
\node [right =0.5 cm of e] (output) {};

\begin{scope}[->,>=latex]

\draw[->] (input) -- (a);

\node at (b.center) {\footnotesize{z}};

\draw[->] ([yshift=1.5 cm]c.north west) node[left]{\footnotesize{$Ack_1$}} -| ([xshift=0.25 cm]e.north);
\draw[->] ([yshift=1.5 cm]c.north west) -| ([xshift=0.25 cm]c.north);
\draw[->] ([yshift=1 cm]c.north west) node[left]{\footnotesize{$Ack_0$}} -| ([xshift=-0.25 cm]e.north);
\draw[->] ([yshift=1 cm]c.north west) -| ([xshift=-0.25 cm]c.north);
\draw[->] (e) -- (output);

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.4 cm]a.east) -- ([yshift=\i * 0.8 cm]b.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.8 cm]b.east) -- ([yshift=\i * 0.8 cm]c.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.4 cm]a.east) to [out=-60,in=-120] ([yshift=\i * 0.8 cm]d.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.8 cm]d.east) -- ([yshift=\i * 0.8 cm]e.west) ;}

\end{scope}
\end{tikzpicture}

\end{document}
23

you can add two points in the path of the arc

\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usepackage{verbatim}
\usepackage[margin=15mm]{geometry}
\usetikzlibrary{shapes,arrows,fit,calc,positioning}


\begin{document}

\begin{tikzpicture}[thick]
\tikzset{input/.style={}}
\tikzset{block/.style={rectangle,draw}}
\tikzstyle{pinstyle} = [pin edge={to-,thick,black}]

\node [input, name=input] {};
\node [block, right=0.5 cm of input,minimum width=1.5cm, minimum height=2.5cm,red] (a) {};
\node [block, right of=a,minimum width=1.5cm, minimum height=5cm,node distance=3cm,blue] (b) {};
\node [block, right of=b, minimum width=2cm, minimum height=5cm,node distance=3cm,purple] (c) {};
\node [block, right of=c,minimum width=1.5cm, minimum height=5cm,node distance=3cm,green] (d) {};
\node [block, right of=d, minimum width=2cm, minimum height=5cm,node distance=3cm] (e) {};
\node [right =0.5 cm of e] (output) {};

\begin{scope}[->,>=latex]

\draw[->] (input) -- (a);

\node at (b.center) {\footnotesize{z}};

\draw[->] ([yshift=1.5 cm]c.north west) node[left]{\footnotesize{$Ack_1$}} -| ([xshift=0.25 cm]e.north);
\draw[->] ([yshift=1.5 cm]c.north west) -| ([xshift=0.25 cm]c.north);
\draw[->] ([yshift=1 cm]c.north west) node[left]{\footnotesize{$Ack_0$}} -| ([xshift=-0.25 cm]e.north);
\draw[->] ([yshift=1 cm]c.north west) -| ([xshift=-0.25 cm]c.north);
\draw[->] (e) -- (output);

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.4 cm]a.east) -- ([yshift=\i * 0.8 cm]b.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.8 cm]b.east) -- ([yshift=\i * 0.8 cm]c.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.4 cm]a.east) to [out=-0,in=90]  ([xshift={\i * 0.15 cm-0.75cm}]b.south west) to [out=-90,in=-90]  ([xshift={-\i * 0.15 cm+0.75cm}]c.south east)  to [out=90,in=-180]  ([yshift=\i * 0.8 cm]d.west) ;}

\foreach \i in {-2,...,2}{% 
\draw[->] ([yshift=\i * 0.8 cm]d.east) -- ([yshift=\i * 0.8 cm]e.west) ;}

\end{scope}
\end{tikzpicture}

\end{document}

enter image description here

15

Suggestion, don't use curved arrows and simplify the diagram.

enter image description here

What you are conveying is that from the input block the process is split into two sub-processes. The Ack lines can be repeated at top and bottom.

I would normally sketch a diagram in a program such as OpenOffice and then draw them using TikZ for inclusion in documents. It takes me about 5 minutes with OpenOffice and anything from three quarters of an hour (still) to an hour to get them right using TikZ, so I am not posting any code. If you adopt the approach, please post your code.

  • This design is also the first thing I thought of when seeing the first picture. The first sketch can be done even more effectively and quickly with pen and paper. – Alfred M. May 28 '12 at 12:20
  • 1
    @AlfredM. True, I should remind myself of Djikstra, his word processor was always hanging form a string in his office:) – Yiannis Lazarides May 28 '12 at 12:45
6

Code for Yiannis Lazarides's solution :

\begin{tikzpicture}[thick]
\tikzset{input/.style={}} 
\tikzset{block/.style={rectangle,draw}}
\tikzstyle{pinstyle} = [pin edge={to-,thick,black}]

\node [input, name=input] {};
\node [block, right=0.5 cm of input,minimum width=3cm, minimum height=5cm] (a) {};
\node [name = z] at ([xshift=4 cm]a.east) {};
\node [block, above=0.5 cm of z, minimum width=3cm, minimum height=5cm] (b) {};
\node [block, right=2.5 cm of b, minimum width=3cm, minimum height=5cm] (c) {};
\node [block, below=0.5 cm of z, minimum width=3cm, minimum height=5cm] (d) {};
\node [block, right=2.5 cm of d, minimum width=3cm, minimum height=5cm] (e) {};



\begin{scope}[>=latex]

\draw[->] ([yshift=1.5 cm,xshift=0.25 cm]c.north) node[right] {\footnotesize{$Ack_1$}} -- ([xshift=0.25 cm]c.north);
\draw[->] ([yshift=1.5 cm,xshift=-0.25 cm]c.north) node[left] {\footnotesize{$Ack_0$}} -- ([xshift=-0.25 cm]c.north);

\draw[->] (input) -- (a);

\draw ([yshift=1 cm,xshift=-0.25 cm]c.north)  -- ([yshift=1 cm,xshift=1 cm]c.north east);
\draw ([yshift=0.5 cm,xshift=0.25 cm]c.north)  -- ([yshift=0.5 cm,xshift=0.5 cm]c.north east);

\draw ([yshift=1 cm,xshift=1 cm]c.north east) -- ([yshift=-0.25 cm,xshift=1 cm]c.south east);
\draw ([yshift=0.5 cm,xshift=0.5 cm]c.north east) -- ([yshift=-0.75 cm,xshift=0.5 cm]c.south east);

\draw ([yshift=-0.25 cm,xshift=1 cm]c.south east) -- ([yshift=1.01 cm,xshift=-0.25 cm]e.north);
\draw ([yshift=-0.75 cm,xshift=0.5 cm]c.south east) -- ([yshift=0.51 cm,xshift=0.25 cm]e.north);

\draw[->] ([yshift=1.01 cm,xshift=-0.25 cm]e.north) -- ([xshift=-0.25 cm]e.north);
\draw[->] ([yshift=0.51 cm,xshift=0.25 cm]e.north) -- ([xshift=0.25 cm]e.north);

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.8 cm]a.east) -- ([yshift=\i * 0.8 cm]b.west) ;}

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.8 cm]a.east) -- ([yshift=\i * 0.8 cm]d.west) ;}

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.8 cm]b.east) -- ([yshift=\i * 0.8 cm]c.west) ;}

\foreach \i in {2,...,-2}{% 
\draw[->] ([yshift=\i * 0.8 cm]d.east) -- ([yshift=\i * 0.8 cm]e.west) ;}


\end{scope}
\end{tikzpicture}

This results into : enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.