I run into a combinatorics problem recently. Let's imagine we have a n-sided polygon, the number of diagonals is easily $$N=\frac{n(n-3)}{2}$$
However, for my work, I need to group the vertices in pairs, where I cannot group nearest neighbouring vertices, i.e., I need to know the number of ways to draw $n/2$ diagonals in an $n$-sided polygon, where we draw one diagonal from each vertex.
Anybody got some hints for that? For n=4 there is only 1 such case, and for n=6 we have 4. But for larger n it becomes tedious.
Also I need only even number of sides n.
Thank you in advance!!
First, ignore the condition that adjacent vertices cannot be paired up. The number of ways to pair up the vertices into $n/2$ disjoint pairs is $n!!$, the double factorial, defined by $$ (n-1)!!\stackrel{\text{def}}=(n-1)(n-3)(n-5)\cdots=\prod_{i=0}^{\lfloor n/2\rfloor-1}(n-1-2i). $$ To account for the condition that adjacent vertices cannot be paired, we use the principle of inclusion exclusion.
Let $S$ be the set of all vertex pairings, so $|S|=n!!$. For each $i\in \{1,\dots,n\}$, let $E_i$ be the set of vertex pairings where vertex number $i$ is paired with its clockwise neighbor. I assume the vertices so the clockwise neighbor of $i$ is $i+1$ (with addition wrapping modulo $n$). The set of legal pairings is $S\setminus (E_1\cup \dots \cup E_n)$, and PIE tells us that $$ \begin{align} |S\setminus (E_1\cup \dots \cup E_n)| &=\sum_{k=0}^n(-1)^k\sum_{1\le i_1<\dots <i_k\le n}|E_{i_1}\cap \dots \cap E_{i_k}|. \end{align}\tag1 $$ To evaluate $|E_{i_1}\cap \dots \cap E_{i_k}|$, there are two cases.
Suppose the list of indices $[i_1,\dots,i_k]$ contains an adjacent pair, meaning that there exists $r\in \{1,\dots,k\}$ such that $i_{r+1}=i_r+1$ (or, $i_1\equiv i_n+1\pmod n$). In this case, $|E_{i_1}\cap \dots \cap E_{i_k}|=0$. This is because it is impossible to simultaneously have vertex number $i_r$ paired with $i_r+1$, and to have vertex $i_{r}+1$ paired with $i_r+2$.
Otherwise, the indices represent pairwise nonadjacent vertices. In this case, there are $k$ particular vertices which must be paired with their clockwise neighbors. This leaves $n-2k$ vertices to be paired up arbitrarily, which can be done in $(n-1-2k)!!$ ways.
In summary, the innermost summation in $(1)$ has two types of terms: zeroes, and $(n-1-2k)!!$. Therefore, instead of summing over all ways to choose indices such that $1\le i_1<\dots <i_k\le n$, we can simply count the number of ways to choose these indices which fall in case $2$, and then multiply by $(n-1-2k)!!$. That is, if we let $N(n,k)$ be the number of ways to select $k$ nonadjacent vertices on an $n$-gon, then the final answer is $$ |S\setminus (E_1\cup \dots \cup E_n)|=\sum_{k=0}^{\lfloor n/2\rfloor} (-1)^k N(n,k) (n-1-2k)!! $$ Note: When $k=n/2$, the term is $N(n,n/2)· (-1)!!$. By definition, $(-1)!!=1$. This is the convention that makes the most sense, like how we define $0!$ to be $1$.
All that remains is to evaluate $N(n,k)$. There is a simple formula for $N(n,k)$ in terms of $n$ and $k$ that involves a binomial coefficient. It is a nice exercise to try to work it out, so I encourage you to do so. If you get stuck, see this old MSE question.