https://brandstifter.github.io/
Recent content on Hugo -- gohugo.ioenThu, 20 Dec 2018 00:00:00 +0000The beauty of Voronio
https://brandstifter.github.io/posts/the-beauty-of-voronoi/
Thu, 20 Dec 2018 00:00:00 +0000https://brandstifter.github.io/posts/the-beauty-of-voronoi/
<h1 id="the-beauty-of-voronoi">The beauty of Voronoi</h1>
<h2 id="motivation">Motivation</h2>
<p>Voronoi diagrams are found in nature on the skin of giraffes, veins of leaves und dragonfly wings.
In biology, Voronois are used to model biological structures, in ecology, they are used to study growth patterns of forrests and in case of incoming emergency calls, Voronoi diagrams can alert the nearest fire station, also known as nearest neighbour queries.
There are many applications in natural sciences, health, engineering, geometry and computer science.</p>
<p>This article wants to illuminate two properties forming a Voronoi cell, namely how an edge and a vertex of a Voronoi are described.</p>
<h2 id="introduction">Introduction</h2>
<p>First, we need a terminology to speak about Voronoi diagrams.
Image a plane and a point set $P$ with distinct points which are called sites.
A Voronoi maps each point on the plane $p_{x,y}$ to its nearest site by subdividing the plane into $n$ cells, denoted by $\mathcal{V}(p_i)$.
Since we talk about a structure in $\mathbb{R}^2$, we take the Euclidean distance between to points $p$ and $q$.
$$
\begin{align}
d(p, q) := \sqrt{ (p_x - q_x)^2 + (p_y - q_y)^2 }
\end{align}
$$</p>
<p>In other words $q$ corresponds to the site $p_i$ if and only if $d(q, p_i) < d(q, p_j)$ for each $p_j \in P$ with $i \neq j$.</p>
<p>Next we define the bisector between two sides $p$ and $q$ as the perpendicular bisector of the line segment $\overline{pq}$.
This bisector splits the the plane into two half-planes.
The half-plane containing $p$ is denoted by $h(p,q)$ and the half-plane containing $q$ by $h(q,p)$.
Combining several half-planes surrounding a site $p_i$ we have the observation that
$$
\begin{align}
\mathcal{V}(p_i) = \bigcup h(p_i, p_j), i \neq j
\end{align}
$$</p>
<p>Following picture illustrates this
<img src="img/site-half-planes.png" alt="" /></p>
<p>When you do this with all sites in the plane you create a Voronoi diagram illustrated here
<img src="img/voronoi-simple.png" alt="" /></p>
<p>All these Voronoi cells forms a Voronoi diagram, denoted by $Vor(P)$.</p>
<h2 id="voronoi-vertices">Voronoi vertices</h2>
<p>The question this section tries to answer is, under which conditions a Voronoi diagram has a Voronie vertice where Voronoi edges meet other Voronoi edges. The answer is simnple.</p>
<p>For the Voronoi diagram $Vor(P)$ of a set of points $P$ it holds, that a point $q$ is a vertrx of $Vor(P)$ if and only if its largest empty circle $C_P(q)$ contains three or more sites on its boundary.</p>
<p>Speaking in pictures one would express it as follows
<img src="img/voronoi-vertice.png" alt="" /></p>
<p>Look at the picture above.
The white vertex $q$ has three points on its boundary.
Imagine an empty circle at every vertex, you will see that no less than three sites forms a vertex.</p>
<p>Lets proof this.</p>
<p>Suppose there is a point $q$ such that $C_P(q)$ contains three or more sites on its boundary.
Let $p_i, p_j, p_k$ be three of those sites.
Since the interior of $C_P(q)$ is empty $q$ must be on the boundary of each of $\mathcal{V}(p_i), \mathcal{V}(p_j), \mathcal{V}(p_k)$, and $q$ must be a vertex of $Vor(P)$.
Every vertex $q$ of $Vor(P)$ is incident to at least three edges and, hence, to at least three cells $\mathcal{V}(p_i), \mathcal{V}(p_j), \mathcal{V}(p_k)$.
Every vertex $q$ must be equidistant to $p_i, p_j, p_k$ and there cannot be another site closer to $q$, since otherwise $\mathcal{V}(p_i), \mathcal{V}(p_j), \mathcal{V}(p_k)$ would not meet at $q$.
Hence, the interior of the circle with $p_i, p_j, p_k$ on its boundary does not contain any site.</p>
<h2 id="voronoi-edges">Voronoi edges</h2>
<p>Now suppose we move the white point $q$ along an edge in $Vor(P)$ and the circle $C_P(q)$ has two sites on its boundary and these sites are equidistant to $q$.
We can do this as long as no other sites appear on the boundary of $C_P(q)$, since this would mean another vertex of $Vor(P)$.
This forms an edge, as simple as that.</p>
<p>Once again, speaking in pictures one would express it as follows
<img src="img/voronoi-edge.png" alt="" /></p>
<p>In a more formal way we state that the bisector between sites $p_i$ and $p_j$ defines an edge of $Vor(P)$ if and only if there is a point $q$ on the bisector such that $C_P(q)$ contains both $p_i$ and $p_j$ on its boundary but no other site.</p>
<p>Lets proof this.</p>
<p>Suppose there is a pont $q$ with the property.
Since $C_P(q)$ does not contain ay sites in its interior and $p_i, p_j$ are on its boundary, we have $d(q, p_i) = d(q, p_j) \leq d(q, p_k)$ for all $1 \leq k \leq n$.
It follows that $q$ lies on an edge or vertex of $Vor(P)$.
$q$ cannot be a vertex of $Vor(P)$, hence $q$ lies on an edge of $Vor(P)$, which is defined by the bisector of $p_i, p_j$.
Conversevly, let the bisector of $p_i, p_j$ define a Voronoi edge.
The largest empty circle of any point $q$ in the interior of this edge must contain $p_i, p_j$ on its boundary and no other sites.</p>
<h2 id="summary">Summary</h2>
<p>Now we can move a circle in mind within an Voronoi diagram in order to recreate the vertices and edges by moving a it along the bisectors of a point set.
This is beautiful and I amazed to recognize this pattern in nature.
<img src="img/dragonfly-wing.jpg" alt="" /></p>
<p>Special thanks to Martin Nöllenburg (University of Technology Vienna) for teaching this.</p>
Metric Steiner Tree
https://brandstifter.github.io/posts/metric-steiner-tree/
Sat, 08 Dec 2018 00:00:00 +0000https://brandstifter.github.io/posts/metric-steiner-tree/
<h1 id="the-metric-steiner-tree">The Metric Steiner Tree</h1>
<h2 id="motivation">Motivation</h2>
<p>A Steiner Tree is an optimization algorithm for finding a subtree spanning so called terminal vertices.
Terminal vertices are the nodes in a network which must spanned by the MST.
This problems arise in railway networks, telecommunication networks and VSLI chip design.</p>
<p>This article describes an 2-approximation algorithm for the Metric Steiner Tree Problem.
Note that 2-approximation guarantees a solution $2 \cdot OPT$ on worst case situations.
If you look for the best approximation, the best known algorithm is a $ <sup>96</sup>⁄<sub>95</sub> $-approximation.</p>
<h2 id="introduction">Introduction</h2>
<p>The Steiner Tree Problem (STP) is a graph $G = (V,E)$.
$V$ is splitted into two sets $R$ of required terminal vertices and $S$ of optional Steiner vertices.
A subgraph of $G$ is a feasible solution if it spans all vertices of $R$.
The objective is to minimize the cost.</p>
<p>The Metric Steiner Tree Problem (MSTP) is a specialization of the vanilla Steiner Tree $X = R \cup S$ along with a non-negative distance function $d : X \times X \mapsto \mathbb{R}_{\geq 0}$ for edges.
A metric have two properties:
$$
\begin{align}
\forall x,y \in X &: d(x,y) = d(y,x) \nonumber \newline
\forall x,y,z \in X &: d(x,y) \leq d(x,z) + d(z,y) \nonumber
\end{align}
$$</p>
<p>This gives an undirected graph $G = (V,E)$ with non-negative edge costs.</p>
<p>Problem: Find a minimal cost tree $T$, which contains all terminal vertives, and possibly some of the optional points, such that the cost $C$ with metric $d$
$$
\begin{align}
C_d (T) := \sum_{(u,v) \in E} d(u, v) \nonumber
\end{align}
$$
of the tree is minimized.</p>
<h3 id="non-optimal-spanning-trees">Non-optimal spanning trees</h3>
<p>Let $G$ be a $K_4$ graph.
<img src="img/k4-mst.pdf" alt="" /></p>
<p>Find a Minimal Spanning Tree (MST) with Kruskal on the terminal vertices.
The algorithm come up with this solution:
<img src="img/k4-mst-kruskal.pdf" alt="" /></p>
<p>But this is not optimal!
The STP would generate a better MST for that example, since ST can also consider the optional Steiner vertices for calculation.
Next we look for a simple and easy to implement approximation for the STP.</p>
<h2 id="towards-an-approximation">Towards an approximation</h2>
<p>In this section we show that the approximation bound for MSTP is not greater than for STP.</p>
<p>Define $G’ = (V, E’$) from $G$ as follows: $G’$ is a complete graph and $e’_{ij}$ is the length of the shortets path in $G$ for vertices $i$ to $j$.</p>
<p>The Steiner Tree algorithm would came up with this graph $G’$
<img src="img/k4-mst-Gprime.pdf" alt="" /></p>
<p>The paths in $G’$ cannot be longer than $G$, therefore
$$
\begin{align}
OPT(G’) \leq OPT(G)
\end{align}
$$</p>
<p>Note that the graph is still connected.</p>
<p>Now we assume to have a heuristic $H$ for $G’$.
We get a solution for $G$ by replacing each edge of the MST in $G$ with its corresponding shortest path in $G’$.
Resolve cycles by removing appropriate edges.
$$
\begin{align}
C^H(G) \leq C^H(G’)
\end{align}
$$
and therefore by (1) and (2)
$$
\begin{align}
\frac{C^H(G’)}{OPT(G’)} \leq \alpha \implies \frac{C^H(G)}{OPT(G)} \leq \alpha
\end{align}
$$</p>
<p>Thus, each approximation algorithm for the general STP with bound $\alpha$ gives an algorithm with bound $\alpha$ for the specific MSTP.
Why the bound is 2 is illustrated in the next section.</p>
<h2 id="an-approximation-algorithm">An approximation algorithm</h2>
<p>Consider a Steiner Tree with optimal cost $OPT$ for $G’$.</p>
<p>Find a MST on the termial vertices.</p>
<p><img src="img/mst.pdf" alt="" /></p>
<p>To ensure an even degree of all vertices, we double each edge.
A graph with even degree have an eulerian cycle.
The cost of the eulerian cycle equals $2 \cdot OPT$ by edge double.</p>
<p><img src="img/double-the-edges.pdf" alt="" /></p>
<p>Construct a hamiltonian cycle by short cutting steiner vertices previously visited.
<img src="img/mst-st.pdf" alt="" />
If the question was how to extend a railway network in a cheap manner for peripheral stations, this is an answer.</p>
<p>To get a hamiltonian path remove one edge of the cycle.
We have found an MST on the terminal vertices.
A hamiltonian path does not increase the cost, because of the triangle inequality and removing edges.
The resulting MST on the terminal vertices cost $\leq 2 \cdot OPT$ and the bound is tight.</p>
<p>Looking back on $K_4$ we have to calculate the solution from $G’$ back to the original $G$ instance by reapplying the shortest path edges for $G’$ to the edges in $G$.<br />
<img src="img/k4-mst-2-approx.pdf" alt="" /></p>
<p>By including the optional Steiner vertice we have found a better MST compared to the Kruskal algorithm.</p>
<p>Special thanks to Prof. Hans Kellerer (University of Graz) for teaching.</p>