2

I want to draw a flowchart using tikz trees.

I would like to change the style of some of my edges. I want the edges from W to GI2 and GI4 to be curved.

I try to use child from parent path={... but it doesn't work (problem with \tikzparentnode ?).

Could you explain me how to do that ?
Thanks !

Here is my code

\documentclass{article}

\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning,shadows,arrows,shapes,shapes.arrows,trees}

\tikzset{
    wait/.style={circle, draw=black, text centered, anchor=north, text=black, font=\scriptsize},
    adopt/.style={single arrow, draw=black, minimum height=1cm, minimum width=0.8cm, single arrow head extend=.15cm, inner sep=0.1cm, text centered, anchor=north, text=black, font=\footnotesize},
    end/.style={draw=none, fill=none, text centered, anchor=north}
}

\begin{document}

\begin{figure}[h]
    \begin{tikzpicture}[level distance=0.3cm, growth parent anchor=south,sibling distance = 3.7cm, align=center]
        \node (start) [end] {Begin $P_{I0-1}$} [->]
        child{[level distance=0.5cm]
            node (adopt5) [adopt, label=0:{\textbf{label 1}}] {$G_{I1}$}
            child{[level distance=1cm, sibling distance=5cm]
                node (w) [wait] {$\mathcal{W}$}
                child{[level distance=0.6cm]
                    node (g1) [adopt, label=0:{\textbf{label 2}}] {$G_{I2}(f)$}
                    child{
                        node (bye1) [end] {}
                    }
                    edge from parent node[pos=0.2,left=0.6cm]  {label on edge 1}
                }
                child{[level distance=0.6cm]
                    node (g2) [adopt, label=0:{\textbf{label 3}}] {$G_{I3}(f)$}
                    child{
                        node (bye2) [end] {}
                    }
                    edge from parent node[pos=0.3]  {label on edge 2}
                }
                child{[level distance=0.6cm]
                    node (g3) [adopt, label=0:{\textbf{label 4}}] {$G_{I4}(f)$}
                    child{[-]
                        node (bye3) [end] {}
                    }
                    edge from parent node[pos=0.2,right=0.6cm]  {label on edge 3}
                }
            }
        };

        \draw [->] (bye3.north) --  (bye2.north) -- (bye1.north) -- (-6cm,-4.63cm) -- (-6cm,-1.6cm) -- (0cm,-1.6cm);
    \end{tikzpicture}
\end{figure}

\end{document}

enter image description here

3

Why do you want to use a tree?

\documentclass[tikz,border=2mm]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning,shadows,arrows,shapes,shapes.arrows,trees}

\tikzset{
    wait/.style={circle, draw=black, text centered, anchor=north, text=black, font=\scriptsize},
    adopt/.style={single arrow, draw=black, minimum height=1cm, minimum width=0.8cm, single arrow head extend=.15cm, inner sep=0.1cm, text centered, anchor=north, text=black, font=\footnotesize},
    end/.style={draw=none, fill=none, text centered, anchor=north}
}

\begin{document}

    \begin{tikzpicture}[]
        \node[end] (start) [end] {Begin $P_{I0-1}$};
        \node[adopt] (adopt5) [below=0.5 of start, label=0:{\textbf{label 1}}] {$G_{I1}$};
        \node[wait] (w) [below=1cm of adopt5] {$\mathcal{W}$};
        \node[adopt, below left=1cm and 3.7cm of w] (g1) [label=0:{\textbf{label 2}}] {$G_{I2}(f)$};
         \node[adopt, below right=1cm and 3.7cm of w] (g3) [label=0:{\textbf{label 4}}] {$G_{I4}(f)$};

        \node[adopt,anchor=center] (g2) [label=0:{\textbf{label 3}}] at (g1-|w) {$G_{I3}(f)$};


        \draw[->] (start)--(adopt5);
        \draw[->] (adopt5)-- coordinate (aux) (w);
        \draw[->] (w) to [out=185, in=90] node[above left]{label on edge 1} (g1.north);
        \draw[->] (w) -- node{label on edge 2} (g2.north);
        \draw[->] (w) to [out=-5, in=90] node[above right]{label on edge 3} (g3.north);
            \draw[->] (g1.south)--++(-90:1cm);
            \draw[->] (g2.south)--++(-90:1cm);
            \draw[->] (g3.south)|-([shift={(-1cm,-1cm)}]g1.south west)|-(aux);
    \end{tikzpicture}


\end{document}

enter image description here

1
  • Oh ! Indeed... It is much simpler. I used trees because my flowchart was a tree. But a day, it became a graph and i didn't change the code.
    – Adhafera
    Jun 16 '16 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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