]> mj.ucw.cz Git - saga.git/commitdiff
Contractions rulez.
authorMartin Mares <mj@ucw.cz>
Fri, 18 Jan 2008 13:39:34 +0000 (14:39 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 18 Jan 2008 13:39:34 +0000 (14:39 +0100)
macros.tex
mst.tex
notation.tex

index d75944d9aa34c7e1c488240c14e1494e32b3c376..f76339459a6a7861b57acff9e00267e6a47db256 100644 (file)
 \parskip=1pt plus 1pt minus 0.3pt
 \rightskip=2em
 \itemcount=0
+\smallskip
 }
 \def\endalgo{\interlistskip\endgroup}
 \def\algopar{\par
 \leavevmode
 }
 \def\algoitem{
-\ifnum\itemcount=0\smallskip\fi
 \algopar\advance\itemcount by 1
 \hbox to 2em{\hss \the\itemcount. }%
 \futurelet\next\algoitemh}
diff --git a/mst.tex b/mst.tex
index f5d935c51583889e7a60601f651d14eca9d3bfd9..357e3b2c0e270e47ba343a36cee9cf868bc7179c 100644 (file)
--- a/mst.tex
+++ b/mst.tex
@@ -279,7 +279,7 @@ The three classical MST algorithms can be easily stated in terms of the Red-Blue
 \algo
 \algin A~graph~$G$ with an edge comparison oracle.
 \:Sort edges of~$G$ by their increasing weight.
-\:$T\=\emptyset$. \cmt{an empty spanning subgraph}
+\:$T\=\emptyset$.~~(an empty spanning subgraph)
 \:For all edges $e$ in their sorted order:
 \::If $T+e$ is acyclic, add~$e$ to~$T$.
 \::Otherwise drop~$e$.
@@ -325,12 +325,69 @@ number of blue edges.
 
 \proof
 Again $T$ is a blue forest, because every addition of some edge~$e_i$ to~$T$ is a straightforward
-application of the Blue rule. It remains to show that adding the edges simultaneously does not
-produce a cycle.
-\FIXME{Finish}
+application of the Blue rule.
+
+It remains to show that adding the edges simultaneously does not
+produce a cycle. Consider the first iteration of the algorithm where $T$ contains some cycle~$C$. Without
+loss of generality we can assume that $C=T_1[u_1v_1]\,v_1u_2\,T_2[u_2v_2]\,v_2u_3\,T_3[u_3v_3]\, \ldots \,T_k[u_kv_k]\,v_ku_1$.
+Each component $T_i$ has chosen its lightest incident edge~$e_i$ as either the edge $v_iu_{i+1}$
+or $v_{i-1}u_i$ (indexing cyclically). Assume that $e_1=v_1u_2$ (otherwise we reverse the orientation
+of the cycle). Then $e_2=v_2u_3$ and $w(e_2)<w(e_1)$ and so on, giving $w(e_1)>w(e_2)>\ldots>w(e_k)>w(e_1)$,
+which is a contradiction. (Note that distinctness of edge weights was crucial here.)
 \qed
 
