There is a way to draw a flowchart with decision nodes, like this, using smartdiagram or something else?
[Tex/LaTex] Draw a flowchart with decision box with smartdiagram
smartdiagramtikz-pgf
Related Solutions
There is an aspect
option for the diamond shape, which sets the target ration of the height and width. By default it is one. See section 48.3 “Geometric Shapes” in the manual (v2.10).
\documentclass{article}
\usepackage{amsmath,tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node [draw, diamond, aspect=2] {$\lVert f(\mathbf{x}^{0}) \rVert < \varepsilon_{g}$};
\end{tikzpicture}
\end{document}
You need to do split your path up in a few sub-paths:
\path [line] (decide) -| node [near start] {no} ([xshift=-1cm] W_legali.west)
|- ([yshift=+1cm, xshift=-.2cm] init.north) coordinate (aux)
-- ([xshift=-.2cm] init.north);
\path [line] (update) |- ([xshift=.4cm] aux) -- ([xshift=.2cm] init.north);
Code
\documentclass[tikz,]{standalone}
\usepackage[italian]{babel}
\usetikzlibrary{arrows,shapes.geometric,positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 2cm,
auto,
decision/.style={diamond, draw, fill=blue!20,
text width=4.5em, align=center, node distance=3cm, inner sep=0pt},
block/.style={rectangle, draw, fill=blue!20,
text width=5em, align=center, rounded corners, minimum height=4em},
line/.style={draw, -latex'},
cloud/.style={draw, ellipse,fill=red!20, node distance=3cm,
minimum height=2em},
% on grid
]
% Place nodes
\node [block] (init) {Generazio-ne scariche ($2^H$)};
\node [block, left=of init] (W_legali) {$\mu_W$ \\ $\rho_b^{-1}=\frac{P}{n_b+1}$};
\node [block, right=of init] (W_nlegali) {$\mu_W$ \\ $\rho_b^{-1}=\frac{P}{n_b}$};
\node [block, below=of W_legali] (fo_legale) {$\min$ $f.o_{W \ge W_L}$};
\node [block, below=of W_nlegali] (fo_nlegale) {$\min$ $f.o_{W < W_L}$};
\node [decision, below=3cm of init] (decide)
{$\min$ $f.o_{W \ge W_L}$ \\${}< \min$ $ f.o_{W < W_L}$};
\node [block, right=of fo_nlegale] (update) {Aggiorno $n_b$};
% Draw edges
\path [line] (init) -- node[swap] {$W_i \ge W_L$} (W_legali);
\path [line] (init) -- node {$W_i < W_L$} (W_nlegali);
\path [line] (W_legali) -- (fo_legale);
\path [line] (W_nlegali) -- (fo_nlegale);
\path [line] (fo_legale) -- (decide);
\path [line] (fo_nlegale) -- (decide);
\path [line] (decide) -| node [near start] {si} (update);
\path [line] (decide) -| node [near start] {no} ([xshift=-1cm] W_legali.west)
|- ([yshift=+1cm, xshift=-.2cm] init.north) coordinate (aux)
-- ([xshift=-.2cm] init.north);
\path [line] (update) |- ([xshift=.4cm] aux) -- ([xshift=.2cm] init.north);
\end{tikzpicture}
\end{document}
Best Answer
In my opinion, I ought not answer this question. Caveat emptor.
For one thing, my answer is likely to be of little help unless you want precisely this with almost no changes, or you could actually do this yourself but just wanted somebody else to do your work for free. Only in the second case are you likely to be able to modify it to your needs without actually doing some work to figure out how things work, which you could have done anyhow.
For another different but related thing, my answer contains zero explanation because I simply have no idea what needs explaining or where you are starting from. That is, I have no idea what the obstacle is to your drawing this yourself. Since I cannot explain everything here and have no idea what needs explaining, I can't usefully explain anything at all.
I really answered this because I wanted to play with the
graphs
syntax without thegraphsdrawing
code, which depends on LuaTeX. If you know nothing about PGF/TikZ, this is not a good place to start. In that case, start with thepositioning
library withoutgraphs
or try the deprecatedchains
library if feeling especially adventurous.