]> mj.ucw.cz Git - saga.git/blobdiff - opt.tex
Call subgraphs clusters.
[saga.git] / opt.tex
diff --git a/opt.tex b/opt.tex
index dca9bd513576e4e50f819120e4f46949144a2a19..9de4d64a617cfd05943cdd07d4f3c0c29663d661 100644 (file)
--- a/opt.tex
+++ b/opt.tex
@@ -2,7 +2,7 @@
 \input macros.tex
 \fi
 
-\chapter{Approaching Optimality}
+\chapter{Approaching Optimality}\id{optchap}%
 
 \section{Soft heaps}
 
@@ -212,7 +212,7 @@ son's list to its parent. Otherwise, we exchange the sons and move the list from
 new left son to the parent. This way we obey the heap order and at the same time we keep
 the white left son free of items.
 
-Ocassionally, we repeat this process once again and we concatenate the resulting lists
+Occasionally, we repeat this process once again and we concatenate the resulting lists
 (we append the latter list to the former, using the smaller of the two \<ckey>'s). This
 makes the lists grow longer and we want to do that roughly on every other level of the
 tree. The exact condition will be that either the rank of the current vertex is odd,
@@ -222,7 +222,7 @@ If refilling of the left son fails because there are no more items in that subtr
 (we report this by setting its \<ckey> to $+\infty$), the current vertex is no longer
 needed --- the items would just pass through it unmodified. We therefore want to
 remove it. Instead of deleting it directly, we rather make it point to its former
-grandsons and we remove the (now orhpaned) original son. This helps us to ensure
+grandsons and we remove the (now orphaned) original son. This helps us to ensure
 that both sons always keep the same rank, which will be useful for the analysis.
 
 When all refilling is done, we update the suffix minima by walking from the current
@@ -280,7 +280,7 @@ Let us translate these ideas to real (pseudo)code:
 all queues in the heap, walks the trees and the item lists of all vertices. It records
 all items seen, the corrupted ones are those that different from their \<ckey>.
 
-\paran{Analysis of accuracy}
+\paran{Analysis of accuracy}%
 The description of the operations is now complete, so let us analyse their behavior
 and verify that we have delivered what we promised --- first the accuracy of
 the structure, then the time complexity of operations. In the whole analysis,
@@ -296,9 +296,9 @@ satisfies:
 $$\ell(v) \le \max(1, 2^{\lceil \<rank>(v)/2 \rceil - r/2}).$$
 
 \proof
-Initially, all item lists contain at most one item, so the ineqality trivially
+Initially, all item lists contain at most one item, so the inequality trivially
 holds. Let us continue by induction. Melds can affect it only in the favorable
-direction (they ocassionally move an~item list to a~vertex of a~higher rank)
+direction (they occasionally move an~item list to a~vertex of a~higher rank)
 and so do deletes (they only remove items from lists). The only potentially
 dangerous place is the \<Refill> procedure.
 
@@ -348,7 +348,7 @@ last expression is less than $2^{k-r+2}$. Since the tree contains $n_k=2^k$ blac
 this makes less than $n_k/2^{r-2}$ corrupted items as we asserted.
 \qed
 
-\paran{Analysis of time complexity}
+\paran{Analysis of time complexity}%
 Now we will examine the amortized time complexity of the individual operations.
 We will show that if we charge $\O(r)$ time against every element inserted, it is enough
 to cover the cost of all other operations.
@@ -400,7 +400,7 @@ of the regular melds.
 Before we estimate the time spent on deletions, we analyse the refills.
 
 \lemma
-Every invokation of the \<Refill> procedure takes time $\O(1)$ amortized.
+Every invocation of the \<Refill> procedure takes time $\O(1)$ amortized.
 
 \proof
 When \<Refill> is called from the \<DeleteMin> operation, it recurses on a~subtree of the
@@ -516,13 +516,13 @@ against each \<Insert>. This yields the time bound.
 
 \rem
 When we set $\varepsilon = 1/2n$, the soft heap is not allowed to corrupt any
-items, so it can be used like any usual heap. By the standard lower bound on
+items, so it can be used like any traditional heap. By the standard lower bound on
 sorting it therefore requires $\Omega(\log n)$ time per operation, so the
 time complexity is optimal for this choice of~$\varepsilon$. Chazelle \cite{chazelle:softheap}
 proves that it is optimal for every choice of~$\varepsilon$.
 
 The space consumed by the heap need not be linear in the \em{current} number
-of items, but if a~case where this matters ever occured, we could fix it easily
+of items, but if a~case where this matters ever occurred, we could fix it easily
 by rebuilding the whole data structure completely after $n/2$ deletes. This
 increases the number of potentially corrupted items, but at worst twice, so it
 suffices to decrease~$\varepsilon$ twice.
@@ -532,20 +532,20 @@ suffices to decrease~$\varepsilon$ twice.
 \section{Robust contractions}
 
 Having the soft heaps at hand, we would like to use them in a~conventional MST
-algorithm in place of a~usual heap. The most efficient specimen of a~heap-based
+algorithm in place of a~normal heap. The most efficient specimen of a~heap-based
 algorithm we have seen so far is the Iterated Jarn\'\i{}k's algorithm (\ref{itjar}).
 It is based on a~simple, yet powerful idea: Run the Jarn\'\i{}k's algorithm with
-limited heap size, so that it stops when the neighborhood of the tree becomes
+limited heap size, so that it stops when the neighborhood of the tree becomes too
 large. Grow multiple such trees, always starting in a~vertex not visited yet. All
 these trees are contained in the MST, so by the Contraction lemma
 (\ref{contlemma}) we can contract each of them to a~single vertex and iterate
 the algorithm on the resulting graph.
 
-We can try implanting the soft heap in this algorithm, preferably in the original
+We can try implanting the soft heap in this algorithm, preferably in its earlier
 version without active edges (\ref{jarnik}) as the soft heap lacks the \<Decrease>
-operation. This honest, but somewhat simple-minded attempt is however doomed to
+operation. This brave, but somewhat simple-minded attempt is however doomed to
 fail. The reason is of course the corruption of items inside the heap, which
-leads to increase of weights of a~subset of edges. In presence of corrupted
+leads to increase of weights of some subset of edges. In presence of corrupted
 edges, most of the theory we have so carefully built breaks down. For example,
 the Blue lemma (\ref{bluelemma}) now holds only when we consider a~cut with no
 corrupted edges, with a~possible exception of the lightest edge of the cut.
@@ -555,11 +555,11 @@ the cycle is not corrupted.
 There is fortunately some light in this darkness. While the basic structural
 properties of MST's no longer hold, there is a~weaker form of the Contraction
 lemma that takes the corrupted edges into account. Before we prove this lemma,
-we will expand our awareness of subgraphs which can be contracted.
+we expand our awareness of subgraphs which can be contracted.
 
 \defn
 A~subgraph $C\subseteq G$ is \df{contractible} iff for every pair of edges $e,f\in\delta(C)$\foot{That is,
-edges with exactly one endpoint in~$C$.} there exists a~path in~$C$ connecting the endpoints
+of~$G$'s edges with exactly one endpoint in~$C$.} there exists a~path in~$C$ connecting the endpoints
 of the edges $e,f$ such that all edges on this path are lighter than either $e$ or~$f$.
 
 \example\id{jarniscont}%
@@ -574,7 +574,7 @@ than this edge.
 We can now easily reformulate the Contraction lemma (\ref{contlemma}) in the language
 of contractible subgraphs. We again assume that we are working with multigraphs
 and that they need not be connected.
-Furthermore, we slightly abuse the notation and we omit the explicit bijection
+Furthermore, we slightly abuse the notation in the way that we omit the explicit bijection
 between $G-C$ and~$G/C$, so we can write $G=C \cup (G/C)$.
 
 \lemman{Generalized contraction}
@@ -582,77 +582,80 @@ When~$C\subseteq G$ is a~contractible subgraph, then $\msf(G)=\msf(C) \cup \msf(
 
 \proof
 As both sides of the equality are forests spanning the same graph, it suffices
-to show that $\msf(G) \subseteq \msf(C)\cup\msf(G/C)$. We know that the edges which
-does not participate in the MSF are exactly those which are the heaviest on some cycle
-(this is the Cycle rule \ref{cyclerule}).
+to show that $\msf(G) \subseteq \msf(C)\cup\msf(G/C)$.
+Let us show that edges of~$G$ that do not belong to the right-hand side
+do not belong to the left-hand side either.
+We know that the edges that
+do not participate in the MSF of some graph are exactly those which are the heaviest
+on some cycle (this is the Cycle rule, \ref{cyclerule}).
 
 Whenever an~edge~$g$ lies in~$C$, but not in~$\msf(C)$, then $g$~is the heaviest edge
 on some cycle in~$C$. As this cycle is also contained in~$G$, the edge $g$~does not participate
 in $\msf(G)$ either.
 
 Similarly for $g\in (G/C)\setminus\msf(G/C)$: when the cycle does not contain
-the vertex~$c$ to which we contracted the subgraph~$C$, the cycle is present
-in~$G$, too. Otherwise we consider the edges $e,f$ adjacent to~$c$ on this cycle.
+the vertex~$c$ to which we have contracted the subgraph~$C$, this cycle is present
+in~$G$, too. Otherwise we consider the edges $e,f$ incident with~$c$ on this cycle.
 Since $C$~is contractible, there must exist a~path~$P$ in~$C$ connecting the endpoints
 of~$e$ and~$f$ in~$G$, such that all edges of~$P$ are lighter than either $e$ or~$f$
 and hence also than~$g$. Expanding~$c$ in the cycle to the path~$P$ then produces
 a~cycle in~$G$ whose heaviest edge is~$g$.
 \qed
 
-We are ready to bring corruption back to the game now and state a~``robust'' version
+We are now ready to bring corruption back to the game and state a~``robust'' version
 of this lemma. A~notation for corrupted graphs will be handy:
 
 \nota\id{corrnota}%
 When~$G$ is a~weighted graph and~$R$ a~subset of its edges, we will use $G\crpt
 R$ to denote an arbitrary graph obtained from~$G$ by increasing the weights of
-some of the edges in~$R$. As usually, we will assume that all edge weights in this
-graph are pairwise distinct. While this is technically not true for the corruption
+some of the edges in~$R$. As usually, we will assume that all edges of this graph
+have pairwise distinct weights. While this is technically not true for the corruption
 caused by soft heaps, we can easily make the weights unique.
 
-If~$C$ is a~subgraph of~$G$, we will refer to the edges of~$R$ whose exactly
-one endpoint lies in~$C$ by~$R^C$ (i.e., $R^C = R\cap \delta(C)$).
+Whenever~$C$ is a~subgraph of~$G$, we will use $R^C$ to refer to the edges of~$R$ with
+exactly one endpoint in~$C$ (i.e., $R^C = R\cap \delta(C)$).
 
-\lemman{Robust contraction}\id{robcont}%
+\lemman{Robust contraction, Chazelle \cite{chazelle:almostacker}}\id{robcont}%
 Let $G$ be a~weighted graph and $C$~its subgraph contractible in~$G\crpt R$
-for some set of edges~$R$. Then $\msf(G) \subseteq \msf(C) \cup \msf((G/C) \setminus R^C) \cup R^C$.
+for some set~$R$ of edges. Then $\msf(G) \subseteq \msf(C) \cup \msf((G/C) \setminus R^C) \cup R^C$.
 
 \proof
 We will modify the proof of the previous lemma. We will again consider all possible types
-of edges which do not belong to the right-hand side and show that they are the
+of edges which do not belong to the right-hand side and we will show that they are the
 heaviest edges of certain cycles. Every edge~$g$ of~$G$ lies either in~$C$, or in $H=(G/C)\setminus R^C$,
 or possibly in~$R^C$.
 
 If $g\in C\setminus\msf(C)$, then the same argument as before applies.
 
-If $g\in H\setminus\msf(H)$, we consider the cycle in~$H$ on which $e$~is the heaviest.
-When $c$ (the vertex to which we have contracted~$C$) is outside this cycle, we are finished.
+If $g\in H\setminus\msf(H)$, we consider the cycle in~$H$ on which $g$~is the heaviest.
+When $c$ (the vertex to which we have contracted~$C$) is outside this cycle, we are done.
 Otherwise we observe that the edges $e,f$ adjacent to~$c$ on this cycle cannot be corrupted
 (they would be in~$R^C$ otherwise, which is impossible). By contractibility of~$C$ there exists
-a~path~$P$ in~$(G\crpt R)\cup C$ such that all edges of~$P$ are lighter than $e$ or~$f$ and hence
+a~path~$P$ in~$C\crpt (R\cap C)$ such that all edges of~$P$ are lighter than $e$ or~$f$ and hence
 also than~$g$. The weights of the edges of~$P$ in the original graph~$G$ cannot be higher than
 in~$G\crpt R$, so the path~$P$ is lighter than~$g$ even in~$G$ and we can again perform the
 trick with expanding the vertex~$c$ to~$P$ in the cycle~$C$. Hence $g\not\in\mst(G)$.
 \qed
 
 \para
-Our plan still is to mimic the Iterative Jarn\'\i{}k's algorithm. We will grow a~collection~$\C$
-of non-overlapping contractible subgraphs and put aside the edges which got corrupted in the process.
-We recursively compute the MSF of the subgraphs and of the contracted graph. Then we take the
+We still intend to mimic the Iterative Jarn\'\i{}k's algorithm. We will partition the given graph to a~collection~$\C$
+of non-overlapping contractible subgraphs called \df{clusters} and we put aside all edges that got corrupted in the process.
+We recursively compute the MSF of that subgraphs and of the contracted graph. Then we take the
 union of these MSF's and add the corrupted edges. According to the previous lemma, this does not produce
-the final MSF, but a~sparser graph containing it, on which we can continue.
+the MSF of~$G$, but a~sparser graph containing it, on which we can continue.
 
-We can formulate the exact partitioning algorithm as follows:
+We can formulate the exact partitioning algorithm and its properties as follows:
 
-\algn{Partition a~graph to a~collection of contractible subgraphs}\id{partition}%
+\algn{Partition a~graph to a~collection of contractible clusters}\id{partition}%
 \algo
-\algin A~graph~$G$ with an~edge comparison oracle, a~parameter~$t$ controlling the size of the subgraphs,
+\algin A~graph~$G$ with an~edge comparison oracle, a~parameter~$t$ controlling the size of the clusters,
   and an~accuracy parameter~$\varepsilon$.
 \:Mark all vertices as ``live''.
 \:$\C\=\emptyset$, $R^\C\=\emptyset$. \cmt{Start with an~empty collection and no corrupted edges.}
 \:While there is a~live vertex~$v_0$:
-\::$T=\{v_0\}$. \cmt{the tree we currently grow}
-\::$K=\emptyset$. \cmt{edges known to be corrupted}
-\::\<Create> a~soft heap with accuracy~$\varepsilon$ and \<Insert> the edges adjacent to~$v_0$ in it.
+\::$T=\{v_0\}$. \cmt{the tree that we currently grow}
+\::$K=\emptyset$. \cmt{edges known to be corrupted in the current iteration}
+\::\<Create> a~soft heap with accuracy~$\varepsilon$ and \<Insert> the edges adjacent to~$v_0$ into it.
 \::While the heap is not empty and $\vert T\vert \le t$:
 \:::\<DeleteMin> an~edge $uv$ from the heap, assume $u\in T$.
 \:::If $uv$ was corrupted, add it to~$K$.
@@ -660,48 +663,53 @@ We can formulate the exact partitioning algorithm as follows:
 \:::$T\=T\cup\{v\}$.
 \:::If $v$ is dead, break out of the current loop.
 \:::Insert all edges incident with~$v$ to the heap.
-\::$\C\=\C \cup \{G[T]\}$. \cmt{Record the subgraph induced by the tree.}
+\::$\C\=\C \cup \{G[T]\}$. \cmt{Record the cluster induced by the tree.}
 \::\<Explode> the heap and add all remaining corrupted edges to~$K$.
-\::$R^\C\=R^\C \cup \{ K^T \}$. \cmt{Record the ``interesting'' corrupted edges.}
+\::$R^\C\=R^\C \cup K^T$. \cmt{Record the ``interesting'' corrupted edges.}
 \::$G\=G\setminus K^T$. \cmt{Remove the corrupted edges from~$G$.}
 \::Mark all vertices of~$T$ as ``dead''.
-\algout The collection $\C$ of contractible subgraphs and the set~$R^\C$ of
-corrupted edges in the neighborhood of these subgraphs.
+\algout The collection $\C$ of contractible clusters and the set~$R^\C$ of
+corrupted edges in the neighborhood of these clusters.
 \endalgo
 
-\thmn{Partitioning to contractible subgraphs, Pettie \cite{pettie:optimal}}\id{partthm}%
+\thmn{Partitioning to contractible clusters, Chazelle \cite{chazelle:almostacker}}\id{partthm}%
 Given a~weighted graph~$G$ and parameters $\varepsilon$ ($0<\varepsilon\le 1/2$)
-and~$t$, the Partition algorithm \ref{partition} constructs a~collection
-$\C=\{C_1,\ldots,C_k\}$ of subgraphs and a~set~$R^\C$ of corrupted edges such that:
+and~$t$, the Partition algorithm (\ref{partition}) constructs a~collection
+$\C=\{C_1,\ldots,C_k\}$ of clusters and a~set~$R^\C$ of edges such that:
 
 \numlist\ndotted
-\:All the $C_i$'s and the set~$R^\C$ are edge-disjoint.
-\:Each $C_i$ contains at most~$t$ vertices.
-\:Each vertex of~$G$ is contained in at least one~$C_i$.
-\:The connected components of the union of all $C_i$'s have at least~$t$ vertices each,
-  except perhaps for those which are equal to a~connected component of~$G\setminus R^\C$.
+\:All the clusters and the set~$R^\C$ are mutually edge-disjoint.
+\:Each cluster contains at most~$t$ vertices.
+\:Each vertex of~$G$ is contained in at least one cluster.
+\:The connected components of the union of all clusters have at least~$t$ vertices each,
+  except perhaps for those which are equal to a~connected component of $G\setminus R^\C$.
 \:$\vert R^\C\vert \le 2\varepsilon m$.
 \:$\msf(G) \subseteq \bigcup_i \msf(C_i) \cup \msf\bigl((G / \bigcup_i C_i) \setminus R^\C\bigr) \cup R^\C$.
 \:The algorithm runs in time $\O(n+m\log (1/\varepsilon))$.
 \endlist
 
 \proof
-The algorithm grows a~series of trees. A~tree is built from edges adjacent to live vertices
+Claim~1: The Partition algorithm grows a~series of trees which induce the clusters~$C_i$ in~$G$.
+A~tree is built from edges adjacent to live vertices
 and once it is finished, all vertices of the tree die, so no edge is ever reused in another
-tree. Edges of~$R^\C$ are immediately deleted from the graph, so they never participate
-in any tree. The algorithm stops only if all vertices are dead, so each vertex must have
-entered some tree. Each $C_i$ is induced by some tree and the trees have at most~$t$ vertices
-each, which limits the size of the $C_i$'s as well. This proves claims 1--3.
+tree. The edges that enter~$R^\C$ are immediately deleted from the graph, so they never participate
+in any tree.
+
+Claim~2: The algorithm stops when all vertices are dead, so each vertex must have
+entered some tree.
+
+Claim~3: The trees have at most~$t$ vertices each, which limits the size of the
+$C_i$'s as well.
 
 Claim~4: We can show that each connected component has $t$~or more vertices as we already did
-in the proof of Lemma \ref{ijsize}: How can a~new tree stop growing? Either it already
-has~$t$ vertices, or it joins one of the existing trees (which only increases the
+in the proof of Lemma \ref{ijsize}: How can a~new tree stop growing? Either it gathers
+$t$~vertices, or it joins one of the existing trees (this only increases the
 size of the component), or the heap becomes empty (which means that the tree spans
-a~full component of the current graph and hence also of~$G\setminus R^\C$).
+a~full component of the current graph and hence also of the final~$G\setminus R^\C$).
 
 Claim~5: The set~$R^\C$ contains a~subset of edges corrupted by the soft heaps over
-the course of the algorithm. As every edge is inserted to a~heap at most once
-in every direction, the heaps can corrupt at worst $2\varepsilon m$ edges altogether.
+the course of the algorithm. As every edge is inserted to a~heap at most once per
+its endpoint, the heaps can corrupt at worst $2\varepsilon m$ edges altogether.
 
 We will prove the remaining two claims as separate lemmata.
 \qed
@@ -711,54 +719,54 @@ $$\msf(G) \subseteq \bigcup_i \msf(C_i) \cup \msf\biggl( \bigl(G / \bigcup_i C_i
 
 \proof
 By iterating the Robust contraction lemma (\ref{robcont}). Let $K_i$ be the set of edges
-corrupted when constructing the subgraph~$C_i$ in the $i$-th phase (iteration of the outer
-loop) of the algorithm, and similarly for the state of the other variables at that time.
+corrupted when constructing the cluster~$C_i$ in the $i$-th phase of the algorithm,
+and similarly for the state of the other variables at that time.
 We will use induction on~$i$ to prove that the lemma holds at the end of every phase.
 
 At the beginning, the statement is obviously true, even as an~equality.
-In the $i$-th phase, we construct the subgraph~$C_j$ by running the partial Jarn\'\i{}k's algorithm on the graph
-$G_i = G\setminus\bigcup_{j<i} K_{\smash j}^{\C_j}$.
-If it were not for corruption, the subgraph~$C_i$ would be contractible, as we already know from Example \ref{jarniscont}.
-When the edges in~$K_i$ get corrupted, the subgraph is contractible in some corrupted graph
+In the $i$-th phase we construct the cluster~$C_i$ by running the partial Jarn\'\i{}k's algorithm on the graph
+$G_i = G\setminus\bigcup_{j<i} K_{\smash j}^{C_j}$.
+If it were not for corruption, the cluster~$C_i$ would be contractible, as we already know from Example \ref{jarniscont}.
+When the edges in~$K_i$ get corrupted, the cluster is contractible in some corrupted graph
 $G_i \crpt K_i$. (We have to be careful as the edges are becoming corrupted gradually,
-but it is easy to check that it can only improve the situation.) Since $C_i$~is edge-disjoint
-with the previous trees, it is also a~contractible subgraph of $(G_i / \bigcup_{j<i} C_j) \crpt K_i$.
+but it is easy to check that it can only improve the situation.) Since $C_i$~shares no edges
+with~$C_j$ for any~$j<i$, we know that~$C_i$ also a~contractible subgraph of $(G_i / \bigcup_{j<i} C_j) \crpt K_i$.
 Now we can use the Robust contraction lemma to show that:
 $$
-\msf\biggl(\bigl(G / \bigcup_{i<j} \bigr) \setminus \bigcup_{i<j} K_j^{\C_j} \biggr) \subseteq
-\msf(C_i) \cup \msf\biggl(\bigl(G / \bigcup_{i\le j} \bigr) \setminus \bigcup_{i\le j} K_j^{\C_j} \biggr) \cup K_i^{C_i},
+\msf\biggl(\bigl(G / \bigcup_{j<i} C_j \bigr) \setminus \bigcup_{j<i} K_j^{C_j} \biggr) \subseteq
+\msf(C_i) \cup \msf\biggl(\bigl(G / \bigcup_{j\le i} C_j \bigr) \setminus \bigcup_{j\le i} K_j^{C_j} \biggr) \cup K_i^{C_i}.
 $$
-which completes the induction step.
+This completes the induction step, because $K_j^{C_j} = K_j^{\C_j}$ for all~$j$.
 \qed
 
 \lemman{Efficiency of Partition, Claim 7 of Theorem \ref{partthm}}
 The Partition algorithm runs in time $\O(n+m\log(1/\varepsilon))$.
 
 \proof
-The inner loop (steps 7--13) processes the edges of the current subgraph~$C_i$ and also
-the edges in its neighborhood $\delta(C_i)$. Steps 6 and~13 insert each such edge to the heap
-at most once, so steps 8--12 also visit each edge at most once. For every edge, we spend
+The inner loop (steps 7--13) processes the edges of the current cluster~$C_i$ and also
+the edges in its neighborhood $\delta(C_i)$. Steps 6 and~13 insert every such edge to the heap
+at most once, so steps 8--12 visit each edge also at most once. For every edge, we spend
 $\O(\log(1/\varepsilon))$ time amortized on inserting it and $\O(1)$ on the other operations
 (by Theorem \ref{softheap} on performance of the soft heaps).
 
 Each edge of~$G$ can participate in some $C_i\cup \delta(C_i)$ only twice before both its
-ends die. The inner loop therefore processes $\O(m)$ edges total, so we spend $\O(m\log(1/\varepsilon))$
-time there. The rest of the algorithm spends $\O(m)$ time on the other operations with subgraphs
-and $\O(n)$ on identifying the live vertices.
+endpoints die. The inner loop therefore processes $\O(m)$ edges total, so it takes $\O(m\log(1/\varepsilon))$
+time. The remaining parts of the algorithm spend $\O(m)$ time on operations with clusters and corrupted edges
+and additionally $\O(n)$ on identifying the live vertices.
 \qed
 
 %--------------------------------------------------------------------------------
 
 \section{Decision trees}
 
-The Pettie's algorithm combines the idea of robust partitioning with optimal decision
+The Pettie's and Ramachandran's algorithm combines the idea of robust partitioning with optimal decision
 trees constructed by brute force for very small subgraphs. In this section, we will
 explain the basics of the decision trees and prove several lemmata which will
-turn out to be useful for the analysis of time complexity of the whole algorithm.
+turn out to be useful for the analysis of time complexity of the final algorithm.
 
-Let us consider all computations of a~comparison-based MST algorithm when we
+Let us consider all computations of some comparison-based MST algorithm when we
 run it on a~fixed graph~$G$ with all possible permutations of edge weights.
-They can be described by a~tree. The root of the tree corresponds to the first
+The computations can be described by a~binary tree. The root of the tree corresponds to the first
 comparison performed by the algorithm and depending to its result, the computation
 continues either in the left subtree or in the right subtree. There it encounters
 another comparison and so on, until it arrives to a~leaf of the tree where the
@@ -768,9 +776,10 @@ Formally, the decision trees are defined as follows:
 
 \defnn{Decision trees and their complexity}\id{decdef}%
 A~\df{MSF decision tree} for a~graph~$G$ is a~binary tree. Its internal vertices
-are labeled with pairs of edges to be compared, each of the two outgoing edges
-corresponds to one possible result of the comparison.\foot{There is no reason
-to compare an~edge with itself and we, as usually, expect that the edge weights are distinct.}
+are labeled with pairs of $G$'s edges to be compared, each of the two outgoing edges
+corresponds to one possible result of the comparison.\foot{There are two possible
+outcomes since there is no reason to compare an~edge with itself and we, as usually,
+expect that the edge weights are distinct.}
 Leaves of the tree are labeled with spanning trees of the graph~$G$.
 
 A~\df{computation} of the decision tree on a~specific permutation of edge weights
@@ -783,7 +792,7 @@ computation results in the real MSF of~$G$ with the particular weights.
 The \df{time complexity} of a~decision tree is defined as its depth. It therefore
 bounds the number of comparisons spent on every path. (It need not be equal since
 some paths need not correspond to an~actual computation --- the sequence of outcomes
-on the path can be unsatifisfiable.)
+on the path could be unsatifisfiable.)
 
 A~decision tree is called \df{optimal} if it is correct and its depth is minimum possible
 among the correct decision trees for the given graph.
@@ -810,12 +819,12 @@ can be used as an~upper bound for the decision tree complexity. For example:
 $D(m,n) \le 4/3 \cdot n^2$.
 
 \proof
-Let us count the comparisons performed by the contractive Bor\o{u}vka's algorithm.
-(\ref{contbor}), tightening up the constants in the original analysis in Theorem
-\ref{contborthm}. In the first phase, each edge participates in two comparisons
+Let us count the comparisons performed by the Contractive Bor\o{u}vka's algorithm.
+(\ref{contbor}), tightening up the constants in its previous analysis in Theorem
+\ref{contborthm}. In the first iteration, each edge participates in two comparisons
 (one for each its endpoint), so the algorithm performs at most $2m \le 2{n\choose 2} \le n^2$
 comparisons. Then the number of vertices drops at least by a~factor of two, so
-the subsequent phases spend at most $(n/2)^2, (n/4)^2, \ldots$ comparisons, which sums
+the subsequent iterations spend at most $(n/2)^2, (n/4)^2, \ldots$ comparisons, which sums
 to less than $n^2\cdot\sum_{i=0}^\infty (1/4)^i = 4/3 \cdot n^2$. Between the phases,
 we flatten the multigraph to a~simple graph, which also needs some comparisons,
 but for every such comparison we remove one of the participating edges, which saves
@@ -828,54 +837,50 @@ show how to find the optimal trees using brute force. The complexity of the sear
 will be of course enormous, but as we already promised, we will need the optimal
 trees only for very small subgraphs.
 
-\lemman{Construction of optimal decision trees}
-Optimal MST decision trees for all graphs on at most~$k$ vertices can be
-constructed on the Pointer machine in time $\O(2^{2^{4k^2}})$.
+\lemman{Construction of optimal decision trees}\id{odtconst}%
+An~optimal MST decision tree for a~graph~$G$ on~$n$ vertices can be constructed on
+the Pointer machine in time $\O(2^{2^{4n^2}})$.
 
 \proof
-There are $2^{k\choose 2} \le 2^{k^2}$ undirected graphs on~$k$ vertices. Any
-graph on less than~$k$ vertices can be extended to $k$~vertices by adding isolated
-vertices, which obviously do not affect the optimal decision tree.
-
-For every graph~$G$, we will try all possible decision trees of depth at most $2k^2$
-(we know from the previous lemma that the optimal tree is shallower). We can obtain
+We will try all possible decision trees of depth at most $2n^2$
+(we know from the previous lemma that the desired optimal tree is shallower). We can obtain
 any such tree by taking the complete binary tree of exactly this depth
-and labeling its $2\cdot 2^{2k^2}-1$ vertices with comparisons and spanning trees. Those labeled
+and labeling its $2\cdot 2^{2n^2}-1$ vertices with comparisons and spanning trees. Those labeled
 with comparisons become internal vertices of the decision tree, the others
-become leaves and the parts of the tree below them are cut. There are less
-than $k^4$ possible comparisons and less than $2^{k^2}$ spanning trees of~$G$,
+become leaves and the parts of the tree below them are removed. There are less
+than $n^4$ possible comparisons and less than $2^{n^2}$ spanning trees of~$G$,
 so the number of candidate decision trees is bounded by
-$(k^4+2^{k^2})^{2^{2k^2+1}} \le 2^{(k^2+1)\cdot 2^{2k^2+1}} \le 2^{2^{2k^2+2}} \le 2^{2^{3k^2}}$.
+$(n^4+2^{n^2})^{2^{2n^2+1}} \le 2^{(n^2+1)\cdot 2^{2n^2+1}} \le 2^{2^{2n^2+2}} \le 2^{2^{3n^2}}$.
 
-We will enumerate the trees in an~arbitrary order, test each for correctness and
+We will enumerate the trees in an~arbitrary order, test each of them for correctness and
 find the shallowest tree among those correct. Testing can be accomplished by running
 through all possible permutations of edges, each time calculating the MSF using any
 of the known algorithms and comparing it with the result given by the decision tree.
-The number of permutations does not exceed $(k^2)! \le (k^2)^{k^2} \le k^{2k^2} \le 2^{k^3}$
-and each permutation can be checked in time $\O(\poly(k))$.
+The number of permutations does not exceed $(n^2)! \le (n^2)^{n^2} \le n^{2n^2} \le 2^{n^3}$
+and each permutation can be checked in time $\O(\poly(n))$.
 
-On the Pointer machine, graphs, trees and permutations can be certainly enumerated in time
-$\O(\poly(k))$ per object. The time complexity of the whole algorithm is therefore
-$\O(2^{k^2} \cdot 2^{2^{3k^2}} \cdot 2^{k^3} \cdot \poly(k)) = \O(2^{2^{4k^2}})$.
+On the Pointer machine, trees and permutations can be certainly enumerated in time
+$\O(\poly(n))$ per object. The time complexity of the whole algorithm is therefore
+$\O(2^{2^{3n^2}} \cdot 2^{n^3} \cdot \poly(n)) = \O(2^{2^{4n^2}})$.
 \qed
 
-\paran{Basic properties of decision trees}
+\paran{Basic properties of decision trees}%
 The following properties will be useful for analysis of algorithms based
 on precomputed decision trees. We will omit some technical details, referring
-the reader to section 5.1 of the Pettie's paper \cite{pettie:optimal}.
+the reader to section 5.1 of the Pettie's article \cite{pettie:optimal}.
 
-\lemma
+\lemma\id{dtbasic}%
 The decision tree complexity $D(m,n)$ of the MSF satisfies:
 \numlist\ndotted
 \:$D(m,n) \ge m/2$ for $m,n > 2$.
-\:$D(m',n') \ge D(m,n)$ whenever $m'\ge mn'\ge n$.
+\:$D(m',n') \ge D(m,n)$ whenever $m'\ge m$ and $n'\ge n$.
 \endlist
 
 \proof
 For every $m,n>2$ there is a~graph on $n$~vertices and $m$~edges such that
 every edge lies on a~cycle. Every correct MSF decision tree for this graph
 has to compare each edge at least once. Otherwise the decision tree cannot
-distinguish between the case when the edge has the lowest of all weights (and
+distinguish between the case when an~edge has the lowest of all weights (and
 thus it is forced to belong to the MSF) and when it has the highest weight (so
 it is forced out of the MSF).
 
@@ -892,7 +897,7 @@ iff they are edge-disjoint, their union is the whole graph~$G$ and
 $\msf(G) = \bigcup_i \msf(C_i)$ for every permutation of edge weights.
 
 \lemma\id{partiscomp}%
-The subgraphs $C_1,\ldots,C_k$ generated by the Partition procedure of the
+The clusters $C_1,\ldots,C_k$ generated by the Partition procedure of the
 previous section (Algorithm \ref{partition}) are compartments of the graph
 $H=\bigcup_i C_i$.
 
@@ -904,17 +909,17 @@ is the union of the MSF's of the individual compartments. By the Cycle rule
 it is the heaviest edge on some cycle. It is therefore sufficient to prove that
 every cycle in~$H$ is contained within a~single~$C_i$.
 
-Let us consider a~cycle $K\subseteq H$ and a~subgraph~$C_i$ such that it contains
-an~edge~$e$ of~$K$ and all subgraphs constructed later by the procedure do not contain
+Let us consider a~cycle $K\subseteq H$ and a~cluster~$C_i$ such that it contains
+an~edge~$e$ of~$K$ and all clusters constructed later by the procedure do not contain
 any. If $K$~is not fully contained in~$C_i$, we can extend the edge~$e$ to a~maximal
 path contained in both~$K$ and~$C_i$. Since $C_i$ shares at most one vertex with the
-earlier components, there can be at most one edge from~$K$ adjacent to the maximal path,
+earlier clusters, there can be at most one edge from~$K$ adjacent to the maximal path,
 which is impossible.
 \qed
 
 \lemma
 Let $C_1,\ldots,C_k$ be compartments of a~graph~$G$. Then there exists an~optimal
-MSF decision tree for~$G$ that does not compare edges from distinct compartments.
+MSF decision tree for~$G$ that does not compare edges of distinct compartments.
 
 \proofsketch
 Consider a~subset~$\cal P$ of edge weight permutations~$w$ that satisfy $w(e) < w(f)$
@@ -943,19 +948,19 @@ A~collection of decision trees for the individual compartments can be ``glued to
 to a~decision tree for~$G$. We take the decision tree for~$C_1$, replace every its leaf
 by a~copy of the tree for~$C_2$ and so on. Every leaf~$\ell$ of the compound tree will be
 labeled with the union of labels of the original leaves encountered on the path from
-the root to the new leaf~$\ell$. This proves that $D(G) \le \sum_i D(C_i)$.
+the root to~$\ell$. This proves that $D(G) \le \sum_i D(C_i)$.
 
 The other inequality requires more effort. We use the previous lemma to transform
 the optimal decision tree for~$G$ to another of the same depth, but without inter-compartment
 comparisons. Then we prove by induction on~$k$ and then on the depth of the tree
-that the tree can be re-arranged, so that every computation first compares edges
+that this tree can be re-arranged, so that every computation first compares edges
 from~$C_1$, then from~$C_2$ and so on. This means that the tree can be decomposed
-to decision trees for the $C_i$'s and without loss of generality all trees for
-a~single~$C_i$ can be made isomorphic.
+to decision trees for the $C_i$'s. Also, without loss of generality all trees for
+a~single~$C_i$ can be made isomorphic to~${\cal D}(C_i)$.
 \qed
 
-\cor
-If $C_1,\ldots,C_k$ are the subgraphs generated by the Partition procedure (Algorithm \ref{partition}),
+\cor\id{dtpart}%
+If $C_1,\ldots,C_k$ are the clusters generated by the Partition procedure (Algorithm \ref{partition}),
 then $D(\bigcup_i C_i) = \sum_i D(C_i)$.
 
 \proof
@@ -963,11 +968,182 @@ Lemma \ref{partiscomp} tells us that $C_1,\ldots,C_k$ are compartments of the gr
 $\bigcup C_i$, so we can apply Lemma \ref{compartsum} on them.
 \qed
 
+\cor\id{dttwice}%
+$2D(m,n) \le D(2m,2n)$ for every $m,n$.
+
+\proof
+For an~arbitrary graph~$G$ with $m$~edges and $n$~vertices, we create a~graph~$G_2$
+consisting of two copies of~$G$ sharing a~single vertex. The copies of~$G$ are obviously
+compartments of~$G_2$, so by Lemma \ref{compartsum} it holds that $D(G_2) = 2D(G)$.
+Taking a~maximum over all choices of~$G$ yields $D(2m,2n) \ge \max_G D(G_2) = 2D(m,n)$.
+\qed
+
 %--------------------------------------------------------------------------------
 
-\section{An optimal algorithm}
+\section{An optimal algorithm}\id{optalgsect}%
+
+Once we have developed the soft heaps, partitioning and MST decision trees,
+it is now simple to state the Pettie's and Ramachandran's MST algorithm
+and prove that it is asymptotically optimal among all MST algorithms in
+comparison-based models. Several standard MST algorithms from the previous
+chapters will also play their roles.
+
+We will describe the algorithm as a~recursive procedure. When the procedure is
+called on a~graph~$G$, it sets the parameter~$t$ to roughly $\log^{(3)} n$ and
+it calls the \<Partition> procedure to split the graph into a~collection of
+clusters of size~$t$ and a~set of corrupted edges. Then it uses precomputed decision
+trees to find the MSF of the clusters. The graph obtained by contracting
+the clusters is on the other hand dense enough, so that the Iterated Jarn\'\i{}k's
+algorithm runs on it in linear time. Afterwards we combine the MSF's of the clusters
+and of the contracted graphs, we mix in the corrupted edges and run two iterations
+of the Contractive Bor\o{u}vka's algorithm. This guarantees reduction in the number of
+both vertices and edges by a~constant factor, so we can efficiently recurse on the
+resulting graph.
+
+\algn{Optimal MST algorithm, Pettie and Ramachandran \cite{pettie:optimal}}\id{optimal}%
+\algo
+\algin A~connected graph~$G$ with an~edge comparison oracle.
+\:If $G$ has no edges, return an~empty tree.
+\:$t\=\lfloor\log^{(3)} n\rfloor$. \cmt{the size of clusters}
+\:Call \<Partition> (\ref{partition}) on $G$ and $t$ with $\varepsilon=1/8$. It returns
+  a~collection~$\C=\{C_1,\ldots,C_k\}$ of clusters and a~set~$R^\C$ of corrupted edges.
+\:$F_i \= \mst(C_i)$ for all~$i$, obtained using optimal decision trees.
+\:$G_A \= (G / \bigcup_i C_i) \setminus R^\C$. \cmt{the contracted graph}
+\:$F_A \= \msf(G_A)$ calculated by the Iterated Jarn\'\i{}k's algorithm (\ref{itjar}).
+\:$G_B \= \bigcup_i F_i \cup F_A \cup R^\C$. \cmt{combine subtrees with corrupted edges}
+\:Run two iterations of the Contractive Bor\o{u}vka's algorithm (\ref{contbor}) on~$G_B$,
+  getting a~contracted graph~$G_C$ and a~set~$F_B$ of MST edges.
+\:$F_C \= \mst(G_C)$ obtained by a~recursive call to this algorithm.
+\:Return $F_B \cup F_C$.
+\algout The minimum spanning tree of~$G$.
+\endalgo
 
+Correctness of this algorithm immediately follows from the Partitioning theorem (\ref{partthm})
+and from the proofs of the respective algorithms used as subroutines. Let us take a~look at
+the time complexity. We will be careful to use only the operations offered by the Pointer machine.
 
+\lemma\id{optlemma}%
+The time complexity $T(m,n)$ of the Optimal algorithm satisfies the following recurrence:
+$$
+T(m,n) \le \sum_i c_1 D(C_i) + T(m/2, n/4) + c_2 m,
+$$
+where~$c_1$ and~$c_2$ are some positive constants and $D$~is the decision tree complexity
+from the previous section.
 
+\proof
+The first two steps of the algorithm are trivial as we have linear time at our
+disposal.
+
+By the Partitioning theorem (\ref{partthm}), the call to \<Partition> with~$\varepsilon$
+set to a~constant takes $\O(m)$ time and it produces a~collection of clusters of size
+at most~$t$ and at most $m/4$ corrupted edges. It also guarantees that the
+connected components of the union of the $C_i$'s have at least~$t$ vertices
+(unless there is just a~single component).
+
+To apply the decision trees, we will use the framework of topological computations developed
+in Section \ref{bucketsort}. We pad all clusters in~$\C$ with isolated vertices, so that they
+have exactly~$t$ vertices. We use a~computation that labels the graph with a~pointer to
+its optimal decision tree. Then we apply Theorem \ref{topothm} combined with the
+brute-force construction of optimal decision trees from Lemma \ref{odtconst}. Together they guarantee
+that we can assign the decision trees to the clusters in time:
+$$\O\Bigl(\Vert\C\Vert + t^{t(t+2)} \cdot \bigl(2^{2^{4t^2}} + t^2\bigr)\Bigr)
+= \O\Bigl(m + 2^{2^{2^t}}\Bigr)
+= \O(m).$$
+Execution of the decision tree on each cluster~$C_i$ then takes $\O(D(C_i))$ steps.
+
+The contracted graph~$G_A$ has at most $n/t = \O(n / \log^{(3)}n)$ vertices and asymptotically
+the same number of edges as~$G$, so according to Corollary \ref{ijdens}, the Iterated Jarn\'\i{}k's
+algorithm runs on it in linear time.
+
+The combined graph~$G_B$ has~$n$ vertices, but less than~$n$ edges from the
+individual spanning trees and at most~$m/4$ additional edges which were
+corrupted. The iterations of the Bor\o{u}vka's algorithm on~$G_B$ take $\O(m)$
+time by Lemma \ref{boruvkaiter} and they produce a~graph~$G_C$ with at most~$n/4$
+vertices and at most $n/4 + m/4 \le m/2$ edges. (The $n$~tree edges in~$G_B$ are guaranteed
+to be reduced by the Bor\o{u}vka's algorithm.) It is easy to verify that this
+graph is still connected, so we can recurse on it.
+
+The remaining steps of the algorithm can be easily performed in linear time either directly
+or in case of the contractions by the bucket-sorting techniques of Section \ref{bucketsort}.
+\qed
+
+\paran{Optimality}%
+The properties of decision tree complexity, which we have proven in the previous
+section, will help us show that the time complexity recurrence is satisfied by a~constant
+multiple of the decision tree complexity $D(m,n)$ itself. This way, we will prove
+the following theorem:
+
+\thmn{Optimality of the Optimal algorithm}
+The time complexity of the Optimal MST algorithm \ref{optimal} is $\Theta(D(m,n))$.
+
+\proof
+We will prove by induction that $T(m,n) \le cD(m,n)$ for some $c>0$. The base
+case is trivial, for the induction step we will expand on the previous lemma:
+\def\eqalign#1{\null\,\vcenter{\openup\jot
+  \ialign{\strut\hfil$\displaystyle{##}$&$\displaystyle{{}##}$\hfil
+      \crcr#1\crcr}}\,}
+$$\vcenter{\openup\jot\halign{\strut\hfil $\displaystyle{#}$&$\displaystyle{{}#}$\hfil&\quad#\hfil\cr
+T(m,n)
+    &\le \sum_i c_1 D(C_i) + T(m/2, n/4) + c_2 m &(Lemma \ref{optlemma})\cr
+    &\le c_1 D({\textstyle\bigcup}_i C_i) + T(m/2, n/4) + c_2 m &(Corollary \ref{dtpart})\cr
+    &\le c_1 D(m,n) + T(m/2, n/4) + c_2m &(definition of $D(m,n)$)\cr
+    &\le c_1 D(m,n) + cD(m/2, n/4) + c_2m &(induction hypothesis)\cr
+    &\le c_1 D(m,n) + c/2\cdot D(m,n/2) + c_2m &(Corollary \ref{dttwice})\cr
+    &\le c_1 D(m,n) + c/2\cdot D(m,n) + 2c_2 D(m,n) &(Lemma \ref{dtbasic})\cr
+    &\le (c_1 + c/2 + 2c_2) \cdot D(m,n)&\cr
+    &\le cD(m,n). &(by setting $c=2c_1+4c_2$)\cr
+}}$$
+The other inequality is obvious as $D(m,n)$ is an~asymptotic lower bound on
+the time complexity of every comparison-based algorithm.
+\qed
+
+\paran{Complexity of MST}%
+As we have already noted, the exact decision tree complexity $D(m,n)$ of the MST problem
+is still open and so is therefore the time complexity of the optimal algorithm. However,
+every time we come up with another comparison-based algorithm, we can use its complexity
+(or more specifically the number of comparisons it performs, which can be even lower)
+as an~upper bound on the optimal algorithm.
+
+The best explicit comparison-based algorithm known to date achieves complexity $\O(m\timesalpha(m,n))$.
+It has been discovered by Chazelle \cite{chazelle:ackermann} as an~improvement of his previous
+$\O(m\timesalpha(m,n)\cdot\log\alpha(m,n))$ algorithm \cite{chazelle:almostacker}.
+It is also based on the ideas of this chapter --- in particular the soft heaps and robust contractions.
+The algorithm is very complex and it involves a~lot of elaborate
+technical details, so we only refer to the original paper here. Another algorithm of the same
+complexity, using similar ideas, has been discovered independently by Pettie \cite{pettie:ackermann}, who,
+having the optimal algorithm at hand, does not take care about the low-level details and he only
+bounds the number of comparisons. Using any of these results, we can prove an~Ackermannian
+upper bound on the optimal algorithm:
+
+\thmn{Upper bound on complexity of the Optimal algorithm}
+The time complexity of the Optimal MST algorithm is $\O(m\timesalpha(m,n))$.
+
+\proof
+We bound $D(m,n)$ by the number of comparisons performed by the algorithm of Chazelle \cite{chazelle:ackermann}
+or Pettie \cite{pettie:ackermann}.
+\qed
+
+\rem
+It is also known from \cite{pettie:optimal} that when we run the Optimal algorithm on a~random
+graph drawn from either $G_{n,p}$ (random graphs on~$n$ vertices, each edge is included with probability~$p$
+independently on the other edges) or $G_{n,m}$ (we draw the graph uniformly at random from the
+set of all graphs with~$n$ vertices and $m$~edges), it runs in linear time with high probability,
+regardless of the edge weights.
+
+\paran{Models of computation}%
+Another important consequence of the optimal algorithm is that when we aim for a~linear-time
+MST algorithm (or for proving that it does not exist), we do not need to care about computational
+models at all. The elaborate RAM data structures of Chapter \ref{ramchap}, which have helped us
+so much in the case of integer weights, cannot help if we are allowed to access the edge weights
+by performing comparisons only. We can even make use of non-uniform objects given by some sort
+of oracle. Indeed, whatever trick we employ to achieve linear time complexity, we can mimic it in the
+world of decision trees and thus we can use it to show that the algorithm we already knew is
+also linear.
+
+This however applies to deterministic algorithms only --- we have shown that access to a~source
+of random bits allows us to compute the MST in expected linear time (the KKT algorithm, \ref{kkt}).
+There were attempts to derandomize the KKT algorithm, but so far the best result in this direction
+is the randomized algorithm also by Pettie \cite{pettie:minirand} which achieves expected linear time
+complexity with only $\O(\log^* n)$ random bits.
 
 \endpart