Source: IMO-2019-P3
Category: Graph Theory

Problem:
A social network has $2019$ users, some pairs of which are friends (friendship is symmetric). If $A$, $B$, $C$ are three users such that $AB$ are friends and $AC$ are friends but $BC$ is not, then the administrator may perform the following operation: change the friendships such that $BC$ are friends, but $AB$ and $AC$ are no longer friends.

Initially, $1009$ users have $1010$ friends and $1010$ users have $1009$ friends. Prove that the administrator can make a sequence of operations such that all users have at most $1$ friend.

Solution:
We reformulate the problem in graph-theoretic terms. Let the users be vertices and the friendships be edges of a graph $G$. The given operation, which we call a \emph{toggle}, consists of taking three vertices $a, b, c$ such that $ab$ and $ac$ are edges but $bc$ is not, and replacing the edges $ab$ and $ac$ with the edge $bc$.

\begin{claim*}
  Let $G$ be a connected graph. Then one can toggle $G$ without disconnecting the graph, unless $G$ is a clique, a cycle, or a tree.
\end{claim*}
\begin{proof}
  Assume $G$ is connected and is not a clique, a cycle, or a tree. Since $G$ is not a tree, it contains a cycle. Let $C$ be a cycle of minimal length in $G$; by hypothesis, $C \neq G$.

  If $C$ is not a triangle (equivalently, $G$ is triangle-free), then since $G$ is connected, there exists a vertex $b \notin C$ adjacent to some vertex $a \in C$. Let $c \in C$ be a neighbor of $a$ on the cycle. Since $G$ is triangle-free, $b$ is not adjacent to $c$. Thus, we can toggle $a, b, c$, replacing edges $ab$ and $ac$ with $bc$. This operation does not disconnect the graph because $a$ and $c$ remain connected through the remaining path in the cycle $C$, and $b$ remains connected to the rest of the graph via $c$.

  Now assume that $G$ contains a triangle. Let $K$ be a maximal clique of size at least $3$ (which exists since $G$ contains a triangle). By hypothesis, $K \neq G$. Since $G$ is connected, there exists an edge $e = ab$ with $a \in K$ and $b \notin K$. Since $K$ is a maximal clique, $b$ cannot be adjacent to all vertices in $K$. Choose a vertex $c \in K$ that is not adjacent to $b$. We can then toggle $a, b, c$, replacing edges $ab$ and $ac$ with $bc$. This does not disconnect the graph because $K$ has size at least $3$, meaning there is another vertex $d \in K$ through which $a$ and $c$ remain connected (since $ad$ and $cd$ are edges in $K$), and $b$ remains connected to the rest of the graph via $c$.
\end{proof}

Back to the original problem; let $G_{\text{imo}}$ be the given initial graph. We can apply toggles (by the claim) repeatedly, without disconnecting the graph, until we reach a tree. This is guaranteed because:
\begin{itemize}
  \item $G_{\text{imo}}$ is initially connected. Any two non-adjacent vertices have a common neighbor by the Pigeonhole Principle, since the sum of their degrees is at least $1009 + 1009 = 2018$, and there are only $2017$ other vertices in the graph ($1009 + 1009 + 2 > 2019$).
  \item $G_{\text{imo}}$ cannot become a cycle. Initially, $1010$ vertices have an odd degree of $1009$. A toggle at vertex $a$ involving neighbors $b$ and $c$ decreases the degree of $a$ by $2$ and leaves the degrees of $b$ and $c$ unchanged, so toggles preserve the parity of the degree of every vertex. Since $G_{\text{imo}}$ always contains vertices of odd degree, it can never become a cycle (which requires all vertices to have an even degree).
  \item $G_{\text{imo}}$ is not a clique initially, since its maximum degree is $1010$, which is strictly less than $2018$. It cannot become a clique later because each toggle strictly decreases the total number of edges.
\end{itemize}
Thus, repeatedly applying these connectivity-preserving toggles must eventually reduce $G_{\text{imo}}$ to a tree.

Once $G_{\text{imo}}$ is a tree, we repeatedly apply toggles arbitrarily until no more are possible. In a forest, any toggle replaces edges $ab$ and $ac$ with $bc$. This operation cannot create a cycle because, after removing $ab$ and $ac$, $b$ and $c$ belong to different connected components, so adding $bc$ simply merges these components. Thus, the graph remains acyclic (a forest). Since each toggle strictly decreases the total number of edges, the process must terminate. The process can only terminate when no vertex has degree $2$ or more; otherwise, in a forest, any two neighbors of a vertex are non-adjacent, allowing for another toggle. Therefore, the terminal graph has a maximum degree of at most $1$, as desired.


Grading guidelines:
(Partial) 1. Reformulated the operation as a graph toggle on a triple (a,b,c): delete edges ab,ac and add bc, and correctly observed that each toggle strictly decreases the number of edges. 2. Proved the parity invariant: in a toggle, only deg(a) changes (by −2), so the parity of the degree of every vertex is preserved throughout. 3. Proved the initial graph is connected, e.g. by showing any two non-adjacent vertices have a common neighbor using the degree condition (so there is a path of length 2 between any such pair). (Almost) 1. Gave the full reduction strategy “apply toggles while keeping the graph connected until reaching a tree; then keep toggling in the forest until no vertex has degree ≥2”, but left a small gap in justifying that one can always choose a toggle that does not disconnect the graph unless the graph is a clique/cycle/tree. 2. Proved termination and the final step in a forest (if a vertex has degree ≥2 then a toggle is possible; edge count decreases so the process ends with max degree ≤1), but did not fully justify why the process cannot get stuck earlier in a connected non-tree state (e.g. missed ruling out the cycle/clique possibilities via invariants). 3. Solution is almost complete, but made minor mistakes which are not negligible.