\input{template}
\input{macros}
\usepackage{color, graphicx}
\usepackage{epsfig}
\usepackage{amssymb, amsmath}
\begin{document}
\lecture{18}{Review of graph algorithms and extending it for general graphs}{Girish Sahani}
\section{Review of Previous lecture:}
Our objective is to find a matching $M$ of maximum size in a bipartite graph $G$.\\
Suppose edge set of the graph is E. Then a path is called an \textit{alternating path} 
if its edges are alternately in $M$ and $E-M$. \\
An \textit{augmenting path} is an alternating path 
whose start and end vertices are free (unmatched). \\
To find an augmenting path in G wrt a
matching $M$, we will use a Modified BFS algorithm. This algorithm finds an augmenting path
and increments the size of current matching $M$ by inverting $M$. This gives us a matching $M$' with $|M'| = |M| + 1$.
This algorithm terminates when no augmenting path can be found.

\begin{figure}[h]
\centering
\includegraphics[scale=0.3]{ap}
\caption{Alternating path in a Bipartite Graph (broken lines indicate non-matched edges)}
\label{figure:Alternating path in a Bipartite Graph (broken lines indicate non-matched edges)}
\end{figure}

\newpage
\section{Proof of correctness of modified BFS algorithm}
\newtheorem{thm}{Theorem}
\begin{thm}
$M$ is maximum if and only if there exists no augmenting path in $G$. 
\end{thm}
\begin{proof}
Proved in previous lecture.
\end{proof}\\
Hence if there exists an augmenting path $P$ from $u$, then applying modified BFS with $u$ as root node must 
find an augmenting path.
In fact, the alogrithm finds the shortest augmenting path $P$ from $u$.\\
Let $\{u_{0},u_{1},....u_{k-1}\}$ be the order of vertices in $P$, $u=u_{0}$.\\

\begin{Lem}
All alternating paths starting from u are traversed in the modified BFS (assuming we do not stop even 
if we obtain an augmenting path in the middle of BFS) in order.
\end{Lem}

\begin{proof}
By induction on length of path. Let k represent length of path.\\
\textit{Base Case:} $k=0,k=1$\\
This is trivially true. In the first iteration, algorithm marks all non-matching edges incident on u, 
and in next iteration one matching edge from each of the vertices in level $1$ is marked. Now as there is atmost one matching edge per vertex, we have covered all alternating paths starting from $u$ and of length 1 and 2.

\begin{program}
\textit{Inductive Step:} Assuming the induction hypothesis holds for $k=l$, consider $k=l+1$.\\
\IF $l = 2*m$:\\
\>	Modified BFS algorithm will mark one matching edge (if any) incident on each vertex in level \\	
\>	$2*(m-1)$, and as all alternating paths of length $2*m-1$ have been marked (induction hypothesis),\\
\>	and as there is atmost one matching edge per vertex $\Rightarrow$ all alternating paths starting from $u$  and\\
\>	of length $l=2*m$ are marked.\\
\IF $l = 2*m+1$:\\
\>	Modified BFS Algorithm will mark all unmatched edges from each vertex in level $2*m$, and as all\\ 
\>	alternating paths of length 2*m have been marked $\Rightarrow$ all alternating paths starting from length\\
\>	$l=2*m+1$ are marked.\\
Thus we have proved the lemma by induction.
\end{program}
\end{proof}\\
We use this lemma to prove correctness of modified BFS algorithm: \\
Since augmenting path is also an alternating path, from above lemma the algorithm guarantees to find an augmenting path
(if any). 
As the algorithm finds alternating paths with increasing length, shortest augmenting path will be found first. Thus the modified BFS algorithm is correct.\\
Time complexity of this algorithm = $O(m*n^{2})$, where $|V| = n$,$|E| = m$.

\newpage
\section{Extending the modified BFS algorithm to general graphs}

Non-bipartite graphs can also contain even-even edges (as shown in the figure above). This will result in odd length cycles.\\
Hence if we apply modified BFS on non-bipartite graphs, the algorithm might not find an 
augmenting path. Such an example is shown in the Fig. \ref{graph}. The augmenting path is shown in dark.\\
This is a non trivial polynomial time algorithm and it was solved by Jack Edmonds. 
A solution to this problem is to shrink the odd-cycles (blossoms) to a single vertex. \\ 
This will be discussed in detail in the next lecture.
\begin{figure}[ht]
\centering
\includegraphics[height=5in]{gg}
\caption{Modified BFS on General graph}
\label{graph}
\end{figure} 

\end{document}
