]> mj.ucw.cz Git - saga.git/commitdiff
Semidynamic MSF.
authorMartin Mares <mj@ucw.cz>
Wed, 9 Apr 2008 08:15:34 +0000 (10:15 +0200)
committerMartin Mares <mj@ucw.cz>
Wed, 9 Apr 2008 08:15:34 +0000 (10:15 +0200)
PLAN
dyn.tex
opt.tex

diff --git a/PLAN b/PLAN
index 837118b001433919777b048d1c8f07f9eed2deda..050f0ea2b036a330c2a7015b3107b11de97530a6 100644 (file)
--- a/PLAN
+++ b/PLAN
@@ -32,7 +32,6 @@
 *  Dynamic MST algorithms
 
   .  (Semi-)dynamic algorithms
-  .  Sleator-Tarjan trees and semi-dynamic MST
   .  ET-trees
   .  Fully dynamic connectivity
   .  Dynamic MST
@@ -73,10 +72,14 @@ Models:
 - mention in-place radix-sorting?
 - consequences of Q-Heaps: Thorup's undirected SSSP etc.
 - add more context from thorup:aczero, also mention FP operations
-- Tarjan79 is claimed by Pettie to define Pointer machines
+- Tarjan79 is mentioned by Pettie to define Pointer machines
 - add references to the C language
 - PM: unify yardsticks
 
+Dynamic:
+
+- What is the origin of the semidynamic MSF?
+
 Ranking:
 
 - the general perspective: is it only a technical trick?
diff --git a/dyn.tex b/dyn.tex
index ea51c44f2922ad7f483462c273ccbc580f62e47f..502f618eedbed8667013e091250787056db9ebb2 100644 (file)
--- a/dyn.tex
+++ b/dyn.tex
@@ -19,14 +19,14 @@ connected components:
 \problemn{Dynamic connectivity}
 Maintain an~undirected graph under a~sequence of the following operations:
 \itemize\ibull
