[Tex/LaTex] Drawing arrows from different edges of node/decision box

arrowstikz-pgf

I'm new to tikz and don't understand how to draw lines originating from all edges of a decision box to other nodes.

In the diagram below flow chart,
how can I specify the originating point of an arrow? For e.g I want to draw an arrow from the bottom of Decision1 to the left edge of Decision2 but just can't figure out how.

My code:

\documentclass{article}
\usepackage{tikz}
\usepackage{fixltx2e}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{document}
\pagestyle{empty}

% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20, 
    text width=6.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, 
    text width=10em, text centered, rounded corners, minimum height=4em]
\tikzstyle{mycircle} = [circle, thick, draw=orange, minimum height=4mm]

\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\begin{tikzpicture}[align=center,node distance = 2cm, auto]
    % Place nodes
    \node [block] (init) {Read system data};
    \node [block, right of=init, node distance=6cm] (trip) {Trip};

    \node [block, below of=init, node distance=2.7cm] (setloadavg)
             {Set average loading level to L\textsubscript{avg}=[0.8,0.9,1,1.1]};
    \node [decision, right of=setloadavg, node distance=6cm] (decision2) {Decision2};
    \node [block, right of=decision2, node distance=3cm] (stop1) {Stop};

    \node [block, below of=setloadavg, node distance=3cm] (setk) {Set K};
    \node [decision, right of=setk, node distance=6cm] (decision3) {Decision3};
    \node [mycircle, right of=decision3, node distance=4cm] (circle1) {1};

    \node [block, below of=setk, node distance=2cm] (startsim)
        {Start simulation (run 1) to generate cascade data, K=0};
    \node [block, right of=startsim, node distance=6cm] (increment) {Increment};
    \node [mycircle, left of=startsim, node distance=4cm] (circle2) {2};

    \node [block, below of=startsim, node distance=3cm] (setloadlevel) {Set Load level};
    \node [decision, right of=setloadlevel, node distance=6cm] (decision4) {Decision4};
    \node [mycircle, right of=decision4, node distance=4cm] (circle3) {2};

    \node [block, below of=setloadlevel, node distance=3cm] (runloadflow) {Run load flow};
    \node [block, right of=runloadflow, node distance=6cm] (stop2) {stop};

    \node [decision, below of=runloadflow, node distance=3cm] (decision1) {Decision1};
    \node [mycircle, left of=decision1, node distance=4cm] (circle2) {1};


    % Draw edges
    \path [line] (init) -- (setloadavg);
    \path [line] (setloadavg) -- (setk);
    \path [line] (setk) -- (startsim);
    \path [line] (startsim) -- (setloadlevel);
    %\path [line] (startsim) -- (circle2);
    \path [line] (setloadlevel) -- (runloadflow);
    \path [line] (runloadflow) -- (decision1);
    \path [line] (decision1) -- node [near start] {Yes} +(3,0) |-  (trip);


\end{tikzpicture}
\end{document}

I would appreciate some explanation of the solution and pointers to documentation, if possible.

Thanks

Best Answer

One possibility:

\documentclass{article}
\usepackage{tikz}
\usepackage{fixltx2e}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{positioning}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>
\begin{document}
\pagestyle{empty}

% Define block styles
\tikzstyle{decision} = [diamond, draw, fill=blue!20,
    text width=6.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20,
    text width=10em, text centered, rounded corners, minimum height=4em]
\tikzstyle{mycircle} = [circle, thick, draw=orange, minimum height=4mm]

\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm,
    minimum height=2em]

\begin{tikzpicture}[align=center,node distance = 2cm, auto]
    % Place nodes
    \node [block] (init) {Read system data};
    \node [block, right of=init, node distance=6cm] (trip) {Trip};

    \node [block, below of=init, node distance=2.7cm] (setloadavg)
             {Set average loading level to L\textsubscript{avg}=[0.8,0.9,1,1.1]};
    \node [decision, right of=setloadavg, node distance=6cm] (decision2) {Decision2};
    \node [block, right of=decision2, node distance=3cm] (stop1) {Stop};

    \node [block, below of=setloadavg, node distance=3cm] (setk) {Set K};
    \node [decision, right of=setk, node distance=6cm] (decision3) {Decision3};
    \node [mycircle, right of=decision3, node distance=4cm] (circle1) {1};

    \node [block, below of=setk, node distance=2cm] (startsim)
        {Start simulation (run 1) to generate cascade data, K=0};
    \node [block, right of=startsim, node distance=6cm] (increment) {Increment};
    \node [mycircle, left of=startsim, node distance=4cm] (circle2) {2};

    \node [block, below of=startsim, node distance=3cm] (setloadlevel) {Set Load level};
    \node [decision, right of=setloadlevel, node distance=6cm] (decision4) {Decision4};
    \node [mycircle, right of=decision4, node distance=4cm] (circle3) {2};

    \node [block, below of=setloadlevel, node distance=3cm] (runloadflow) {Run load flow};
    \node [block, right of=runloadflow, node distance=6cm] (stop2) {stop};

    \node [decision, below of=runloadflow, node distance=3cm] (decision1) {Decision1};
    \node [mycircle, left of=decision1, node distance=4cm] (circle2) {1};


    % Draw edges
    \path [line] (init) -- (setloadavg);
    \path [line] (setloadavg) -- (setk);
    \path [line] (setk) -- (startsim);
    \path [line] (startsim) -- (setloadlevel);
    %\path [line] (startsim) -- (circle2);
    \path [line] (setloadlevel) -- (runloadflow);
    \path [line] (runloadflow) -- (decision1);
    \path [line] (decision1) -- node [near start] {Yes} +(3,0) coordinate (my coord) |-  (trip);
    \path [line] (decision1.south) -- +(0,-20pt) -| ([xshift=5pt, yshift=-5pt]my coord) |- (decision2.west);


\end{tikzpicture}
\end{document}

By placing a coordinate on the previous line, we can navigate around it when placing the new arrow's path. .south and .west are anchors of the nodes decision1 and decision2, corresponding to the exit and entry point you want. Using the xshift...,yshift... ensures that the line goes near to the previous one, without being right on top of it.

Note that some of your syntax is outdated. For example, you should use \tikzset rather than \tikzstyle.

additional arrow