\documentclass[11pt]{article}

\usepackage{fullpage}
\usepackage{graphicx,epsfig}
\usepackage{color} 

\begin{document}

\title{} 
\date{}

\maketitle


\vspace{-5cm}
\section*{PRIM's MST algorithm}

\begin{itemize}
\item Start with spanning tree containing arbitrary an  vertex $r$ and
  no edges

\item Grow spanning tree by repeatedly adding minimal weight edge
  connecting vertex in current  tree with a vertex not in the
  tree

\item To find minimal edge connected to current tree we maintain a
  priority queue on vertices not in the tree: 
  \begin{itemize} 
  \item The key/priority of a vertex $v$ is the weight of minimal
    weight edge connecting $v$ to the tree. We maintain pointer from
    adjacency list of $v$ to $v$ in the priority queue.

  \item For each node $v$ maintain $visit(v)$ such that edge $(v,
    visit(v))$ is the best edge connecting $v$ to the current tree.
    
  \end{itemize}
\end{itemize}

\noindent 
\fbox{
  \parbox{11cm}{
    PRIM\\   
    \textcolor{blue}{/* initialize */}\\
    Pick arbitrary vertex $r$\\
    For each vertex  $u \in V, u \neq r$: {\sc Insert}($PQ,u,\infty$)\\    
    {\sc Insert}$(PQ,r,0)$,  $visit(r) = NULL$ \\
    \textcolor{blue}{/* main loop */}\\
    WHILE $PQ$ not empty
    \begin{itemize}
    \item[] $u$ = {\sc Delete-min}($PQ$)
    \item[] For each $(u,v) \in E$: 
      \begin{itemize}
      \item[] IF $v \in PQ$ and $w(u,v) < $ key($v$): 
      \item[] ~~~~visit[$v$] = $u$
      \item[] ~~~~{\sc Decrease-Key}($PQ,v,w(u,v)$)
      \end{itemize}
    \end{itemize}
    Output edges $(u, visit(u))$ as part of MST.
    
  }
}



\vspace{1cm}
\section*{Kruskal's MST algorithm} 
\fbox{
  \parbox{11cm}{
    KRUSKAL \\
     \textcolor{blue}{/* initialize */}\\
    For each vertex $v \in V$: {\sc Make-Set}($v$)\\
    Sort edges of $E$ in increasing order by weight \\
    \textcolor{blue}{/* main loop */}\\
    FOR each edge $e=(u,v) \in E$ in order of weight: 
    \begin{itemize}
    \item[] IF {\sc Find-Set}($u$) $\neq$ {\sc Find-Set}($v$) THEN
      \begin{itemize}
      \item[] output edge $e$ as part of MST 
      \item[] {\sc Union-Set}($u,v$)
      \end{itemize}
    \end{itemize}
  }}



\end{document} 