-\:$\<Init>(n)$ --- create a~graph with $n$~isolated vertices $\{1,\ldots,n\}$,\foot{%
+\:$\<Init>(n)$ --- Create a~graph with $n$~isolated vertices $\{1,\ldots,n\}$.\foot{%
 The structure could support dynamic addition and removal of vertices, too,
 but this is easy to add and infrequently used, so we will rather define
 the structure with a~fixed set of vertices for clarity.}
-\:$\<Insert>(G,u,v)$ --- insert an~edge $uv$ to~$G$ and return its unique
-identifier (assuming that the edge did not exist yet),
-\:$\<Delete>(G,e)$ --- delete an~edge specified by its identifier from~$G$,
-\:$\<Connected>(G,u,v)$ --- test if $u$ and~$v$ are in the same connected component of~$G$.
+\:$\<Insert>(G,u,v)$ --- Insert an~edge $uv$ to~$G$ and return its unique
+identifier (assuming that the edge did not exist yet).
+\:$\<Delete>(G,e)$ --- Delete an~edge specified by its identifier from~$G$.
+\:$\<Connected>(G,u,v)$ --- Test if $u$ and~$v$ are in the same connected component of~$G$.
 \endlist
 
 \para
@@ -47,8 +47,8 @@ The edges that have triggered the \<Union>s form a~spanning forest of the curren
 So far, all known algorithms for dynamic connectivity maintain some sort of a~spanning
 tree. This suggests that a~dynamic MST algorithm could be obtained by modifying the
 dynamic connectivity algorithms. This will indeed turn out to be true. Semidynamic MST
-is easy to achieve before the end of this section, but making it fully dynamic will require
-more effort, so we will review some of the existing data structures in the meantime.
+is easy to achieve even in the few pages of this section, but making it fully dynamic will require
+more effort, so we will review some of the required building blocks before going into that.
 
 We however have to answer one important question first: What should be the output of
 our MSF data structure? Adding an~operation that would return the MSF of the current
@@ -78,28 +78,95 @@ the new components. If there is no such replacement edge, we have deleted a~brid
 so the MSF has to remain disconnected.
 
 The idea of reporting differences in the MSF indeed works very well. We can summarize
-what we have shown by the following lemma:
+what we have shown by the following lemma and use it to define the dynamic MSF.
 
 \lemma
 An~\<Insert> or \<Delete> of an~edge in~$G$ causes at most one edge addition, edge
 removal or edge exchange in $\msf(G)$.
 
+\problemn{Dynamic minimum spanning forest}
+Maintain an~undirected graph with weights on edges (drawn from a~totally ordered set)
+and its minimum spanning forest under a~sequence of the following operations:
+\itemize\ibull
+\:$\<Init>(n)$ --- Create a~graph with $n$~isolated vertices $\{1,\ldots,n\}$.
+\:$\<Insert>(G,u,v)$ --- Insert an~edge $uv$ to~$G$. Return its unique
+       identifier and the list of additions and deletions of edges in $\msf(G)$.
+\:$\<Delete>(G,e)$ --- Delete an~edge specified by its identifier from~$G$.
+       Return the list of additions and deletions of edges in $\msf(G)$.
+\endlist
+
 \paran{Semidynamic MSF}%
 To obtain a~semidynamic MSF algorithm, we need to keep the forest in a~data structure which
 supports search for the heaviest edge on the path connecting a~given pair
 of vertices. This can be handled efficiently by the Link-Cut trees of Sleator and Tarjan:
 
-\thmn{Link-Cut Trees, Sleator and Tarjan \cite{sleator:trees}}
+\thmn{Link-Cut Trees, Sleator and Tarjan \cite{sleator:trees}}\id{sletar}%
 There is a~data structure that represents a~forest of rooted trees on~$n$ vertices.
 Each edge of the forest has a~weight drawn from a~totally ordered set. The structure
-supports the following operations in time $\O(\log n)$ amortized:
+supports the following operations in time $\O(\log n)$ amortized:\foot{%
+The Link-Cut trees offer many other operations, but we do not mention them
+as they are not needed in our application.}
+\itemize\ibull
+\:$\<Parent>(v)$ --- Return the parent of~$v$ in its tree or \<null> if $v$~is a~root.
+\:$\<Root>(v)$ --- Return the root of the tree containing~$v$.
+\:$\<Weight>(v)$ --- Return the weight of the edge $(\<Parent(v)>,v)$.
+\:$\<PathMax>(v)$ --- Return the vertex~$w$ closest to $\<Root>(v)$ such that the edge
+       $(\<Parent>(w),w)$ is the heaviest of those on the path from~$v$ to the root.
+       If more edges have the maximum weight, break the tie arbitrarily.
+       If there is no such edge ($v$~is the root itself), return \<null>.
+\:$\<Link>(u,v,x)$ --- Connect the trees containing $u$ and~$v$ by an~edge $(u,v)$ of
+       weight~$x$. Assumes that $u~$is a tree root and $v$~lies in a~different tree.
+\:$\<Cut>(v)$ --- Split the tree containing the non-root vertex $v$ to two trees by
+       removing the edge $(v,\<Parent>(v))$. Returns the weight of this edge.
+\:$\<Evert>(v)$ --- Modify the orientations of the edges in the tree containing~$v$
+       to make~$v$ the tree's root.
+\endlist
 
-XXX
+%% \>Additionally, all edges on the path from~$v$ to $\<Root>(v)$ can be enumerated in
+%% time $\O(\ell + \log n)$, where $\ell$~is the length of that path. This operation
+%% (and also the path itself) is called $\<Path>(v)$.
+%% 
+%% \>If the weights are real numbers (or in general an~arbitrary group), the $\O(\log n)$
+%% operations also include:
+%% 
+%% \itemize\ibull
+%% \:$\<PathWeight>(v)$ --- Return the sum of the weights on $\<Path>(v)$.
+%% \:$\<PathUpdate>(v,x)$ --- Add~$x$ to the weights of all edges on $\<Path>(v)$.
+%% \endlist
 
 \proof
 See \cite{sleator:trees}.
 \qed
 
+Once we have this structure, we can turn our ideas on updating of the MSF to
+an~algorithm:
+
+\algn{\<Insert> in a~semidynamic MSF}
+\algo
+\algin A~graph~$G$ with its MSF $F$ represented as a~Link-Cut forest, an~edge~$uv$
+with weight~$w$ to be inserted.
+\:$\<Evert>(u)$. \cmt{$u$~is now the root of its tree.}
+\:If $\<Root>(v) \ne u$: \cmt{$u$~and~$v$ lie in different trees.}
+\::$\<Link>(u,v,w)$. \cmt{Connect the trees.}
+\::Return ``$uv$ added''.
+\:Otherwise:
+\::$y\=\<PathMax>(v)$.
+\::$x\=\<Parent>(x)$.  \cmt{Edge~$xy$ is the heaviest on $F[uv]$.}
+\::If $\<Weight>(x) > w$: \cmt{We have to exchange~$xy$ with~$uv$.}
+\:::$\<Cut>(x)$, $\<Evert>(v)$, $\<Link>(v,y,w)$.
+\:::Return ``$uv$~added, $xy$~removed''.
+\::Otherwise return ``no changes''.
+\algout The list of changes in~$F$.
+\endalgo
+
+\thmn{Semidynamic MSF}
+When only edge insertions are allowed, the MSF can be maintained in time $\O(\log n)$
+amortized per operation.
+
+\proof
+Every \<Insert> performs $\O(1)$ operations on the Link-Cut forest, which take
+$\O(\log n)$ each by Theorem \ref{sletar}.
+\qed
 
 
 %--------------------------------------------------------------------------------
diff --git a/opt.tex b/opt.tex
index 15b97d510b3796933ef1c5b137381fa208038cad..7d236c64556a8b9d8adb41e49325c345eb5c3a9b 100644 (file)
--- a/opt.tex
+++ b/opt.tex
@@ -27,13 +27,13 @@ corrupted.
 The soft heap contains a~set of distinct items from a~totally ordered universe and it
 supports the following operations:
 \itemize\ibull
-\:$\<Create>(\varepsilon)$ --- create an~empty soft heap with the given accuracy parameter~$\varepsilon$,
-\:$\<Insert>(H,x)$ --- insert a~new item~$x$ to the heap~$H$,
-\:$\<Meld>(P,Q)$ --- merge two heaps into one, more precisely move all items of a~heap~$Q$
-  to the heap~$P$, destroying~$Q$ in the process (both heaps must have the same~$\varepsilon$),
-\:$\<DeleteMin>(H)$ --- delete the minimum item of the heap~$H$ and return its value
+\:$\<Create>(\varepsilon)$ --- Create an~empty soft heap with the given accuracy parameter~$\varepsilon$.
+\:$\<Insert>(H,x)$ --- Insert a~new item~$x$ to the heap~$H$.
+\:$\<Meld>(P,Q)$ --- Merge two heaps into one, more precisely move all items of a~heap~$Q$
+  to the heap~$P$, destroying~$Q$ in the process (both heaps must have the same~$\varepsilon$).
+\:$\<DeleteMin>(H)$ --- Delete the minimum item of the heap~$H$ and return its value
   (optionally signalling that the value has been corrupted).
-\:$\<Explode>(H)$ --- destroy the heap and return a~list of all items contained in it
+\:$\<Explode>(H)$ --- Destroy the heap and return a~list of all items contained in it
   (again optionally marking those corrupted).
 \endlist