[Tex/LaTex] How to center a node below two nodes and create an arrow to another arrow

tikz-arrowstikz-pgf

I have the following code, which generates the image shown below.

\tikzstyle{decision} = [diamond, draw, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, text width=5em, text centered, rounded corners, minimum height=4em]
\tikzstyle{bigblock} = [rectangle, draw, text width=10em, text centered, rounded corners, minimum height=4em]
\tikzstyle{invisible} = [rectangle, node distance=3cm, text=white]
\tikzstyle{line} = [draw, -latex']

\begin{tikzpicture}[node distance = 2.5cm, auto, scale=1.0, every node/.style={transform shape}]

% Place nodes
\node [block] (c0) {c0};
\node [block, right of=c0, node distance=3cm] (c1) {c1};
\node [bigblock, below of=c0] (point) {ver};
\node [decision, below of=point] (check) {?};
\node [bigblock, below of=check] (resume) {resume};
\node [bigblock, right of=check, node distance=4cm] (rollback) {rollback};
\node [invisible, below left of=resume] (c02) {};
\node [invisible, below right of=resume] (c12) {};

% Draw edges
\path [line] (c0) -- (point);
\path [line] (c1) -- (point);
\path [line] (point) -- (check);
\path [line] (check) -- node [near start] {yes} (resume);
\path [line] (check) -- node [near start] {no} (rollback);
\path [line] (resume) -- (c02);
\path [line] (resume) -- (c12);

\end{tikzpicture}

enter code here

I'm trying to center the node (point) below (c0) and (c1), so that the arrows to the node are also straight. I also wanted the last two arrows, coming from node (resume) to be straight. I was also trying to create an arrow coming from node (rollback) to the arrow between (c1) and (point) but I don't know how to do it. If somebody could help I'd be truly grateful!

Best Answer

These things are all straightforward if you make use of the |- and -| syntax, which has been explained very well in this answer by Torbjørn T..

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{shapes,arrows.meta}
\begin{document}
\tikzset{decision/.style={diamond, draw, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt},
block/.style={rectangle, draw, text width=5em, text centered, rounded corners, minimum height=4em},
bigblock/.style={rectangle, draw, text width=10em, text centered, rounded corners, minimum height=4em},
invisible/.style={rectangle, node distance=3cm, text=white},
line/.style={draw, -latex}}

\begin{tikzpicture}[node distance = 2.5cm, auto, scale=1.0, every node/.style={transform shape}]

% Place nodes
\node [block] (c0) {c0};
\node [block, right of=c0, node distance=3cm] (c1) {c1};
\path (c0) -- (c1) coordinate[midway] (aux);
\node [bigblock, below of=aux] (point) {ver};
\node [decision, below of=point] (check) {?};
\node [bigblock, below of=check] (resume) {resume};
\node [bigblock, right of=check, node distance=4cm] (rollback) {rollback};
\node [invisible, below of=resume,xshift=-1cm] (c02) {};
\node [invisible, below of=resume,xshift=1cm] (c12) {};

% Draw edges
\path [line] (c0) -- (c0|-point.north);
\path [line] (c1) -- (c1|-point.north) coordinate[midway](aux2);
\path [line] (point) -- (check);
\path [line] (check) -- node [near start] {yes} (resume);
\path [line] (check) -- node [near start] {no} (rollback);
\path [line] (rollback) |- (aux2);
\path [line] (resume.south -| c02) -- (c02);
\path [line] (resume.south -| c12) -- (c12);

\end{tikzpicture}
\end{document}

enter image description here

Related Question