Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am working on this example: Simple flow chart

\documentclass{article}
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\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}

I would like to remove the "update model" node and to connect directly the decision node node and the "identify..." one with an horizontal-vertical-horizontal line. I naively tried to use

 \path [line] (decide) -|- node [near start] {yes} (identify)

but it doesn't work.

Is there any simple way to do this?

share|improve this question
3  
Welcome to TeX.SX. See if Vertical and horizontal lines in pgf-tikz helps –  Torbjørn T. Jul 4 '13 at 16:14

1 Answer 1

The syntax -|- is not defined by default, so if you want to use it you need to load Qrrbrbirlbel's paths.ortho library.

Another possibility would be to use the |- (or -|) syntax. It represents the intersection point between a vertical and a horizontal line. You can find more information at Flowchart - draw line from node to edge. or How to draw a return arrow from node-3 to node-1.

Using it, it is easy to draw a connection between (decide) and (identify):

    \path [line] (decide) --(decide-|expert) |- (identify);

(decide)--(decide-|expert) draws a line between decide.center to the intersection point defined by a horizontal line across decide.center and a vertical line across expert.center. This line uses decide.center as origin, but it will start to be drawn at decide border.

(decide-|expert) |- (identify) will draw a vertical line with origin at (decide-|expert) which will stop at identify.center y coordinate. From there a horizonta line will be drawn to the (identify) border.

\documentclass[tikz]{standalone}
\usepackage[latin1]{inputenc}
\usetikzlibrary{shapes,arrows}
\usepackage{verbatim}
\begin{document}
% 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) --(decide-|expert) |- (identify);
%    \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}

enter image description here

share|improve this answer
    
Thanks a lot, very nice and simple solution. –  hardhu Jul 5 '13 at 8:13
    
@hardhu. Glad to help you! I'd suggest to read this Welcome to TeX.SX! information and better know how this site works. –  Ignasi Jul 5 '13 at 10:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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