Search code examples
latexflowchart

Flowchart Draw with squared connections


I try to draw a diagram on the provided link from the "act" to the decision diamond up on the beginning of the flow chart, but I fail. I would like to draw a connection arrow from block to the diamond without crossing the other blocks. Could someone help me to do it?

https://www.overleaf.com/1327913296kgkmkvmhqgmj

Best regards Bruno


Solution

  • If I understood weel, maybe adding some hidden nodes may be of some help:

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    
    \usepackage{tikz}
    \usepackage{csquotes}
    \usetikzlibrary{shapes,arrows}
    
    \input{config}
    
    \begin{document}
    \begin{figure}[!htp]
        \centering
        \begin{tikzpicture}[node distance = 2cm, auto]
            % Place nodes
            \node [cloud] (init) {Initialize};
            \node [block, left of = init, node distance = 4cm] (estimate) {Estimate};
            \node [block, below of = estimate, node distance = 3cm] (compute) {Compute};    
            \node [decision, below of = init] (decide_exploration) {$t \in (t_i, \, t_{i+1})$?};
            \node [decision, below of = decide_exploration, node distance = 4cm] (decide_sample) {$t_s \in (t_s^0, \, t_s^0 + T_s)$?};
            \node [block, right of = decide_sample, node distance = 4cm] (sample) {Sample};
            \node [block, below of = decide_sample, node distance = 4cm] (control) {Act};
            \node [below of = control, node distance = 2cm] (control2) {};
            \node [right of = control2, node distance = 6cm] (control3) {};
            \node [right of = decide_exploration, node distance = 2cm] (sample2) {};
    
            % Draw edges
            \path [line, dashed] (init) -- (estimate);
            \path [line] (estimate) -- (compute);
            \path [line] (compute) |- (control);
            \path [line] (decide_exploration) -- node {yes} (decide_sample);
            \path [line] (decide_exploration) -- node {no} (estimate);
            \path [line] (decide_sample) -- node {yes} (control);
            \path [line] (decide_sample) -- node {no} (sample);
            \path [line] (sample) |- (control);
                    \path [line] (control) |-(6,-13) |-(sample2) |-(decide_exploration);
    
        \end{tikzpicture}
        \caption{Source seeking algorithm}
        \label{fig:sseeking_algo}
    \end{figure}
    
    \end{document}
    

    I used some funny names for the hidden nodes, you may find something more significant..

    EDIT: I edited the last line, so the corner is not missing anymore.