%! TEX root = GT.tex
% vim: tw=50
% 07/10/2023 09AM

\subsection{Trees}

\begin{flashcard}[acyclic-defn]
\begin{definition*}[Acyclic graph]
  \cloze{
  Say graph $G$ is \emph{acyclic} if it has no
  cycle.
  }
\end{definition*}
\end{flashcard}

\begin{flashcard}[tree-defn]
\begin{definition*}[tree]
  \glsnoundefn{tree}{tree}{trees}
  \cloze{
  A \emph{tree} is a connected acyclic graph.
  }
\end{definition*}
\end{flashcard}

\begin{example*}
  The following are both trees:
  \begin{center}
      \includegraphics[width=0.6\linewidth]
      {images/ae54c68a64e811ee.png}
  \end{center}
\end{example*}

\begin{flashcard}[leaf-defn]
\begin{definition*}[leaf]
  \glsnoundefn{leaf}{leaf}{leaves}
  \cloze{
  In a tree, a vertex of degree 1 is a \emph{leaf}
  or \emph{\fcemph{enovertex}}.
  }
\end{definition*}
\end{flashcard}

\begin{flashcard}[tree-tfae-prop]
\begin{proposition}
  Let $G$ be a graph. Then the following are
  equivalent:
  \begin{enumerate}[(i)]
    \item $G$ is a tree.
    \item \cloze{$G$ is minimal connected ($G$ is
      connected, and $G - xy$ is disconnected for
      all $xy \in E$)}
    \item \cloze{$G$ is maximal acyclic ($G$ is acyclic,
      $G + xy$ has a cycle for all $xy \in V^{(2)}
      \setminus E$)}
  \end{enumerate}
\end{proposition}

\begin{proof}
  \phantom{}
  \begin{enumerate}[iiiii]
    \item[(i) $\implies$ (ii)] \cloze{Suppose $G - xy$
      connected, so $G - xy$ has an $x - y$ path
      $P$ say. But then $Pyx$ is a cycle in $G$.}
    \item[(ii) $\implies$ (i)] \cloze{Suppose $G$
      has a cycle $C$, and pick $xy \in E(C)$.
      Then $G - xy$ connected. Indeed, for any $a,
      b \in V$ have an $ab$ path in $G$. If this
      path uses $xy$, replace $xy$ with $C - xy$
      to obtain an $a-b$ \fcemph{walk} in $G - xy$.}
    \item[(i) $\implies$ (iii)] \cloze{For any $xy
      \not\in E$: $G$ has an $x-y$ path $P$, so $G
      + xy$ has the cycle $Pyx$.}
    \item[(iii) $\implies$ (i)] \cloze{If $G$ is
      disconnected, choose $x$, $y$ in \fcemph{different
      components}. Then $G + xy$ is acyclic.} \qedhere
  \end{enumerate}
\end{proof}
\end{flashcard}

\begin{flashcard}[trees-have-leaf-prop]
\begin{proposition}
  Every tree $T$ ($|T| \ge 2$) has a leaf.
\end{proposition}

\begin{proof}
  \cloze{
  Choose a \fcemph{longest path} $P = x_1, \ldots,
  x_k$ in $T$ (since $T$ finite). Then
  $\Gamma(x_k) \subset P$ (by maximality of $P$),
  but also $\Gamma(x_K) \cap P = \{x_{k - 1}\}$
  (since $T$ acyclic). So $x_k$ is a leaf.
  }
\end{proof}
\end{flashcard}

\begin{note*}
  Actually always have at least 2 leaves, since
  same argument shows $x_1$ is a leaf.
\end{note*}

\begin{proof}[Proof (alternative)]
  Suppose $d(x) \ge 2$ for all $x \in T$. Choose
  $x_1, x_2$ such that $x_1 x_2 \in E$. Then
  choose $x_3, x_4, \ldots$ as follows: given
  $x_{k - 1}$, let $x_k$ be a neighbour of $x_{k -
  1}$ not equal to $x_{k - 2}$. Since $G$ is
  finite, we must repeat, which gives a cycle.
\end{proof}

We can describe this proof as ``go for a walk''.

