exercises/solutions/sol02.tex
author Eugen Sawin <sawine@me73.com>
Sun, 20 May 2012 23:03:17 +0200
changeset 12 7db450445696
parent 6 536889e989c3
permissions -rw-r--r--
Added final solution ex3.
     1 \documentclass[a4paper, 10pt, pagesize, smallheadings]{article}
     2 \usepackage{graphicx}
     3 %\usepackage[latin1]{inputenc}
     4 \usepackage{amsmath, amsthm, amssymb}
     5 \usepackage{typearea}
     6 \usepackage{algorithm}
     7 \usepackage{algorithmic}
     8 \usepackage{fullpage}
     9 \usepackage{mathtools}
    10 \usepackage[all]{xy}
    11 \addtolength{\voffset}{-40pt}
    12 \title{CSP Exercise 02 Solution}
    13 \author{Eugen Sawin}
    14 \renewcommand{\familydefault}{\sfdefault}
    15 \newcommand{\E}{\mathcal{E}}
    16 \newcommand{\R}{\mathcal{R}}
    17 
    18 %\include{pythonlisting}
    19 
    20 \pagestyle{empty}
    21 \begin{document}
    22 \maketitle
    23 
    24 \section*{Exercise 2.1}
    25 (a) The strongly connected components are the subgraphs induced by following sets of vertices.
    26 \begin{itemize}
    27   \item $V_1 = \{v_1,v_2,v_5,v_6\}$
    28   \item $V_2 = \{v_3,v_4\}$
    29 \end{itemize}
    30 (b) The cliques are the the complete subgraphs induced by the following sets of vertices.
    31 \begin{itemize}
    32   \item $V_1 = \{v_1,v_2,v_5\}$
    33   \item $V_{2-8} \in E$
    34   \item $V_{9-14} \in \{\{v_i\} \mid v_i \in V\}$
    35 \end{itemize}
    36 
    37 \section*{Exercise 2.2}
    38 We define the following undirected graph $G = \langle W, E \rangle$ with $\{w_i,w_j\} \in E$ iff $w_i$ and $w_j$ dislike each other. Additionally we define two sets $B_1 = B_2 = \{\}$ for the buildings and an auxiliary set $F = \{\}$ for remembering \emph{expanded} nodes.
    39 \begin{enumerate}
    40   \item For all $w_i \in W$ with $w_i \notin \bigcup E$ add $w_i$ to $B_1$ and $F$, i.e. $B_1 = B_1 \cup \{w_i\}$ and $F = F \cup \{w_i\}$. This way we assign all workers, who are liked by everyone to building $B_1$.
    41   \item If $F = W$ terminate, we have found a solution.\\
    42   Otherwise select any $w_i \notin F$ and add it to $B_1$ and $F$, i.e. $B_1 = B_1 \cup \{w_i\}$ and $F = F \cup \{w_i\}$.\\
    43   Add all its disliked neighbours to $B_2$, i.e. $B_2 = B_2 \cup \{w_j \mid \{w_i,w_j\} \in E\}$.\\
    44   If $B_1 \cap B_2 \neq \emptyset$ terminate, there was a conflict and therefore no possible solution.
    45   \item If there a $w_i \notin F$ with $w_i \in B_1 \cup B_2$ select it, otherwise continue with $2.$\\
    46   Add all its disliked neighbours to the other building, i.e. $w_i \in B_1 \implies B_2 = B_2 \cup \{w_j \mid (w_i,w_j) \in E\}$, $w_i \in B_2 \implies B_1 = B_1 \cup \{w_j \mid (w_i,w_j) \in E\}$ and $F = F \cup \{w_i\}$.\\
    47   If $B_1 \cap B_2 \neq \emptyset$ terminate, there was a conflict and therefore no possible solution.\\
    48   Otherwise continue with $3.$
    49 \end{enumerate}
    50 This is essentially a random walk through the graph with some book keeping. Assumming that set containment can be tested in $\mathcal{O}(1)$ and set intersection in $\mathcal{O}(n)$ we have an asymptotic complexity of $\mathcal{O}(|W| \cdot |E|)$ (this includes the optimisation, that the intersection test is only done once when $F = W$ holds).
    51 
    52 \section*{Exercise 2.3}
    53 (a) $VertexCover \in NP$ because by guessing the vertex set $V'$, we can iterate over all $\{v_1,v_2\} \in E$ and check if $v_1 \in V'$ or $v_2 \in V'$ holds in polynomial time.\\
    54 We show $Clique \le_P VertexCover$. Given an undirected graph $G = \langle V,E \rangle$ and $k \in N$ we build a graph $G_2 = \langle V_2, E_2 \rangle$ so that there is a clique $V' \subseteq V$ with $|V'| \geq k$ iff there is a vertex cover $V_2' \subseteq V_2$ with $|V_2'| \leq k_2$ given following construction:
    55 \begin{itemize}
    56   \item $V_2 = V$
    57   \item $E_2 = \{\{v_i,v_j\} \mid \{v_i,v_j\} \notin E\}$
    58   \item $k_2 = |V| - k$
    59 \end{itemize}
    60 If there is a vertex cover $V_2'$ of size $\leq k_2$, i.e. $\forall{e \in E}: \exists{v \in V_2'}: v \in e$ then it follows that there must be a clique of at least size $|V|-k_2$ in the complementary graph and vice versa, because for each disconnected vertex pair in one graph, there is a connected pair in the other.\\
    61 The construction takes linear time, hence it follows that $VertexCover \in NP$-$complete$. \qed\\\\
    62 (b) $Dominating Set \in NP$ because by guessing the vertex set $V'$, we can iterate over all $v \in V$ and check if $v \in V'$ or $\exists{v' \in V}: \{v,v'\} \in E$ holds in polynomial time.\\
    63 We show $Vertex Cover \le_P DominatingSet$. Given an undirected graph $G = \langle V, E \rangle$ and $k \in N$ we build a graph $G_2 = \langle V_2, E_2 \rangle$ so that there is a vertex cover $V' \subseteq V$ with $|V'| \leq k$ iff there is a dominating set $V_2' \subseteq V_2$ with $|V_2| \leq k$ given following construction:
    64 \begin{itemize}
    65   \item $V_2 = V \cup \{v_e \mid e \in E\}$
    66   \item $E_2 = E \cup \{\{v,v_e\} \mid v,v_e \in V_2$ and $e \in E\}$
    67 \end{itemize}
    68 By introducing the additional nodes for all vertices in $G$, we make sure that the dominating set $V_2'$, by covering all vertices in $G_2$, implicitely covers all edges in $G$. The other direction follows analogously, if a vertex cover $V'$ covers all edges in $G$ it follows that the same set covers all vertices in $G_2$.\\
    69 The construction takes linear time, hence it follows that $DominatingSet \in NP$-$complete$. \qed
    70 \end{document}