mirror of
https://github.com/janishutz/eth-summaries.git
synced 2025-11-25 10:34:23 +00:00
[AW] Update summary to new version of helpers
This commit is contained in:
@@ -27,7 +27,7 @@ The following algorithm correctly computes \textit{\textbf{a}} valid colouring.
|
||||
\begin{align*}
|
||||
\mathscr{X}(G) \leq C(G) \leq \Delta(G) + 1
|
||||
\end{align*}
|
||||
where $\Delta(G) := \max_{v\in V}\deg(v)$ is the maximum degree of a vertex in $G$. If the graph is stored as an adjacency list, the algorithm finds a colouring \tco{|E|}
|
||||
where $\Delta(G) := \max_{v\in V}\deg(v)$ is the maximum degree of a vertex in $G$. If the graph is stored as an adjacency list, the algorithm finds a colouring $\tco{|E|}$
|
||||
\end{theorem}
|
||||
|
||||
\begin{algorithm}
|
||||
@@ -46,12 +46,12 @@ The following algorithm correctly computes \textit{\textbf{a}} valid colouring.
|
||||
\begin{align*}
|
||||
\mathscr{X}(G) \leq \Delta(G)
|
||||
\end{align*}
|
||||
and there is an algorithm that colours the graph using $\Delta(G)$ colours in \tco{|E|}. Otherwise $\mathscr{X}(G) \leq \Delta(G) + 1$
|
||||
and there is an algorithm that colours the graph using $\Delta(G)$ colours in $\tco{|E|}$. Otherwise $\mathscr{X}(G) \leq \Delta(G) + 1$
|
||||
\end{theorem}
|
||||
Of note is that a graph with an even number of vertices and edges does not contain an uneven cycle, so for an incomplete graph with an even number of edges and vertices, we always have that $\mathscr{X}(G) \leq \Delta(G)$
|
||||
|
||||
\begin{theorem}[]{Maximum degree}
|
||||
Let $G$ be a graph and $k \in \N$ the number representing the maximum degree of any vertex of any induced subgraph of $G$. Then we have $\mathscr{X}(G) \leq k + 1$ and a $(k + 1)$-coloring can be found in \tco{|E|}
|
||||
Let $G$ be a graph and $k \in \N$ the number representing the maximum degree of any vertex of any induced subgraph of $G$. Then we have $\mathscr{X}(G) \leq k + 1$ and a $(k + 1)$-coloring can be found in $\tco{|E|}$
|
||||
\end{theorem}
|
||||
|
||||
\begin{theorem}[]{Mycielski-Construction}
|
||||
@@ -63,6 +63,6 @@ To conclude this section, one last problem:
|
||||
|
||||
We are given a graph $G$ which we are told has $\mathscr{X}(G) = 3$. This means, we know that there is exists an order of processing for the \textsc{Greedy-Colouring} algorithm that only uses three colours. We don't know the colours, but we can find an upper bound for the number of colours needed
|
||||
\begin{theorem}[]{$3$-colourable graphs}
|
||||
Every $3$-colourable graph $G$ can be coloured in time \tco{|E|} using at most \tco{\sqrt{|V|}} colours
|
||||
Every $3$-colourable graph $G$ can be coloured in time $\tco{|E|}$ using at most $\tco{\sqrt{|V|}}$ colours
|
||||
\end{theorem}
|
||||
Since the graph has to be bipartite (because for each vertex $v$, its neighbours can only be coloured in $2$ other colours, because the graph can be $3$-coloured), we can use BFS and thus have linear time. The algorithm works as follows: We choose the vertices with the largest degree and apply three colours to them. For the ones of smaller degree, we apply Brook's theorem.
|
||||
|
||||
@@ -74,7 +74,7 @@ $v$ is an articulation point $\Leftrightarrow$ ($v = s$ and $s$ has degree at le
|
||||
|
||||
\stepcounter{all}
|
||||
\begin{theorem}[]{Articulation points Computation}
|
||||
For a connected graph $G = (V, E)$ that is stored using an adjacency list, we can compute all articulation points in \tco{|E|}
|
||||
For a connected graph $G = (V, E)$ that is stored using an adjacency list, we can compute all articulation points in $\tco{|E|}$
|
||||
\end{theorem}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ The idea now is that every vertex contained in a bridge is either an articulatio
|
||||
\end{center}
|
||||
|
||||
\begin{theorem}[]{Bridges Computation}
|
||||
For a connected graph $G = (V, E)$ that is stored using an adjacency list, we can compute all bridges and articulation points in \tco{|E|}
|
||||
For a connected graph $G = (V, E)$ that is stored using an adjacency list, we can compute all bridges and articulation points in $\tco{|E|}$
|
||||
\end{theorem}
|
||||
|
||||
\subsubsection{Block-Decomposition}
|
||||
|
||||
@@ -41,7 +41,7 @@ If we combine the entirety of the explanations of pages 43-45 in the script, we
|
||||
\begin{theorem}[]{Eulerian Graph}
|
||||
\begin{enumerate}[label=\alph*)]
|
||||
\item A connected graph $G$ is eulerian if and only if the degree of all vertices is even
|
||||
\item In a connected eulerian graph, we can find a eulerian cycle in \tco{|E|}
|
||||
\item In a connected eulerian graph, we can find a eulerian cycle in $\tco{|E|}$
|
||||
\end{enumerate}
|
||||
\end{theorem}
|
||||
|
||||
@@ -58,7 +58,7 @@ The issue with Hamiltonian cycles is that the problem is $\mathcal{N}\mathcal{P}
|
||||
|
||||
\stepcounter{all}
|
||||
\begin{theorem}[]{Hamiltonian Cycle Algorithm}
|
||||
The algorithm \textsc{HamiltonianCycle} is correct and has space complexity \tco{n \cdot 2^n} and time complexity \tco{n^2 \cdot 2^n}, where $n = |V|$
|
||||
The algorithm \textsc{HamiltonianCycle} is correct and has space complexity $\tco{n \cdot 2^n}$ and time complexity $\tco{n^2 \cdot 2^n}$, where $n = |V|$
|
||||
\end{theorem}
|
||||
|
||||
In the below algorithm, $G = (V, E)$ is a graph for which $V = [n]$ and $N(v)$ as usual the neighbours of $v$ and we define $S$ as a subset of the vertices of $G$ with $1 \in S$.
|
||||
@@ -137,10 +137,10 @@ We thus reach the following algorithm:
|
||||
\end{algorithm}
|
||||
|
||||
\begin{theorem}[]{Count Hamiltionian Cycles Algorithm}
|
||||
The algorithm computes the number of Hamiltonian cycles in $G$ with space complexity \tco{n^2} and time complexity \tco{n^{2.81}\log(n) \cdot 2^n}, where $n = |V|$
|
||||
The algorithm computes the number of Hamiltonian cycles in $G$ with space complexity $\tco{n^2}$ and time complexity $\tco{n^{2.81}\log(n) \cdot 2^n}$, where $n = |V|$
|
||||
\end{theorem}
|
||||
The time complexity bound comes from the fact that we need \tco{\log(n)} matrix multiplications to compute $|W_S|$, which can be found in entry $(s, s)$ in $(A_S)^n$, where $A_S$ is the adjacency matrix of the induced subgraph $G[V\backslash S]$.
|
||||
Each matrix multiplication can be done in \tco{n^{2.81}} using Strassen's Algorithm.
|
||||
The time complexity bound comes from the fact that we need $\tco{\log(n)}$ matrix multiplications to compute $|W_S|$, which can be found in entry $(s, s)$ in $(A_S)^n$, where $A_S$ is the adjacency matrix of the induced subgraph $G[V\backslash S]$.
|
||||
Each matrix multiplication can be done in $\tco{n^{2.81}}$ using Strassen's Algorithm.
|
||||
The $2^n$ is given by the fact that we have that many subsets to consider.
|
||||
|
||||
|
||||
@@ -187,14 +187,14 @@ In words, we are looking for the hamiltonian cycle with the shortest length amon
|
||||
|
||||
\stepcounter{all}
|
||||
\begin{theorem}[]{Travelling Salesman Problem}
|
||||
If there exists for $\alpha > 1$ a $\alpha$-approximation algorithm for the travelling salesman problem with time complexity \tco{f(n)}, there also exists an algorithm that can decide if a graph with $n$ vertices is Hamiltonian in \tco{f(n)}.
|
||||
If there exists for $\alpha > 1$ a $\alpha$-approximation algorithm for the travelling salesman problem with time complexity $\tco{f(n)}$, there also exists an algorithm that can decide if a graph with $n$ vertices is Hamiltonian in $\tco{f(n)}$.
|
||||
\end{theorem}
|
||||
This obviously means that this problem is also $\mathcal{N}\mathcal{P}$-complete.
|
||||
If we however use the triangle-inequality $l(\{x, z\}) \leq l(\{x, y\}) + l(\{y, z\}))$, which in essence says that a direct connection between two vertices has to always be shorter or equally long compared to a direct connection (which intuitively makes sense),
|
||||
we reach the metric travelling salesman problem, where, given a graph $K_n$ and a function $l$ (as above, but this time respecting the triangle-inequality), we are again looking for the same answer as for the non-metric problem.
|
||||
|
||||
\begin{theorem}[]{Metric Travelling Salesman Problem}
|
||||
There exists a $2$-approximation algorithm with time complexity \tco{n^2} for the metric travelling salesman problem.
|
||||
There exists a $2$-approximation algorithm with time complexity $\tco{n^2}$ for the metric travelling salesman problem.
|
||||
\end{theorem}
|
||||
|
||||
\shortproof This algorithm works as follows: Assume we have an MST and we walk around the outside of it.
|
||||
@@ -202,4 +202,5 @@ Thus, the length of our path is $2$ \verb|mst|($K_n, l$).
|
||||
If we now use the triangle inequality, we can skip a few already visited vertices and at least not lengthen our journey around the outside of the MST.
|
||||
Any Hamiltonian cycle can be transformed into an MST by removing an arbitrary edge from it.
|
||||
Thus, for the optimal length (minimal length) of a Hamiltonian cycle, we have $\text{opt}(K_n, l) \geq \verb|mst|(K_n, l)$.
|
||||
If we now double the edge set (by duplicating each edge), then, since for $l(C) = \sum_{e \in C} l(e)$ for our Hamiltonian cycle $C$, we have $l(C) \leq 2 \text{opt}(K_n, l)$, we can simply find a eulerian cycle in the graph in \tco{n}, and since it takes \tco{n^2} to compute an MST, our time complexity is \tco{n^2}
|
||||
If we now double the edge set (by duplicating each edge), then, since for $l(C) = \sum_{e \in C} l(e)$ for our Hamiltonian cycle $C$, we have $l(C) \leq 2 \text{opt}(K_n, l)$, we can simply find a eulerian cycle in the graph in $\tco{n}$, and since it takes $\tco{n^2}$ to compute an MST, our time complexity is $\tco{n^2}$
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ That system will have to fulfill the performance requirements of the task, but p
|
||||
\end{algorithm}
|
||||
The above algorithm doesn't return the maximum matching, just a matching
|
||||
\begin{theorem}[]{Greedy-Matching}
|
||||
The \textsc{Greedy-Matching} determines a maximal matching $M_{Greedy}$ in \tco{|E|} for which we have
|
||||
The \textsc{Greedy-Matching} determines a maximal matching $M_{Greedy}$ in $\tco{|E|}$ for which we have
|
||||
\begin{align*}
|
||||
|M_{Greedy}| \geq \frac{1}{2} |M_{\max}|
|
||||
\end{align*}
|
||||
@@ -48,7 +48,7 @@ The above algorithm doesn't return the maximum matching, just a matching
|
||||
\end{theorem}
|
||||
\inlineproof If $M$ is not a maximum matching, there exists a matching $M'$ with higher cardinality, where $M \oplus M'$ ($M$ xor $M'$) has a connected component that contains more edges of $M'$ than $M$. Said connected component is the augmenting path for $M$
|
||||
|
||||
This idea leads to an algorithm to determine a maximum matching: As long as a matching isn't a maximum matching, there exists an augmenting path that allows us to expand the matching. After \textit{at most} $\frac{|V|}{2} - 1$ steps, we have a maximum matching. For bipartite graphs, we can use modified BFS with time complexity \tco{(|V| + |E|) \cdot |E|} to determine the augmenting paths.
|
||||
This idea leads to an algorithm to determine a maximum matching: As long as a matching isn't a maximum matching, there exists an augmenting path that allows us to expand the matching. After \textit{at most} $\frac{|V|}{2} - 1$ steps, we have a maximum matching. For bipartite graphs, we can use modified BFS with time complexity $\tco{(|V| + |E|) \cdot |E|}$ to determine the augmenting paths.
|
||||
\begin{algorithm}
|
||||
\caption{\textsc{AugmentingPath}$(G = (A \uplus B, E), M)$}
|
||||
\begin{algorithmic}[1]
|
||||
@@ -100,11 +100,11 @@ The algorithm discussed above uses layers $L_i$ to find the augmenting paths. Ea
|
||||
\end{algorithm}
|
||||
To find the shortest augmenting path, we observe that if the last layer has more than one non-covered vertex, we can potentially (actually, likely) find more than one augmenting path.
|
||||
We find one first, remove it from the data structure and find more augmenting paths by inverting the tree structure (i.e. cast \textit{flippendo} on the edges) and using DFS to find the all augmenting paths.
|
||||
We always delete each visited vertex and we thus have time complexity \tco{|V| + |E|}, since we only visit each vertex and edge once.
|
||||
We always delete each visited vertex and we thus have time complexity $\tco{|V| + |E|}$, since we only visit each vertex and edge once.
|
||||
|
||||
\begin{theorem}[]{Hopcroft and Karp Algorithm}
|
||||
The algorithm of Hopcroft and Karp's while loop is only executed \tco{\sqrt{|V|}} times.
|
||||
Hence, the maximum matching is computed in \tco{\sqrt{|V|} \cdot (|V| + |E|)}
|
||||
The algorithm of Hopcroft and Karp's while loop is only executed $\tco{\sqrt{|V|}}$ times.
|
||||
Hence, the maximum matching is computed in $\tco{\sqrt{|V|} \cdot (|V| + |E|)}$
|
||||
\end{theorem}
|
||||
|
||||
\newpage
|
||||
@@ -113,14 +113,14 @@ We always delete each visited vertex and we thus have time complexity \tco{|V| +
|
||||
In Section 4, using flows to compute matchings is discussed.
|
||||
|
||||
\begin{theorem}[]{Weighted Matching problem}
|
||||
Let $n$ be even and $l: {[n] \choose 2} \rightarrow \N_0$ be a weight function of a complete graph $K_n$. Then, we can compute, in time \tco{n^3}, a minimum perfect matching with
|
||||
Let $n$ be even and $l: {[n] \choose 2} \rightarrow \N_0$ be a weight function of a complete graph $K_n$. Then, we can compute, in time $\tco{n^3}$, a minimum perfect matching with
|
||||
\begin{align*}
|
||||
\sum_{e \in M} l(e) = \min\left\{ \sum_{e \in M'} l(e) \smallhspace \Big| \smallhspace M' \text{ is a perfect matching in } K_n \right\}
|
||||
\end{align*}
|
||||
\end{theorem}
|
||||
|
||||
\begin{theorem}[]{MTSP with approximation}
|
||||
There is a $\frac{3}{2}$-approximation algorithm with time complexity \tco{n^3} for the metric travelling salesman problem
|
||||
There is a $\frac{3}{2}$-approximation algorithm with time complexity $\tco{n^3}$ for the metric travelling salesman problem
|
||||
\end{theorem}
|
||||
|
||||
\subsubsection{Hall's Theorem}
|
||||
@@ -137,7 +137,7 @@ The following theorem follows from Hall's Theorem immediately. We remember that
|
||||
\end{theorem}
|
||||
|
||||
\begin{theorem}[]{Algorithm for the problem}
|
||||
If $G$ is a $2^k$-regular bipartite graph, we can find a perfect matching in time \tco{|E|}
|
||||
If $G$ is a $2^k$-regular bipartite graph, we can find a perfect matching in time $\tco{|E|}$
|
||||
\end{theorem}
|
||||
It is important to note that the algorithms to determine a perfect matching in bipartite graph do not work for non-bipartite graphs, due to the fact that when we remove every other edge from the eulerian cycle, it is conceivable that the graph becomes disconnected. While this is no issue for bipartite graphs (as we can simply execute the graph on all connected components), for $k = 1$, such a connected component can could contain an odd number of vertices, thus there would be a eulerian cycle of odd length from which not every other edge can be deleted. Since that component has odd length, no perfect matching can exist.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user