]> mj.ucw.cz Git - saga.git/blobdiff - mst.tex
Matroids.
[saga.git] / mst.tex
diff --git a/mst.tex b/mst.tex
index b915272b62a7ab165ff03d38805731aa41a7db00..3f715954dd69cdaeb575751369442f8f562971f9 100644 (file)
--- a/mst.tex
+++ b/mst.tex
@@ -41,19 +41,20 @@ spanning tree problem was one of the central topics of the flourishing new
 disciplines, the previous work was not well known and the algorithms had to be
 rediscovered several times.
 
-Recently, several significantly faster algorithms were discovered, most notably the
-$\O(m\timesbeta(m,n))$-time algorithm by Fredman and Tarjan \cite{ft:fibonacci} and
-algorithms with inverse-Ackermann type complexity by Chazelle \cite{chazelle:ackermann}
-and Pettie \cite{pettie:ackermann}.
+In the next 50 years, several significantly faster algorithms were discovered, ranging
+from the $\O(m\timesbeta(m,n))$ time algorithm by Fredman and Tarjan \cite{ft:fibonacci},
+over algorithms with inverse-Ackermann type complexity by Chazelle \cite{chazelle:ackermann}
+and Pettie \cite{pettie:ackermann}, to another algorithm by Pettie \cite{pettie:optimal}
+whose time complexity is provably optimal.
 
-\FIXME{Write the rest of the history.}
-
-This chapter attempts to survey the important algorithms for finding the MST and it
-also presents several new ones.
+In the upcoming chapters, we will explore this colorful universe of MST algorithms.
+We will meet the standard works of the classics, the clever ideas of their successors,
+various approaches to the problem including randomization and solving of important
+special cases.
 
 %--------------------------------------------------------------------------------
 
-\section{Basic properties}
+\section{Basic properties}\id{mstbasics}%
 
 In this section, we will examine the basic properties of spanning trees and prove
 several important theorems to base the algorithms upon. We will follow the theory
@@ -244,7 +245,7 @@ of choosing the rules in this procedure, which justifies the name meta-algorithm
 We will denote the unique minimum spanning tree of the input graph by~$T_{min}$.
 We intend to prove that this is also the output of the procedure.
 
-\lemman{Blue lemma}%
+\lemman{Blue lemma}\id{bluelemma}%
 When an edge is colored blue in any step of the procedure, it is contained in the minimum spanning tree.
 
 \proof
@@ -302,15 +303,45 @@ are colored, so by the Blue lemma all blue edges are in~$T_{min}$ and by the Red
 lemma all other (red) edges are outside~$T_{min}$, so the blue edges are exactly~$T_{min}$.
 \qed
 
+\para
+The Red lemma actually works in both directions and it can be used to characterize
+all non-MST edges, which will turn out to be useful in the latter chapters.
+
+\corn{Cycle rule}\id{cyclerule}%
+An~edge~$e$ is not contained in the MST iff it is the heaviest on some cycle.
+
+\proof
+The implication from the right to the left is the Red lemma. In the other
+direction, when~$e$ is not contained in~$T_{min}$, it is $T_{min}$-heavy (by
+Theorem \ref{mstthm}), so it is the heaviest edge on the cycle $T_{min}[e]+e$.
+\qed
+
+\rem
+The MST problem is a~special case of the problem of finding the minimum basis
+of a~weighted matroid. Surprisingly, when we modify the Red-Blue procedure to
+use the standard definitions of cycles and cuts in matroids, it will always
+find the minimum basis. Some of the other MST algorithms also easily generalize to
+matroids and in some sense matroids are exactly the objects where ``the greedy approach works''. We
+will however not pursue this direction in our work, referring the reader to the Oxley's monograph
+\cite{oxley:matroids} instead.
+
 %--------------------------------------------------------------------------------
 
-\section{Classical algorithms}
+\section{Classical algorithms}\id{classalg}%
 
 The three classical MST algorithms can be easily stated in terms of the Red-Blue meta-algorithm.
 For each of them, we first show the general version of the algorithm, then we prove that
 it gives the correct result and finally we discuss the time complexity of various
 implementations.
 
