Two people play a game on a graph with $2022$ points. Initially, there are no edges in the graph. They take turns and connect two non-neighbouring vertices with an edge. Whoever makes the graph connected loses. Which player has a winning strategy?
ST, danny2915
According to the paper Connected Graph Game (Theorem 5), if there are $n \ge 3$ vertices, then Alice (the first to make moves) wins if and only if $n \equiv 2,3 \pmod 4$. ( I believe that there is a typo in the paper - as Table 5 lists all the winning states for Bob.)
I just wonder if there is nice proof to it, as the proof in the paper relies on messy casework. The odd $n$ case is easy: consider the state when one of the players has to make the graph connected, the graph is a combination of two cliques $K_m$ and $K_{n-m}$, so the number of edges in the graph is $\binom{m}{2}+\binom{n-m}{2}=\binom{n}{2}+m(n-m) \equiv \binom{n}{2} \pmod 2$. The parity of $\binom{n}{2}$ decides the winner. But for even $n$ case I got stuck.
Call the players Ana and Banana, with Ana first. Then we claim Ana wins.
First note that the number of connected components stays the same or decreases by 1 every turn, so for every $1 \leq k \leq 2022$, there is some point where there are exactly $k$ connected components.
Call the potential of a graph the number of edges it will have if each of its connected components becomes a $K_n$, so if its connected components have size $c_1$, $\ldots$, $c_k$, then its potential is $\tbinom{c_1}{2} + \cdots + \tbinom{c_k}{2}$.
Claim: If the graph has $2m$ odd-sized connected components, then the potential of the graph has the same parity as $m + 1$.
Proof. Let the even components have sizes $2x_i$, and the odd components have size $2y_i + 1$. Then note that $\tbinom{2x}{2}$ and $\tbinom{2y + 1}{2}$ have the same parity as $x$ and $y$, respectively. So the potential has the same parity as \[\sum x_i + \sum y_i = \frac{2022 - 2m}{2} \equiv 1 + m,\]since the sum of all component sizes is 2022. $\blacksquare$
Claim: If there are exactly two connected components, both of even size, Ana wins.
Proof. Neither player wants to connect them, so the game ends when both become complete and the next player loses. Since $m = 0$ here, the graph has odd potential, which means that Ana will be the player to complete the last $K_n$ and Banana will be the one forced to connect them. $\blacksquare$
Now consider the time when we first have exactly $4$ connected components.
If all four have odd size, then $m = 2$ and the graph again has odd potential. So Ana can guarantee that Banana is the one to connect two components, resulting in three components of sizes even, odd, and odd. Then Ana connects the two odd components and wins.
If all four have even size, then Ana immediately wins -- no matter what, in the two-component case both will have even sizes.
If two have even size and two have odd size, then if it's Ana's turn Ana connects the two odd-sized components to get three of even size, and no matter what in the two-component case both will be even and Ana wins. On the other hand, if it's Bob's turn, if he doesn't connect two components then Ana does this next turn; if he connects the odd components then the same thing happens; and if he connects an even and odd component then we get back to the even, odd, odd case and again Ana wins by connecting the odd ones.
Remark: For the general even $n \geq 4$ case, this works for all $n \equiv 2 \pmod{4}$ while for $n \equiv 0 \pmod{4}$ the second player wants two even components, and the same argument works to show that they win.
We claim that the first player can win.
First, note that at any time we can split the graph $G$ into connected components $G_1,\cdots,G_k$, no two of which are connected to each other (if there is a point not connected to any other, then it goes in its own connected component). We first show that if at any time there are at least two connected components, and all of the connected components have an even number of vertices (from now on, we call such components even), then the first player can win.
Note that after this time, the connected components will always all be even, as a player can either add an edge to the vertices in a connected component, which clearly doesn't change the parity, or connect two connected components, but since even+even = even all the connected components are still even. Then, the first player's strategy will be to just move randomly until there are only two connected components left. At this time, they connect two points in a connected component; note that the second player must do the same as otherwise they lose immediately. Then, at the time when there are no more such possible moves, if the number of vertices in one connected component is $m$, then the number of vertices in the other connected component is $2022-m$, so the total number of moves has been ${m \choose 2} + {2022-m \choose 2}$. However, note that
$m$ and $2022-m$ are $0$ and $2$ $\bmod 4$ in some order, so ${m \choose 2} + {2022-m \choose 2}$ is odd. However, this means that it is the second player's turn to move, and so the second player will lose as required.
Now, we call a connected component with $1$ vertex dormant. We claim that if after the first player's move all of the non-dormant connected components are even, and there are at least two non-dormant connected components, then the first player can win.
The first player's strategy is as follows: if the non-dormant connected components cover all vertices then they win. If the second player connects two non-dormant connected components, connects two vertices in a non-dormant connected component, or connects two dormant connected components, then the first player connects two dormant connected components, and the condition is preserved (he can always do this). If on the other hand the second player connects one of the connected components to a dormant connected component, then the first player connects this to another dormant connected component and the condition is preserved, as required.
Now we prove that the first player can win. After the first player's first move, either the second player connects two dormant connected components, in which case the first player connects two other dormant connected components and wins, or the second player connects the non-dormant connected component to a dormant connected component. In this second case, the first player can connect the two vertices in the non-dormant connected component currently not connected. Then, either the first player connects two dormant connected components, in which case the first player connects the non-dormant connected component to a dormant connected component and wins, or the second player connects the non-dormant connected component to a dormant connected component, in which case the first player connects two dormant connected components and wins. In either case, we are done.
Similar one, only difference is the first one make graph connected wins.
The paper commented in #2 has both solution to two cases: first one make graph connected win/lose.