\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{subfig}
\usepackage{amssymb}
\usepackage{amsmath,amsthm}
\usepackage{graphicx}
\usepackage{multicol,xcolor}
\usepackage{enumerate}
\usepackage{float}
\usepackage{mathtools}
\newcounter{lecnum}

\newcommand{\lecture}[4]{
   \newpage
   \setcounter{lecnum}{#1}
   \noindent

   \begin{center}
   \framebox{
      \vbox{\vspace{2mm}
    \hbox to 16cm { {\bf CS602 Applied Algorithms
                        \hfill 2019-20 Sem II} }
       \vspace{4mm}
       \hbox to 16cm { {\Large \hfill Lecture #1: #2  \hfill} }
       \vspace{2mm}
       \hbox to 16cm { {\it Scribe: #4  \hfill  Lecturer: #3} }
      \vspace{2mm}}
   }
   \end{center}
   \vspace*{4mm}
}

\newcommand{\R}{\mathbb{R}}
\newcommand{\transpose}{\mathtt{T}}

\newtheorem{theorem}{Theorem}[lecnum]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem{claim}[theorem]{Claim}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{definition}[theorem]{Definition}

\DeclareMathOperator{\Cone}{cone}
\newcommand\Mycomb[2][^n]{\prescript{#1\mkern-0.5mu}{}C_{#2}}


\begin{document}

%\lecture{**LECTURE-NUMBER**}{**DATE**}{**LECTURER**}{**SCRIBE**}
\lecture{17}{March 17}{Rohit Gurjar}{Vijaykrishna G, Nipun Mittal}

\paragraph{Steiner Tree/Forest.} A graph $G$ with edge weights and 
some vertex pairs $(s_1,t_1),(s_1,t_1),...,(s_k,t_k)$ are given. The goal is to compute a forest that connects 
$s_i$ to $t_i$ for each $i$ and has minimum possible weight. 

Interesting cuts : $S \subseteq V$ s.t. $\exists i$, $ s_i \in S$ and $t_i \in \overline{S}$.

\begin{itemize}
	\item When $k = 1$, Steiner Tree/Forest problem is equivalent to Shortest Path problem.
	\item When $k = \Mycomb[|V|]{2}$ i.e, every pair of vertices needs to be connected then the problem is equivalent to Minimum Spanning Tree problem. 
\end{itemize}

\section{Algorithm Outline for the Steiner Tree Problem}

\paragraph{Step 1:} Start with a feasible dual solution. The simplest solution one can think of is $\forall S \;\; y_S = 0$.

\paragraph{Step 2:} Try to find a primal feasible \textit{integral} solution that satisfies complementary slackness condition i.e,
\begin{eqnarray*}
 \text{you can set  } x_e =1 \text{ if }	 \sum_{S : e \in \delta(S)}  y_S = w_e \quad \text{(i.e., tight edge)}
\end{eqnarray*}
In other words, check whether the desired kind of Steiner forest can formed using only the tight edges. %forms a Steiner Forest: 
\begin{itemize}
\item If yes, then we are done and we have found a solution.
\item Otherwise, find a set $S$ s.t.\ $ s_i \in S$ and $t_i \in \overline{S}$ for some $i$ (which implies interesting cut) 
 and for each edge $e \in \delta(S)$, we have $x_e = 0$.
\end{itemize}
For ease of understanding, one can think that $x_e=0$ if and only if the edge $e$ is non-tight. 
We will see later that this is not exactly true, a tight edge can possibly have $x_e=0$. 

\paragraph{Step 3:} For such a set $S$,
 try to increase $y_S$  till some dual constraint(s) i.e, edge(s) becomes tight. 

\paragraph{} Since after one iteration at least one edge will become tight, we can easily 
 conclude that the algorithm will terminate after finitely many iterations.
We elaborate more on the implementation details.  As discussed in the last lecture, 
we will try to increase many dual variables simultaneously.

%In the \textbf{Step2} we are supposed to find a set $S$ s.t. $ s_i \in S$ and $t_i \in \overline{S}$. 
We will  maintain the subgraph $G'$ with edge set $\{e \in E : x_e =1\}$ and its connected components. 
% let $F$ be the current set  of tight edges. 
At any stage, for any connected component $S \subseteq V$ of $G'$,  all the edges in $\delta(S)$ are potentially non-tight.
%We can find S by maintaining connected components of the graph $G^\prime$ with only tight edges.
 However, we only need \emph{active sets} among the connected components.

\paragraph{Active set.} $T\subseteq V$ is an active set if $T$ forms a  connected component in $G'$ and for some $i$, $s_i \in T$ and $t_i \notin T$.

\begin{figure}[H]
	\center
\includegraphics[width=80mm]{cc.png}
\caption{Connected components where CC1 and CC2 are interesting cuts (active sets) while CC3 is not.}
\end{figure}

We increase the dual variables $y_T$ for all active sets $T$ simultaneously until at least one edge becomes tight.
Note that multiple edges can become tight simultaneously, however,
 we set $x_e=1$ only for one of them at a time (chosen arbitrarily) and include it in $G'$.
The reason for this is as follows: any new edge that becomes tight connects two different components in $G'$
and we want to maintain that the set of edges $\{e : x_e=1\}$ forms a forest. Adding multiple edges simultaneously might lead to cycles. 
 The example given below will  clarify this. 

\paragraph{Pruning:}
After algorithm stops we'll have subset of edges $F$ as the solution. Now, there may be some spurious edges in the solution, that is, any edge after whose removal 
the solution remains a valid Steiner forest (for each $i$, $s_i$ is connected to $t_i$). 
It is simple to identify spurious edges. Since $F$ is a forest, there is a unique path between $s_i$ and $t_i$, for each $i$. 
Any edge that does not lie on any of these paths is spurious. Recall the example from the last lecture where $\{e_1,e_2\}$ was the output of the algorithm, 
but $e_2$ was spurious and was removed. 
All spurious edges can removed at once (i.e., setting $x_e = 0$ for that edge).

%we can remove them one by one s.t, after removing an edge (i.e., setting $x_e = 0$ for that edge) our solution is still feasible. Since our solution is a forest there will not be any cycles so we can remove the edges in any order. 

Now, let us look at an example to understand this.

\section{Example from Vazirani's book}
\begin{figure}[H]
\center
\includegraphics[width=100mm]{graph.png}
\caption{Example. Terminal pairs are ($u$,$v$) and ($s$,$t$)}
\label{fig:graph}
\end{figure}
Consider the graph given in Figure~\ref{fig:graph}. The terminal pairs are $(u,v)$ and $(s,t)$.
That is, we want to compute a forest that connects $u$ to $v$ and $s$ to $t$.
Recall that 
the dual constraints are given by the following.
\[\text{For each } e \in E, \;  \displaystyle\sum_{ \substack{ S  \subseteq V \\
S  \text{ is interesting } \\ \text{and } e \in \delta(S)}}  y_S \leq w_e .\]

Initially $y_S = 0 $ for all $S$ and there are no tight edges, that is, $x_e=0$ for each edge $e$.
%When writing a dual constraints we will only write the dual variables that are currently nonzero. 

\paragraph{Iteration 1:}
The graph $G'$ has no edges and thus, the connected components are individual vertices. According to 
the definition of active sets we get the following active dual variables. 

Active: $y_u = 0$, $y_s = 0$, $y_v = 0$, $y_t=0$.

Trying to add $\epsilon$ to each of the four variables. The dual constraints look like this (we hide the dual variables that are still zero).
\begin{eqnarray*}
2 \epsilon = y_u + y_s &\leq& w_{(u,s)} = 16.\\
 \epsilon =  y_s &\leq& w_{(s,a)} = 12.\\
\color{red} \epsilon =  y_u & \color{red} \leq & \color{red} w_{(u,a)} = 6. \\
2 \epsilon =  y_u + y_v &\leq& w_{(u,v)} = 20.\\
0=0 &\leq& w_{(a,b)} = 9.\\
\color{red} \epsilon =  y_v & \color{red} \leq & \color{red} w_{(v,b)} = 6.\\
 \epsilon =  y_t &\leq& w_{(b,t)} = 12.\\
2 \epsilon =  y_v + y_t &\leq& w_{(t,v)} = 19.\\
\end{eqnarray*}

The largest value  $\epsilon$ can take without violating the above constraints is $6$.
 So set 
 \[y_u = y_s = y_v = y_t = 6.\] 
 The constraints for the two edges $(u,a)$ and $(v,b)$ become tight (shown in red).
We pick one of the two tight edges, say $(u,a)$, and set $x_{(u,a)}=1$.

\paragraph{Iteration 2:}
Now, our $G'$ has a single edge $(u,a)$. Connected components are $\{u,a\}$ and all other single vertices. 

Active: $y_{\{u,a\}}=0$, $y_s=6$, $y_v=6$, $y_t=6$.

Trying to add $\epsilon$ to each, you get $\epsilon = 0$, because the edge $(v,b)$ is already a tight edge so you cannot increase $y_v$ any further.
We count $(v,b)$ as the new tight edge found in this iteration and  set $x_{(v,b)}=1$.

\paragraph{Iteration 3:}
$G'$ has a  edges $(u,a), (v,b)$. Connected components are $\{u,a\},\{v,b\}, \{s\}, \{t\}$. 

Active: $y_s=6$, $y_t=6$, $y_{\{u,a\}}=0$, $y_{\{v,b\}}=0$.
Trying to add $\epsilon$ to each of the four variables. 
\[y_s=6+\epsilon, \; y_t=6+\epsilon, \;  y_{\{u,a\}}=\epsilon, \; y_{\{v,b\}}=\epsilon.\]
The dual constraints look like this (we hide the dual variables that are still zero).

\begin{eqnarray*}
 \color{red} y_u + y_s + y_{u,a} = 6+6+\epsilon+\epsilon & \color{red} \leq& \color{red} w_{(u,s)} = 16.\\
 y_s +y_{u,a}  = 6+\epsilon+\epsilon&\leq & w_{(s,a)} = 12.\\
 y_u =6 &  \leq &  w_{(u,a)} = 6. \\
y_u + y_v + y_{\{u,a\}} + y_{\{v,b\}}  =6+6+\epsilon+\epsilon &\leq& w_{(u,v)} = 20.\\
y_{\{u,a\}} + y_{\{v,b\}} = \epsilon+\epsilon &\leq& w_{(a,b)} = 9.\\
y_v = 6 &  \leq &  w_{(v,b)} = 6.\\
  y_t +  y_{\{v,b\}} = 6+\epsilon+\epsilon &\leq& w_{(b,t)} = 12.\\
 y_v + y_t + y_{\{v,b\}} =  6+6+\epsilon+\epsilon &\leq& w_{(t,v)} = 19.\\
\end{eqnarray*}

The largest value  $\epsilon$ can take without violating the above constraints is $2$.
That makes the constraint for edge $(u,s)$ tight (shown in red).
So we get
\[ y_s=y_t=8,   \; y_{u,a}= y_{v,b} = 2, \text{ and }  y_u = y_v = 6 \text{ (remained unchanged)} .\]
Since $(u,s)$ becomes tight, we set $x_{(u,s)}=1$.

\paragraph{Iteration 4:}
$G'$ has a  edges $(u,a), (v,b), (u,s)$. Connected components are $\{u,s,a\},\{v,b\}, \{t\}$.

Active: $y_{\{u,s,a\}} = 0$, $y_t = 8$, $y_{\{v,b\}}=2$.
Adding $\epsilon$ to each of the three.
\[ y_{\{u,s,a\}} = \epsilon, \; y_t = 8+\epsilon,\; y_{\{v,b\}}=2+\epsilon. \]
The dual constraints look like this (we hide the dual variables that are still zero).
\begin{eqnarray*}
 y_u + y_s + y_{u,a} = 6+8+2 &  \leq&  w_{(u,s)} = 16.\\
 y_s +y_{u,a}  = 8+2 &\leq & w_{(s,a)} = 12.\\
 y_u =6 &  \leq &  w_{(u,a)} = 6. \\
y_u + y_v + y_{\{u,a\}} + y_{\{v,b\}} +y_{\{u,s,a\}}  =6+6+2+2 + \epsilon +\epsilon&\leq& w_{(u,v)} = 20.\\
y_{\{u,a\}} + y_{\{v,b\}} + y_{\{u,s,a\}} = 2+ 2+ \epsilon+\epsilon &\leq& w_{(a,b)} = 9.\\
y_v = 6 &  \leq &  w_{(v,b)} = 6.\\
\color{red}  y_t +  y_{\{v,b\}} = 8+\epsilon+ 2+ \epsilon & \color{red} \leq& \color{red} w_{(b,t)} = 12.\\
 y_v + y_t + y_{\{v,b\}} =  6+8+\epsilon+2+\epsilon &\leq& w_{(t,v)} = 19.\\
\end{eqnarray*}

The largest value  $\epsilon$ can take without violating the above constraints is $1$.
That makes the constraint for the edge $(b,t)$ tight (shown in red). Set $x_{(b,t)}=1$.
Dual variables become
\[y_{\{u,s,a\}} = 1, \; y_t = 9,\; y_{\{v,b\}}=3 \text{ and } y_s=8,   \; y_{u,a} = 2, \;  y_u = y_v = 6 \text{ (remained unchanged)} .\]

\paragraph{Iteration 5:}
$G'$ has a  edges $(u,a), (v,b), (u,s), (b,t)$. Connected components are $\{u,s,a\},\{v,b,t\}$.


Active: $y_{\{u,s,a\}} = 1$, $y_{\{v,b,t\}} = 0$.
Adding $\epsilon$ to each,  
\[y_{\{u,s,a\}} = 1+\epsilon, \; y_{\{v,b,t\}} = \epsilon .\]
The dual constraints look like this (we hide the dual variables that are still zero).
\begin{eqnarray*}
 y_u + y_s + y_{u,a} = 6+8+2 &  \leq&  w_{(u,s)} = 16.\\
 y_s +y_{u,a}  = 8+2 &\leq & w_{(s,a)} = 12.\\
 y_u =6 &  \leq &  w_{(u,a)} = 6. \\
\color{red} y_u + y_v + y_{\{u,a\}} + y_{\{v,b\}} +y_{\{u,s,a\}} +y_{\{v,b,t\}} =6+6+2+3 + 1 +\epsilon+\epsilon& \color{red} \leq&  \color{red} w_{(u,v)} = 20.\\
y_{\{u,a\}} + y_{\{v,b\}} + y_{\{u,s,a\}} +y_{\{v,b,t\}}= 2+ 3+ 1+\epsilon+\epsilon &\leq& w_{(a,b)} = 9.\\
y_v = 6 &  \leq &  w_{(v,b)} = 6.\\
 y_t +  y_{\{v,b\}} = 9+ 3 &  \leq&  w_{(b,t)} = 12.\\
 y_v + y_t + y_{\{v,b\}} =  6+9+3 &\leq& w_{(t,v)} = 19.\\
\end{eqnarray*}

The largest value  $\epsilon$ can take without violating the above constraints is $1$.
That makes the constraint for the edge $(u,v)$ tight (shown in red). Set $x_{(u,v)}=1$.
Dual variables become
\[y_{\{u,s,a\}} = 2, \; y_{\{v,b,t\}} =1,  \text{ and } y_t = 9,\; y_{\{v,b\}}=3, \; y_s=8,   \; y_{u,a} = 2, \;  y_u = y_v = 6 \text{ (remained unchanged)} .\]

Now, $G'$ has a  edges $(u,a), (v,b), (u,s), (b,t), (u,v)$. Finally, $s$ is connected to $t$ and $u$ is connected to $v$.

\begin{figure}[H]
\center
\includegraphics[width=100mm]{graph1.png}
\caption{After iteration 5}
\end{figure}

\paragraph{Pruning:}
In the solution obtained, if removing an edge $e$ still makes it a feasible solution then remove it. Order of removal of edges does not matter. 
So the final solution would be to just remove the edge $(u,a)$ and
we obtain $\{ (v,b), (u,s), (b,t), (u,v) \}$ as the Steiner forest, whose cost is $54$.
Compare this to the optimal solution $\{(u,a),(s,a),(a,b),(b,v),(b,t)\}$, whose cost is $45$.

\textbf{Exercise:} Run this algorithm for finding shortest path and MST(Minimum Spanning Tree) in the graph are match its result with the optimal answer. 

\section{Analysis of the Algorithm}
\begin{claim}
The above algorithm gives a 2-approximate solution for Steiner forest. 
\end{claim}

This section is devoted to prove this claim. 
Let $F^\prime$ be the final set of edges obtained after the pruning step.
 Now we will analyze the complementary slackness conditions with respect to our solution.
  The first (dual) condition which was $$ x_e \neq 0 \implies  \displaystyle\sum_{ \substack{ S  \subseteq V \\
		S  \text{ is interesting } \\ \text{and } e \in \delta(S)}}  y_S = w_e  $$ is always satisfied because we have used this only to proceed in the algorithm.
	
The second (primal) condition which says $$ y_S \neq 0 \implies \sum_{e \in \delta(S)}  x_e = 1 \qquad i.e, \; |F^\prime \cap \delta (S)| = 1$$ is desired. It means that final solution should take exactly one edge from each $\delta(S)$ s.t. $y_S \not= 0$. Recall that we did not care about this condition in the algorithm. 
Note that, in the discussed example, $y_u \neq 0$, but there are two edges from $\delta(u)$ in the final solution. 
So, certainly our solution cannot be guaranteed to be optimal.  

We have seen a usual  technique to bound the approximation factor, which requires the complementary slackness conditions to be satisfied approximately.
Towards this, 
let us define a variable $\gamma$ as $$\gamma = \displaystyle\max_{ \substack{S\\y_S \not= 0}} |F^\prime \cap \delta (S)|$$

\textbf{Exercise:} Prove that $F^\prime$ is $\gamma$-approx solution.

However, this approach does not give us a 2-factor guarantee. One can construct examples where $\gamma$ is  larger than $2$.

We will do a slightly different analysis to prove that the above algorithm is 2-approx. 
Note that it will be sufficient  to show that 
\begin{eqnarray}
 \sum_e x_e w_e   &\leq& \;  2 \sum_S y_S \label{eq:primal-dual} \\
 \text{ i.e.,  (cost of our primal solution) } &\leq& 2 \times \text{(cost of our dual solution)} \nonumber 
\end{eqnarray}
Why? Because cost of our dual solution is at most the optimal dual value, which is equal to optimal primal value, which in turn, is at most the cost of optimal Steiner forest 
(optimal Steiner forest is the optimal solution of the integer LP).
 
 To prove (\ref{eq:primal-dual}) let us first write the primal cost as 
 \[ \sum_{e} x_e w_e = \sum_{e \in F'} w_e = \sum_{e \in F'} \sum_{ {S : e \in \delta(S)}}y_S = P \text{ (say)}. \]
 The last equation holds because all edges in $F'$ are tight. Let us write the dual cost as simply 
\[ \sum_S y_S = D \text{ (say)}.\]
%$$\displaystyle\sum_{ \substack{e \in F^\prime}}w_e = \displaystyle\sum_{ \substack{e \in F^\prime}} \sum_{ \substack{S \\ e \in \delta(S)}}y_S \; \leq \; 2\sum y_S$$
At the beginning of the algorithm, both the sums $P$ and $D$ are zero, since $y_S=0$ for all $S$ .
 As  the dual variables increase, we will see how much do the sums $P$ and $D$ increase relative to each other. 
At any iteration of the algorithm, suppose  there are $k$ active sets (dual variables) $y_{S_1},  y_{S_2}, \dots, y_{S_k}$
 and suppose we add $\epsilon$ to each of these variables in this iteration.
\textbf{The total increase in $D$ will be exactly $k\epsilon$ in this iteration.}

To calculate total increase in $P$, we add up the increase in the sum $\sum_{ {S : e \in \delta(S)}}y_S$
for each edge $e \in F'$.
First consider an edge $e$ whose both end-points are inside  an active set, say $S_i$.
Note that $e \not\in \delta(S_j)$ for any $1\leq j \leq k$. Thus, there is no increase in the  $\sum_{ {S : e \in \delta(S)}}y_S$.

Now, consider any edge $e$ whose end-points are in  two different active sets, say $S_{i_1}, S_{i_2}$. 
Thus, $e \in \delta(S_{i_1})$ and $e \in \delta(S_{i_2})$, but $e \not\in \delta(S_j)$ for any  $j$ other than $i_1$ or $i_2$.
For this edge $e$, the sum $\sum_{ {S : e \in \delta(S)}}y_S$ will see an increase of exactly $2 \epsilon$.
We can have at most $k-1$ edges going across active sets because $F'$ is a forest. 
\textbf{Thus, the total increase in $P$ will be at most $2\epsilon(k-1)$ in this iteration.}

In conclusion, $P \leq 2 ((k-1)/k) \times D \leq 2D$, which is the desired inequality.
\\

\paragraph{Exercise (Survivable Network Desgin):} In this problem, we are given pairs of vertices along with numbers $(s_1,t_1,n_1),(s_1,t_1,n_2),...,(s_k,t_k,n_k)$ and want to find out the minimum weight subgraph which has at least $n_i$ edge-disjoint paths between $s_i$ and $t_i$, for each $i$. 
Design a similar algorithm for this problem using the  same primal dual scheme seen in this lecture. 
Is it a  2-approx algorithm?

\end{document}
