From: Martin Mares Date: Fri, 18 Jan 2008 13:39:34 +0000 (+0100) Subject: Contractions rulez. X-Git-Tag: printed~293 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=56caa99a2f2a516120444fec616279e81fb7464e;p=saga.git Contractions rulez. --- diff --git a/macros.tex b/macros.tex index d75944d..f763394 100644 --- a/macros.tex +++ b/macros.tex @@ -240,6 +240,7 @@ \parskip=1pt plus 1pt minus 0.3pt \rightskip=2em \itemcount=0 +\smallskip } \def\endalgo{\interlistskip\endgroup} \def\algopar{\par @@ -249,7 +250,6 @@ \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 f5d935c..357e3b2 100644 --- 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_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 diff --git a/notation.tex b/notation.tex index dd76722..09994e8 100644 --- a/notation.tex +++ b/notation.tex @@ -20,6 +20,49 @@ \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