Let
\((G,w)\) be a weighted graph with
\(n\) vertices, and let
\(T = (V,S)\) be the spanning tree produced by Kruskalβs algorithm. We will first show that
\(T\) is indeed a spanning tree of
\(G\text{.}\) Since the algorithm terminates when
\(|S| = n - 1\text{,}\) and since we only add edges that connect two components in the spanning subgraph
\(G:S\text{,}\) it follows that
\(G:S\) is connected and acyclic. Therefore,
\(T\) is a spanning tree of
\(G\text{.}\)
We will now show that \(T\) is a minimum spanning tree. Let \(T'= (V, S')\) be any other spanning tree of \(G\text{.}\) Write
\begin{equation*}
S=\{e_1,e_2,\ldots,e_{n-1}\}
\end{equation*}
where the edges are listed in the order they were added by Kruskalβs algorithm, i.e.,
\begin{equation*}
w(e_1) \leq w(e_2) \leq \cdots \leq w(e_{n-1})\, .
\end{equation*}
We will write
\begin{equation*}
S_k:=\{e_1,\ldots,e_k\}\, .
\end{equation*}
Let \(T'\) have edges
\begin{equation*}
S' = \{f_1, f_2, \ldots, f_{n-1}\}\text{,}
\end{equation*}
written in the order
\begin{equation*}
w(f_1) \leq w(f_2) \leq \cdots \leq w(f_{n-1})\, .
\end{equation*}
We will show that
\begin{equation*}
w(e_i) \leq w(f_i)
\end{equation*}
for all \(1 \leq i \leq n - 1\text{,}\) which will imply that the total weight of \(T\) is less than or equal to the total weight of \(T'\text{.}\) We go by contradiction and suppose that there exists an index \(k\) such that
\begin{equation*}
w(e_k) \gt w(f_k)\text{,}
\end{equation*}
and let \(k\) be the smallest such index. Since none of \(f_1, f_2, \ldots, f_{k}\) were chosen by Kruskalβs algorithm to be \(e_k\text{,}\) it follows that they were already in the components of \(G:S_{k-1}\text{.}\) Since \(G:S_{k-1}\) has \(n-(k-1)\) components, we see that \(G:S'_k\) has at least \(n-(k-1)=n-k+1\) components as well. But, if \(G:S'_k\) were acyclic, it would be a union of trees, and hence would have \(n-k\) components. This is not possible, and therefore \(G:S'_k\) is not acyclic, contradicting the assumption that \(T'\) is a spanning tree. Thus, we conclude that
\begin{equation*}
w(e_i) \leq w(f_i)
\end{equation*}
for all \(1 \leq i \leq n - 1\text{,}\) and hence that \(T\) is a minimum spanning tree.