+\paran{Bor\o{u}vka's algorithm}%
+The oldest MST algorithm is based on a~simple idea: grow a~forest in a~sequence of
+iterations until it becomes connected. We start with a~forest of isolated
+vertices. In each iteration, we let each tree of the forest select the lightest
+edge of those having exactly one endpoint in the tree (we will call such edges
+the \df{neighboring edges} of the tree). We add all such edges to the forest and
+pAroceed with the next iteration.
+
 \algn{Bor\o{u}vka \cite{boruvka:ojistem}, Choquet \cite{choquet:mst}, Sollin \cite{sollin:mst} and others}
 \algo
 \algin A~graph~$G$ with an edge comparison oracle.
@@ -373,6 +404,12 @@ Bor\o{u}vka's algorithm finds the MST in time $\O(m\log n)$.
 Follows from the previous lemmata.
 \qed
 
+\paran{Jarn\'\i{}k's algorithm}%
+The next algorithm, discovered independently by Jarn\'\i{}k, Prim and Dijkstra, is similar
+to Bor\o{u}vka's algorithm, but instead of the whole forest it concentrates on
+a~single tree. It starts with a~single vertex and it repeatedly extends the tree
+by the lightest neighboring edge until it spans the whole graph.
+
 \algn{Jarn\'\i{}k \cite{jarnik:ojistem}, Prim \cite{prim:mst}, Dijkstra \cite{dijkstra:mst}}\id{jarnik}%
 \algo
 \algin A~graph~$G$ with an edge comparison oracle.
@@ -395,10 +432,9 @@ number of blue edges.
 \qed
 
 \impl\id{jarnimpl}%
-The most important part of the algorithm is finding \em{neighboring edges,} i.e., edges
-of the cut $\delta(T)$. In a~straightforward implementation,
-searching for the lightest neighboring edge takes $\Theta(m)$ time, so the whole
-algorithm runs in time $\Theta(mn)$.
+The most important part of the algorithm is finding \em{neighboring edges.}
+In a~straightforward implementation, searching for the lightest neighboring
+edge takes $\Theta(m)$ time, so the whole algorithm runs in time $\Theta(mn)$.
 
 We can do much better by using a binary
 heap to hold all neighboring edges. In each iteration, we find and delete the
@@ -413,12 +449,19 @@ From this, we can conclude:
 Jarn\'\i{}k's algorithm finds the MST of a~given graph in time $\O(m\log n)$.
 
 \rem
-We will show several faster implementations in section \ref{fibonacci}.
+We will show several faster implementations in section \ref{iteralg}.
 
-\algn{Kruskal \cite{kruskal:mst}, the Greedy algorithm}
+\paran{Kruskal's algorithm}%
+The last of the three classical algorithms processes the edges of the
+graph~$G$ greedily. It starts with an~empty forest and it takes the edges of~$G$
+in order of their increasing weights. For every edge, it checks whether its
+addition to the forest produces a~cycle and if it does not, the edge is added.
+Otherwise, the edge is dropped and not considered again.
+
+\algn{Kruskal \cite{kruskal:mst}}
 \algo
 \algin A~graph~$G$ with an edge comparison oracle.
-\:Sort edges of~$G$ by their increasing weight.
+\:Sort edges of~$G$ by their increasing weights.
 \:$T\=\emptyset$. \cmt{an empty spanning subgraph}
 \:For all edges $e$ in their sorted order:
 \::If $T+e$ is acyclic, add~$e$ to~$T$.
@@ -440,37 +483,54 @@ so~$T$ must be the~MST.
 
 \impl
 Except for the initial sorting, which in general takes $\Theta(m\log m)$ time, the only
-other non-trivial operation is the detection of cycles. What we need is a data structure
+other non-trivial operation is the detection of cycles. What we need is a~data structure
 for maintaining connected components, which supports queries and edge insertion.
-(This is also known under the name Disjoint Set Union problem, i.e., maintenance
-of an~equivalence relation on a~set with queries on whether two elements are equivalent
-and the operation of joining two equivalence classes into one.)
-The following theorem shows that it can be done with surprising efficiency.
+This is closely related to the well-known Disjoint Set Union problem:
+
+\problemn{Disjoint Set Union (DSU)}
+Maintain an~equivalence relation on a~finite set under a~sequence of operations \<Union>
+and \<Find>. The \<Find> operation tests whether two elements are equivalent and \<Union>
+joins two different equivalence classes into one.
+
+\para
+We can maintain the connected components of our forest~$T$ as equivalence classes. When we want
+to add an~edge~$uv$, we first call $\<Find>(u,v)$ to check if both endpoints of the edge lie in
+the same components. If they do not, addition of this edge connects both components into one,
+so we perform $\<Union>(u,v)$ to merge the equivalence classes.
+
+Tarjan and van Leeuwen have shown that there is a~data structure for the DSU problem
+with surprising efficiency:
 
-\thmn{Incremental connectivity}%
-When only edge insertions and connectivity queries are allowed, connected components
-can be maintained in $\O(\alpha(n))$ time amortized per operation.
+\thmn{Disjoint Set Union, Tarjan and van Leeuwen \cite{tarjan:setunion}}\id{dfu}%
+Starting with a~trivial equivalence with single-element classes, a~sequence of operations
+comprising of $n$~\<Union>s intermixed with $m\ge n$~\<Find>s can be processed in time
+$\O(m\timesalpha(m,n))$, where $\alpha(m,n)$ is a~certain inverse of the Ackermann's function
+(see Definition \ref{ackerinv}).
 
 \proof
-Proven by Tarjan and van Leeuwen in \cite{tarjan:setunion}.
+See \cite{tarjan:setunion}.
 \qed
 
-\FIXME{Define Ackermann's function. Use $\alpha(m,n)$?}
+This completes the following theorem:
+
+\thm\id{kruskal}%
+Kruskal's algorithm finds the MST of a given graph in time $\O(m\log n)$.
+If the edges are already sorted by their weights, the time drops to
+$\O(m\timesalpha(m,n))$.
+
+\proof
+We spend $\O(m\log n)$ on sorting, $\O(m\timesalpha(m,n))$ on processing the sequence
+of \<Union>s and \<Find>s, and $\O(m)$ on all other work.
+\qed
 
 \rem
-The cost of the operations on components is of course dwarfed by the complexity
+The cost of the \<Union> and \<Find> operations is of course dwarfed by the complexity
 of sorting, so a much simpler (at least in terms of its analysis) data
 structure would be sufficient, as long as it has $\O(\log n)$ amortized complexity
 per operation. For example, we can label vertices with identifiers of the
-corresponding components and always recolor the smaller of the two components.
+corresponding components and always relabel the smaller of the two components.
 
-\thm\id{kruskal}%
-Kruskal's algorithm finds the MST of a given graph in time $\O(m\log n)$
-or $\O(m\timesalpha(n))$ if the edges are already sorted by their weights.
-
-\proof
-Follows from the above analysis.
-\qed
+We will study dynamic maintenance of connected components in more detail in Chapter~\ref{dynchap}.
 
 %--------------------------------------------------------------------------------
 
@@ -533,7 +593,7 @@ at the beginning of the $i$-th iteration by $G_i$ (starting with $G_0=G$) and th
 of vertices and edges of this graph by $n_i$ and $m_i$ respectively.
 
 \lemma\id{contiter}%
-The $i$-th iteration of the algorithm (also called the Bor\o{u}vka step) can be carried
+The $i$-th iteration of the algorithm (also called the \df{Bor\o{u}vka step}) can be carried
 out in time~$\O(m_i)$.
 
 \proof
@@ -549,7 +609,7 @@ edges together. The bucket sort uses two passes with $n_i$~buckets, so it takes
 $\O(n_i+m_i)=\O(m_i)$.
 \qed
 
-\thm
+\thm\id{contborthm}%
 The Contractive Bor\o{u}vka's algorithm finds the MST of the input graph in
 time $\O(\min(n^2,m\log n))$.
 
@@ -590,7 +650,7 @@ in section~\ref{minorclosed}.
 To achieve the linear time complexity, the algorithm needs a very careful implementation,
 but we defer the technical details to section~\ref{bucketsort}.
 
-\para
+\paran{General contractions}%
 Graph contractions are indeed a~very powerful tool and they can be used in other MST
 algorithms as well. The following lemma shows the gist:
 
@@ -617,7 +677,7 @@ which obviously works in multigraphs as well.)
 \rem
 In the previous algorithm, the role of the mapping~$\pi^{-1}$ is of course played by the edge labels~$\ell$.
 
-\para
+\paran{A~lower bound}%
 Finally, we will show a family of graphs where the $\O(m\log n)$ bound on time complexity
 is tight. The graphs do not have unique weights, but they are constructed in a way that
 the algorithm never compares two edges with the same weight. Therefore, when two such