1

I drew the following flow chart using a matrix in tikz (the code has been taken from this question):

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains}

\begin{document}

\tikzset{
decision/.style={
diamond,
draw,
text width=4em,
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=.5
},
rectangle connector/.default=-2cm,
straight connector/.style={
connector,
to path=--(\tikztotarget) \tikztonodes
}
}

\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=.8cm,row  sep=6mm, 
align=center, nodes={rectangle,draw, anchor=center} ]{
|[block]| {Start}              &  \\
|[block]| {Setting up the system }               &                                            
\\
|[block]| {Execute benchmarking applications}    &                                             
\\
     |[block]| {Retrieve data for VNF and NFVI KPIs}  & |[block]| 
{Change parameters}   \\        
       |[block]| {Data synthesis and Analysis}       &  \\
       |[decision]| {Something meaningful ?}          &   \\
             |[block]| {Perform statistical operations}    &  \\
             |[block]| {Stop}\\
};
\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-7-1) edge (m-8-1);
\draw [rectangle connector=2.5cm] (m-6-1) to node[descr, pos=0.5] {No} (m-4-2);
\draw [rectangle connector=2.5cm] (m-4-2) to (m-3-1);
\end{tikzpicture}

\end{document}

This gives me the following output:

Current Output

Want to connect the box on the right to and from the middle (as shown in the attached picture). Wanted Output

4

You have a path with an edge label No. The rectangle connector is not made for this setup. The way you can draw this with the edge label is

  \draw [connector]  (<start>)  -| node[descr, pos=0.25] {No}  (<target>);

You are also loading chains. In general I am not a fan of using this library everywhere, but your graph is IMHO an example where this could make sense. This makes the code a bit shorter and allows us to avoid repetition. (If you keep matrix, please consider adding cells={nodes={block}} and to remove all the |[block]| to make the code shorter.) I also made a few other small layout changes to arrive at

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,positioning,chains}

\begin{document}

\tikzset{
decision/.style={
diamond,
draw,
text width=4em,
align=center,
%text badly centered,
inner sep=0pt,
rounded corners=false
},
block/.style={
rectangle,
draw,
text width=10em,
text centered,
rounded corners
},
connector/.style={
-latex,
font=\scriptsize
},
descr/.style={
fill=white,
inner sep=2.5pt
},
}

\begin{tikzpicture}[node distance=5mm,node font=\sffamily]
\begin{scope}[start chain=1 going below,nodes={on chain,join,block},
every join/.style={connector}]
 \path node{Start} 
    node{Setting up the system} 
    node {Execute benchmarking applications}
    node  {Retrieve data for VNF and NFVI KPIs}
    node {Data synthesis and Analysis}
    node[decision] {Some-\\thing meaning-ful?}
    node {Stop};
\end{scope}
  \path (1-4.east) -- node[right=8mm,block] (CP) {Change parameters}
        (1-5.east);
  \draw [connector] (1-6) -| node[descr, pos=0.25] {No} (CP);
  \draw [connector] (CP) |- (1-3);
\end{tikzpicture}
\end{document}

enter image description here

|improve this answer|||||
0

Tikz allows to build horizontal and vertical paths between two objects (points, nodes) with the syntax -| and |-. See page 153 of manual 3.1.4b.

\draw [rectangle connector=2.5cm] (m-6-1) -|  (m-4-2.south);
\draw [rectangle connector=2.5cm] (m-4-2) |- (m-3-1);

screenshot

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,arrows,positioning,chains}

\begin{document}

\tikzset{
decision/.style={
diamond,
draw,
text width=4em,
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=.5
},
rectangle connector/.default=-2cm,
straight connector/.style={
connector,
to path=--(\tikztotarget) \tikztonodes
}
}

\begin{tikzpicture}
\matrix (m)[matrix of nodes, column  sep=.8cm,row  sep=6mm, 
align=center, nodes={rectangle,draw, anchor=center} ]{
|[block]| {Start}              &  \\
|[block]| {Setting up the system }               &                                            
\\
|[block]| {Execute benchmarking applications}    &                                             
\\
     |[block]| {Retrieve data for VNF and NFVI KPIs}  & |[block]| 
{Change parameters}   \\        
       |[block]| {Data synthesis and Analysis}       &  \\
       |[decision]| {Something meaningful ?}          &   \\
             |[block]| {Perform statistical operations}    &  \\
             |[block]| {Stop}\\
};
\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-7-1) edge (m-8-1);
\draw [rectangle connector=2.5cm] (m-6-1) -|  (m-4-2.south);
\draw [rectangle connector=2.5cm] (m-4-2) |- (m-3-1);
\end{tikzpicture}

\end{document}
|improve this answer|||||
0

You can achieve this even without the "rectangle connector". In the question you linked, you can see that these kind of connectors are already present in the original code. In your specific case, you can simply use

\draw [>=latex,->] (m-6-1) -| (m-4-2);
\draw [>=latex,->] (m-4-2) |- (m-3-1);

where -| and |- give you the desired behaviour:

Output

|improve this answer|||||

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.