With PGF/TikZ you can draw flow charts with relative ease. This flow chart from [1] outlines an algorithm for identifying the parameters of an autonomous underwater vehicle model.
Note that relative node placement has been used to avoid placing nodes explicitly. This feature was introduced in PGF/TikZ >= 1.09.
| [1] | Bossley, K.; Brown, M. & Harris, C. Neurofuzzy identification of an autonomous underwater vehicle International Journal of Systems Science, 1999, 30, 901-913 |
\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}
% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em]
\begin{tikzpicture}[node distance = 2cm, auto]
% Place nodes
\node [block] (init) {initialize model};
\node [cloud, left of=init] (expert) {expert};
\node [cloud, right of=init] (system) {system};
\node [block, below of=init] (identify) {identify candidate models};
\node [block, below of=identify] (evaluate) {evaluate candidate models};
\node [block, left of=evaluate, node distance=3cm] (update) {update model};
\node [decision, below of=evaluate] (decide) {is best candidate better?};
\node [block, below of=decide, node distance=3cm] (stop) {stop};
% Draw edges
\path [line] (init) -- (identify);
\path [line] (identify) -- (evaluate);
\path [line] (evaluate) -- (decide);
\path [line] (decide) -| node [near start] {yes} (update);
\path [line] (update) |- (identify);
\path [line] (decide) -- node {no}(stop);
\path [line,dashed] (expert) -- (init);
\path [line,dashed] (system) -- (init);
\path [line,dashed] (system) |- (evaluate);
\end{tikzpicture}
\end{document}
Comments
A little improvement
i read it so it is intersting
Very helpful, thanks! It seems the code for formatting the yes/no nodes can also be styled:
You can also use anchors like decide.east if you want to force the arrows to come out of the points of the decision rhombus. This isn't needed here but if you want a diagonal line coming out of the decision node it will by default come from the center and emerge from one of the sides.
In the PGF >= 2.0 manual there is a version of this flow chart that uses a tikz matrix to place the blocks. Requires less typing than my version.
I have the 2.0 manual and I didn't catch it, which is why I turned to google and found this page. Guess I'll look harder.
Section "16.6 Examples". Page 181 in the current CTAN version of the manual (PGF 2.0).
Found it, thanks!
Meanwhile this section has another number, so reference by name would be easier. ;-)
It's part III, chapter »Matrices and Alignment«, section »Examples«. 8-)
How do I do an other box around system, initialize model and expert? I need this for modified flow chart.
I want To learn how to make a flowchart easily!!
Drop the semicolon for avoiding the semicolon at the top of the picture.
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em];
@John Chain: Fixed.
Would it be possible to include a figure (e.g. eps from R software) within a block so that it can be included in the flow chart?
Thanks, Jan
@Jan: You can put nearly anything inside a node, including an eps or pdf:
Very helpful!
If the "update" block is removed ..how to connect the path between the decision block and the "identify" block
Post a comment