1

enter image description here
I want to draw a line from block 2 to block 7 but I get this error (! Package pgf Error: No shape named m-2-2 is known)

\tikzset{
desicion/.style={
    diamond,
    draw,
    text width=5em,
    text badly centered,
    inner sep=0pt
},
block/.style={
    rectangle,
    draw,
    text width=10em,
    text centered,
    rounded corners
},
cloud/.style={
    draw,
    ellipse,
    minimum height=2em
},
descr/.style={
    fill=white,
    inner sep=2.5pt
},
connector/.style={
    -latex,
    font=\scriptsize
},
rectangle connector/.style={
    connector,
    to path={(\tikztostart) -- ++(#1,0pt) \tikztonodes |- (\tikztotarget) },
    pos=0.5
},
rectangle connector/.default=-2cm,
straight connector/.style={
    connector,
    to path=--(\tikztotarget) \tikztonodes
}
}



\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=2cm,row  sep=8mm, align=center, nodes={rectangle,draw, anchor=center} ]
{
    |[block]| {Start}                       &  \\
    |[desicion]| {$d^{(i)}_{(n,m)} < 2r$?}  &  \\
    |[block]| {Estimate $I_{n,p}^{(i)} \rightarrow FBS_m$ }    & \\
    |[block]| {Estimate $\zeta^{(i*)}$ and $\varphi^{(i*)}_{n,p}$}    &   \\
    |[desicion]| {$o^{(i+1)}_{(n,m)} > o^{(i)}_{(n,m)}$?}  &  \\
    |[block]| {Apply}    &   \\
    |[block]| {End}    & \\
};
\path [>=latex,->] (m-1-1) edge (m-2-1);
\path [>=latex,->] (m-2-1) edge (m-3-1);
\path [>=latex,->] (m-3-1) edge (m-4-1);
\path [>=latex,->] (m-4-1) edge (m-5-1);
\path [>=latex,->] (m-5-1) edge (m-6-1);
\path [>=latex,->] (m-6-1) edge (m-7-1);
\path [>=latex,->] (m-2-2) edge (m-7-2);

\end{tikzpicture}
  • 1
    Hi, welcome. You get that error because there are no nodes in the second column. What exactly are you after, something like \draw [>=latex,->] (m-2-1) -- ++(3,0) |- (m-7-1); or \draw [>=latex,->] (m-2-1.east) to[bend left] (m-7-1.east);, or do you want a vertical arrow running parallel to the blocks in the first column? – Torbjørn T. Nov 22 '17 at 17:19
  • 1
    Add nodes in empty cells to the matrix options. This will assign a name to all empty positions in second column. – Ignasi Nov 22 '17 at 19:31
2

You can do a matrix with only one column, you should not use & if you don't need it:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix, arrows.meta, shapes}
\tikzset{
    desicion/.style={
        diamond,
        draw,
        text width=5em,
        text badly centered,
        inner sep=0pt
    },
    block/.style={
        rectangle,
        draw,
        text width=10em,
        text centered,
        rounded corners
    },
    cloud/.style={
        draw,
        ellipse,
        minimum height=2em
    },
    descr/.style={
        fill=white,
        inner sep=2.5pt
    },
    connector/.style={
        -latex,
        font=\scriptsize
    },
    rectangle connector/.style={
        connector,
        to path={(\tikztostart) -- ++(#1,0pt) \tikztonodes |- (\tikztotarget) },
        pos=0.5
    },
    rectangle connector/.default=-2cm,
    straight connector/.style={
        connector,
        to path=--(\tikztotarget) \tikztonodes
    }
}

\begin{document}
\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=2cm,row  sep=8mm, align=center, nodes={rectangle,draw, anchor=center} ]
{
    |[block]| {Start}                         \\
    |[desicion]| {$d^{(i)}_{(n,m)} < 2r$?}    \\
    |[block]| {Estimate $I_{n,p}^{(i)} \rightarrow FBS_m$ }    \\
    |[block]| {Estimate $\zeta^{(i*)}$ and $\varphi^{(i*)}_{n,p}$}     \\
    |[desicion]| {$o^{(i+1)}_{(n,m)} > o^{(i)}_{(n,m)}$?}   \\
    |[block]| {Apply}      \\
    |[block]| {End}    \\
};
\path [-Latex] (m-1-1) edge (m-2-1);
\path [-Latex] (m-2-1) edge (m-3-1);
\path [-Latex] (m-3-1) edge (m-4-1);
\path [-Latex] (m-4-1) edge (m-5-1);
\path [-Latex] (m-5-1) edge (m-6-1);
\path [-Latex] (m-6-1) edge (m-7-1);
\draw [-Latex] (m-2-1.east) -- ++(2,0) |- (m-7-1.east);
\end{tikzpicture}
\end{document}

enter image description here

1

like this?

enter image description here

but above image i draw with nodes in chain (because this way is more simple to me and gives more concise and clear code):

\documentclass[tikz, margin=3mm]{standalone}
\usetikzlibrary{arrows.meta, chains, positioning, shapes}

\begin{document}
\tikzset{
desicion/.style={
    diamond,
    draw,
    text width=6em,
    aspect=1.2,
    align=flush center,
    inner sep=-0pt
},
block/.style={
    rectangle,
    draw,
    text width=10em,
    text centered,
    rounded corners
}
        }% end of tikzset

\begin{tikzpicture}[
           node distance = 5mm and 7mm,
             start chain = A going below,
every node/.append style = {on chain=A, join=by -Latex}
                    ]
\node[block]    {Start};
\node[desicion] {$d^{(i)}_{(n,m)} < 2r$?};
\node[block]    {Estimate $I_{n,p}^{(i)} \rightarrow FBS_m$};
\node[block]    {Estimate $\zeta^{(i*)}$ and $\varphi^{(i*)}_{n,p}$};
\node[desicion] {$o^{(i+1)}_{(n,m)} > o^{(i)}_{(n,m)}$?};
\node[block]    {Apply};
\node[block]    {End};
%
\draw[-Latex] (A-2.east) -- ++ (1,0) |- (A-7);
\end{tikzpicture}
\end{document}

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.