\begin{flashcard}[spanned-graph-notation]
\begin{notation*}
  For a graph $G$, $W \subset V$, write
  \cloze{$G[W]$ for the graph $(W, E \cap
  W^{(1)})$ (the subgraph \fcemph{spanned} by
  $W$).}
\end{notation*}
\end{flashcard}

\begin{flashcard}[graph-minus-vertex-notation]
\begin{notation*}
  For a graph $G$, $x \in V$, write $G - x$ for
  \cloze{$G[V \setminus \{x\}]$.}
\end{notation*}
\end{flashcard}

\begin{flashcard}[tree-has-n-minus-1-edges-prop]
\begin{proposition}
  \label{tree_has_n_minus_1_edges}
  Every tree $T$ on $n$ vertices ($n \ge 1$) has
  $e(T) = n - 1$.
\end{proposition}

\begin{proof}
  \cloze{
  Induction on $n$. $n = 1$ is trivial.

  Given a tree $T$ on $n$ vertices, $n \ge 2$: let
  $x$ be a leaf of $T$. Define $T - x$ is a tree
  on $n - 1$ vertices, so $e(T - x) = n - 2$
  (induction). Hence $e(T) = n - 1$.
  }
\end{proof}
\end{flashcard}

\begin{flashcard}[spanning-tree-defn]
\begin{definition*}[Spanning tree]
  \cloze{
  In a connected graph $G = (V, E)$, a
  \emph{spanning tree} is a subgraph $T$ that is a
  tree with $V(T) = V$.
  }
\end{definition*}
\end{flashcard}

\begin{flashcard}[connected-graph-has-spanning-tree-lemma]
\begin{lemma*}
  Every connected graph $G$ has a spanning tree.
\end{lemma*}

\begin{proof}
  \cloze{
  Keep removing edges until we are
  \fcemph{minimally connected} (which is
  equivalent to being a tree).
  }
\end{proof}
\end{flashcard}

\begin{note*}
  For a tree $T$, $T$ is the \emph{unique}
  spanning tree of $T$ (by minimal connectedness,
  for example).
\end{note*}

\begin{flashcard}[distance-defn]
\begin{definition*}[distance]
  \glssymboldefn{dist}{$d(x, y)$}{$d(x, y)$}
  \cloze{For $x, y \in G$, the \emph{distance}
  $d(x, y)$ is the length of a shortest $x-y$ path
  in $G$.}
\end{definition*}
\end{flashcard}

\begin{example*}
  In the following graph, $x$ and $y$ have
  distance $2$:
  \begin{center}
      \includegraphics[width=0.6\linewidth]
      {images/78b98eba64ee11ee.png}
  \end{center}
\end{example*}
\vspace{-1em}

Most proofs of \cref{tree_has_n_minus_1_edges}
work by induction. Some books even say that every
proof must use induction. This isn't true. Just to
prove this point, we show the below proof.

\begin{proof}[Proof (non-inductive proof of
  \cref{tree_has_n_minus_1_edges})]
  We will show that any tree $T$ has a spanning
  tree of $n - 1$ edges (and since the only
  spanning tree of a tree is itself, this will
  mean we are done).

  Fix $x_0 \in T$. For each $x \in V \setminus
  \{x_0\}$, let $x x', \ldots, x_0$ be a shortest
  $x-x_0$ path (so $d(x', x_0) = d(x, x_0) - 1$).
  Let $T' = \{xx' : x \in V \setminus \{x_0\}\}$.
  So $e(T') = n - 1$ (we can't count an edge twice
  because we can only go in the direction that
  brings us closer to $x_0$).

  \textbf{Claim:} $T'$ is a tree.
  \textbf{Proof of claim:}
  \begin{enumerate}[connected]
    \item[connected] For any $x$, $xx'(x')'\ldots$
      must reach $x_0$.
    \item Suppose $C$ is a cycle in $T'$. Choose
      $x \in C$ at greatest distance from $x_0$.
      Then \emph{both} neighbours of $x$ on $C$
      are at distance $\le d(x, x_0)$ from $x_0$.
      Contradiction construction of $T'$. \qedhere
  \end{enumerate}
\end{proof}
