# Connect vertices of a regular poly by curved arrows

I have a diagram that is simply a set of nodes distributed evenly around a circle. How can I connect the nodes with arrows that are circular?

e.g., suppose we have a pentagon with nodes at each vertex. Obviously the vertices of the pentagon all lay on a circle. I want to connect the nodes by arrows that are "parallel" to the circle. (so overall it looks like a cycle)

-

Here is a possibility: using twice nodes of type regular polygon, one internal and the other one external, both placed on circles.

\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\newcommand{\polygonsides}{5}

\begin{document}
\begin{minipage}[t][0.3\textheight]{0.45\textwidth}
Clockwise [option \texttt{bend left}]:
\begin{flushleft}
\begin{tikzpicture}
% Internal cirlce with polygon
\draw[blue](0,0)circle(1.5cm);
\node[regular polygon, regular polygon sides=\polygonsides, minimum size=3cm, draw, name=x] at (0,0) {};
% Nodes on vertices
\foreach \corner in {1,2,...,\polygonsides}
\node[circle,ball color=blue] at (x.corner \corner){};

% External polygon
\node[regular polygon, regular polygon sides=\polygonsides, minimum size=4cm, draw=none, name=p] at (0,0) {};
% Invisible nodes on vertices
\foreach \corner in {1,2,...,\polygonsides}
\node at (p.corner \corner){};

% Connections
\foreach \source/\destination in {p.corner 1/p.corner 5,p.corner 5/p.corner 4,p.corner 4/p.corner 3,p.corner 3/p.corner 2,p.corner 2/p.corner 1}
\draw[-stealth,shorten <=0.2cm,shorten >=0.2cm,thick,blue](\source)to[bend left](\destination);
\end{tikzpicture}
\end{flushleft}
\end{minipage}
\begin{minipage}[t][0.3\textheight]{0.55\textwidth}
Counterclockwise [option \texttt{bend right}]:
\begin{flushleft}
\begin{tikzpicture}
% Internal cirlce with polygon
\draw[red](0,0)circle(1.5cm);
\node[regular polygon, regular polygon sides=\polygonsides, minimum size=3cm, draw, name=x] at (0,0) {};
% Nodes on vertices
\foreach \corner in {1,2,...,\polygonsides}
\node[circle,ball color=red] at (x.corner \corner){};

% External polygon

\node[regular polygon, regular polygon sides=\polygonsides, minimum size=4cm, draw=none, name=p] at (0,0) {};

% Nodes on vertices
\foreach \corner in {1,2,...,\polygonsides}
\node at (p.corner \corner){};

% Connections
\foreach \source/\destination in {p.corner 1/p.corner 2,p.corner 2/p.corner 3,p.corner 3/p.corner 4,p.corner 4/p.corner 5,p.corner 5/p.corner 1}
\draw[-stealth,shorten <=0.2cm,shorten >=0.2cm,thick,red](\source)to[bend right](\destination);
\end{tikzpicture}
\end{flushleft}
\end{minipage}
\end{document}


Result:

The external polygon is not drawn because it's just used as reference to set properly the vertices that are the starting and ending point of arrows. Of course, it is possible to make arrows more near the polygon by declaring a closer radius for this external polygon: now the distance is 1cm. In the following there are two examples: in the first arrows are clockwise while in the second they are counterclockwise. To achieve these two things are necessary:

• using options bend left for clockwise and bend right for counterclockwise;
• connect the pair source/destination in clockwise order or in counterclockwise order taking in mind that nodes are vertices are numbered in counterclockwise order:

-
Thanks, looks nice and works like a charm – AbstractDissonance Aug 19 '12 at 15:24
Glad of having helped you! :) – Claudio Fiandrino Aug 19 '12 at 15:38

A compact version (didn't automate the circumference calc since I am not sure if this what is asked)

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,decorations.markings}

\begin{document}
\begin{tikzpicture}[decoration={
markings,
mark=between positions 0 and 1 step 2.51376 cm with {\arrow{latex}}
}
]
\draw[postaction={decorate}] (90:2cm) arc (-270:90:2cm);
\node[draw,red,regular polygon, regular polygon sides=5,minimum height=4cm] {};
\end{tikzpicture}
\end{document}


-

In the following, I use the library shapes.geometric that defines a shape called regular polygon so that you have a general solution no matter how many sides the polygon has. I also need a auxiliary macro \pgfmathsetlenghtbetweenanchors that computes the lenght between two anchors of the same node.

To draw the arc, I use the syntax given here and I need the angle between two corners as mentioned here.

\documentclass{standalone}

\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\begin{document}

\makeatletter
\def\pgfmathsetlenghtbetweenanchors#1#2#3#4{%
% #1: length
% #2: node
% #3: first anchor
% #4: second anchor
\pgfpointdiff{%
\pgfpointanchor{#2}{#3}}{%
\pgfpointanchor{#2}{#4}}%
\pgfmathparse{veclen(\pgf@x,\pgf@y)}%
#1=\pgfmathresult pt}
\makeatother

\begin{tikzpicture}
\def\nsides{5}%
\node[regular polygon,
regular polygon sides = \nsides,
draw,
rotate=25,
minimum size = 3cm] (\nsides-agon) {};

corner 2}%
\foreach \n [remember = \n as \m (initially \nsides)] in
{1,...,\nsides} {%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{\nsides-agon}{center}}{%
\pgfpointanchor{\nsides-agon}{corner \m}}%
\let\anglem\pgfmathresult
\pgfmathanglebetweenpoints{%
\pgfpointanchor{\nsides-agon}{center}}{%
\pgfpointanchor{\nsides-agon}{corner \n}}%
\let\anglen\pgfmathresult
\ifdim\anglen pt < \anglem pt
\pgfmathparse{\anglen + 360}%
\let\anglen\pgfmathresult
\fi

\end{tikzpicture}

\begin{tikzpicture}
\def\nsides{7}%
\node[regular polygon,
regular polygon sides = \nsides,
draw,
rotate=25,
minimum size = 3cm] (\nsides-agon) {};

corner 2}%
\foreach \n [remember = \n as \m (initially \nsides)] in
{1,...,\nsides} {%
\pgfmathanglebetweenpoints{%
\pgfpointanchor{\nsides-agon}{center}}{%
\pgfpointanchor{\nsides-agon}{corner \m}}%
\let\anglem\pgfmathresult
\pgfmathanglebetweenpoints{%
\pgfpointanchor{\nsides-agon}{center}}{%
\pgfpointanchor{\nsides-agon}{corner \n}}%
\let\anglen\pgfmathresult
\ifdim\anglen pt < \anglem pt
\pgfmathparse{\anglen + 360}%
\let\anglen\pgfmathresult
\fi

\end{tikzpicture}

\end{document}

-

Here is a solution using arc:

And the code:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\foreach \nbn in {3,5,7,9}{
\begin{tikzpicture}
\pgfmathsetmacro{\angle}{360/\nbn}
% center
\node {\nbn{} nodes};
% draw nodes
\foreach \i in {1,...,\nbn}{
\node at (\angle*\i:\radius) {$N_\i$};
}
% draw arrows (clockwise)
\foreach \i in {1,...,\nbn}{
\draw[-latex,very thick,red!50!black]