+\section{Contractive algorithms}
+
+While the classical algorithms are based on growing suitable trees, they
+can be also reformulated in terms of edge contraction. Instead of keeping
+a forest of trees, we can keep each tree contracted to a single vertex.
+This replaces the relatively complex tree-edge incidencies by simple
+vertex-edge incidencies, potentially speeding up the calculation at the
+expense of having to perform the contractions.
+
+We will show a contractive version of the Bor\accent23uvka's algorithm
+in which these costs are carefully balanced, leading for example to
+a linear-time algorithm for MST in planar graphs.
+
+There are two definitions of edge contraction which differ when an edge of a
+triangle is contracted. Either we unify the other two edges to a single edge
+or we keep them as two parallel edges, leaving us with a multigraph. We will
+use the multigraph version and show that we can easily reduce the multigraph
+to a simple graph later. (See \thmref{contract} for the exact definitions.)
+
+We only need to be able to map edges of the contracted graph to the original
+edges, so each edge will carry a unique label $l(e)$ which will be preserved by
+contractions.
+
+\lemman{Flattening a multigraph}%
+Let $G$ be a multigraph and $G'$ its subgraph such that all loops have been
+removed and each bundle of parallel edges replaced by its lightest edge.
+Then $G'$~has the same MST as~$G$.
+
+\proof
+Loops can be never used in a spanning tree. If there is a spanning tree~$T$
+containing a removed edge~$e$ parallel to an edge~$e'\in G'$, exchaning $e'$
+for~$e$ in~$T$ makes it lighter. \qed
+
+\rem Removal of the heavier of a pair of parallel edges can be also viewed
+as an application of the Red rule on a 2-edge cycle. And indeed it is, the
+Red-Blue procedure works on multigraphs and all the classical algorithms also
+do. We only have to be more careful in the formulations and proofs, which we
+preferred to avoid. We also note that most of the algorithms can be run on
+disconnected graphs with little or no modifications.
+
 \algn{Contracting version of Bor\accent23uvka's algorithm}
+\algo
+\algin A~graph~$G$ with an edge comparison oracle.
+\:$T\=\emptyset$.
+\:$l(e)\=e$ for all edges~$e$. \cmt{Initialize the labels.}
+\:While $n(G)>1$:
+\::For each vertex $v_i$ of~$G$, let $e_i$ be the lightest edge incident to~$v_i$.
+\::$T\=T\cup \{ l(e_i) \}$. \cmt{Remember labels of all selected edges.}
+\::Contract $G$ along all edges $e_i$, inheriting labels and weights.
+\::Flatten $G$, removing parallel edges and loops.
+\algout Minimum spanning tree~$T$.
+\endalgo
 
 % G has to be connected
 % mention Steiner trees
index dd76722d50e0d1b2392929d59393d8f583e7e2c2..09994e8e58e1a514dc022c4e242f572b0c8ff83f 100644 (file)
 \n{$V,E,n,m$}{when used without $(G)$, they refer to the input of the current algorithm}
 \n{MST}{minimal spanning tree \[mstdef]}
 \n{MSF}{minimal spanning forest \[mstdef]}
+\n{$X \choose k$}{a set of $k$-element subsets of a set~$X$}
+\n{$G/e$}{multigraph contraction \[contract]}
+\n{$G.e$}{simple graph contraction \[simpcont]}
 }
 
+\section{Multigraphs and contractions}
+
+Since the formalism of multigraphs is not fixed in the literature, we will
+better define it carefully, following \cite{diestel:gt}:
+
+\defn A~\df{multigraph} is an ordered triple $(V,E,M)$, where $V$~is the
+set of vertices, $E$~is the set of edges, taken as abstract objects disjoint
+with the vertices, and $M$ is a mapping $E\mapsto V \cup {V \choose 2}$
+which assigns to each edge either a pair of vertices or a single vertex
+(if the edge is a loop).
+
+\proclaim{Notation}%
+When the meaning is clear from the context, we use our notation originally
+defined for graphs even for multigraphs. For example, $xy\in E(G)$ becomes a
+shorthand for $\exists e\in E(G)$ such that $M(G)(e) = \{x,y\}$. Also, we
+consider multigraphs with no multiple edges nor loops and simple graphs to be
+the same objects, although they formally differ.
+
+\defn\thmid{contract}%
+Let $G=(V,E,M)$ be a multigraph and $e=xy$ its edge. \df{(Multigraph) contraction of~$G$ along~$e$}
+produces a multigraph $G/e=(V',E',M')$ such that:
+$$\eqalign{
+V' &= (V(G) \setminus \{x,y\}) \cup \{v_e\},\quad\hbox{where $v_e$ is a new vertex,}\cr
+E' &= E(G) - \{e\},\cr
+M'(f) &= \{ m(v) ; v\in M(f) \} \quad\hbox{for every $f=\in E'$, and}\cr
+m(x) &= \cases{v_e & \hbox{for $v=x,y,$}\cr v & \hbox{otherwise.}} \cr
+}$$
+
+Sometimes we need contraction for simple graphs as well. It corresponds to performing
+the multigraph contraction, unifying parallel edges and deleting loops.
+
+\defn\thmid{simpcont}%
+Let $G=(V,E)$ a simple graph and $e=xy$ its edge. \df{(Simple graph) contraction of~$G$ along~$e$}
+produces a graph $G.e=(V',E')$ such that:
+$$\eqalign{
+V' &= (V(G) \setminus \{x,y\}) \cup \{v_e\},\quad\hbox{where $v_e$ is a new vertex,}\cr
+E' &= \{ \{m(x),m(y)\} ; xy\in E \land m(x)\ne m(y) \},\cr
+m(x) &= \cases{v_e & \hbox{for $v=x,y,$}\cr v & \hbox{otherwise.}} \cr
+}$$
+
 \endpart