# Drawing edges between nodes in Tikz diagram

I have a tikz image:

\begin{tikzpicture}[roundnode/.style={circle, draw=green!60, fill=green!5, very thick, minimum size=7mm}, squarednode/.style={rectangle, draw=blue!60, fill=blue!5, very thick, minimum size=5mm},>=stealth]
\node[squarednode, rounded corners] (1) {Some Text};
\node[squarednode, rounded corners, right=of 1] (2) {Some Text};
\node[squarednode, rounded corners, right=of 2] (3) {Some Text};
\draw[->] (1) edge node {} (2);
\draw[->] (2) edge node {} (3);
\end{tikzpicture}


I want to create a connection between the 3rd block and the 1st block as depicted below.

I don't know how to let the edge start on the right side of the 3rd block and end at the left side of the 1st block.

There are several ways to achieve this, all of which are variations of what you already did. You can use lines with corners like so:

\documentclass[tikz,border=5pt]{standalone}

\usetikzlibrary{positioning,calc}

\begin{document}
\begin{tikzpicture}[squarednode/.style={rectangle, draw=blue!60, fill=blue!5, very thick, minimum size=5mm,rounded corners},>=stealth]
\node[squarednode] (1) {Some Text};
\node[squarednode, right=of 1] (2) {Some Text};
\node[squarednode, right=of 2] (3) {Some Text};
\draw[->] (1) -- (2);
\draw[->] (2) -- (3);
\draw[->] (3.east) -| ++(.5,-1) -- ($(1.west)+(-.5,-1)$) |- (1.west);
\end{tikzpicture}
\end{document}


Which looks like so:

OR: You can use a line with specified exit and entrance angles, like so:

\documentclass[tikz,border=5pt]{standalone}

\usetikzlibrary{positioning,calc}

\begin{document}
\begin{tikzpicture}[squarednode/.style={rectangle, draw=blue!60, fill=blue!5, very thick, minimum size=5mm,rounded corners},>=stealth]
\node[squarednode] (1) {Some Text};
\node[squarednode, right=of 1] (2) {Some Text};
\node[squarednode, right=of 2] (3) {Some Text};
\draw[->] (1) -- (2);
\draw[->] (2) -- (3);
\draw[->] (3.east) to[out=-20,in=200] (1.west);
\end{tikzpicture}
\end{document}


Which looks like so:

Note of caution: Using the exit-entrance angles, you will end up with extra white space to the sides of the image, so you may want to clip the image to the desired size manually.

EDIT: To clip the image to the desired size, again there are many ways to this, but for me the easiest way is to first draw a rectangle around the image to make sure everything is on the inside and then replace draw by clip.

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{positioning,calc}

\begin{document}
\begin{tikzpicture}[squarednode/.style={rectangle, draw=blue!60, fill=blue!5, very thick, minimum size=5mm,rounded corners},>=stealth]
\draw (-1.5,-1) rectangle (7.3,1); % replace \draw with \clip
\node[squarednode] (1) {Some Text};
\node[squarednode, right=of 1] (2) {Some Text};
\node[squarednode, right=of 2] (3) {Some Text};
\draw[->] (1) -- (2);
\draw[->] (2) -- (3);
\draw[->] (3.east) to[out=-20,in=200] (1.west);
\end{tikzpicture}
\end{document}

• Thanks! How does the clipping work? I exactly have the issue that there is a lot of white space. Jun 18 at 14:04
• I added some instructions to get you started. Note: This is certainly not the most sophisticated approach, but it gets the job done. Jun 18 at 14:13