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 two identical edges.}
+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
\ref{contborthm}. In the first phase, 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 $(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$.
+the subsequent phases 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
+at least one comparison in the subsequent phases.
\qed
\para
will be of course enormous, but as we already promised, we will need the optimal
trees only for very small subgraphs.
-\lemma
+\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^{k^3}})$.
+constructed on the Pointer machine in time $\O(2^{2^{4k^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 expanded to $k$~vertices by adding isolated
+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, we will try all possible trees of depth at most $4/3\cdot k^2$
-(we know from the previous lemma that the optimal tree is not deeper). Each such
-tree has at most $2^{2k^2}$ internal vertices and at most $2^{2k^2}$ leaves.
-All internal vertices are labeled with comparisons and there are less than $k^4$
-ways how to select the edges to be compared. Each leaf is labeled with one of the
-at most $2^{k^2}$ spanning trees. There are therefore at most $(2^{2k^2})^{2^{2k^2}}
-\le 2^{2k^2\cdot 2^{2k^2}} \le 2^{2^{k^3}}$ candidate trees and we will enumerate them
-in order of increasing depth.
-
-\FIXME{Continue with verifying correctness.}
-
+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
+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
+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$,
+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}}$.
+
+We will enumerate the trees in an~arbitrary order, test each 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))$.
+
+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}})$.
\qed