\documentclass[11pt]{article}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{fullpage}
\usepackage[capitalise,nameinlink]{cleveref}
\usepackage[shortlabels]{enumitem}
\usepackage{graphicx}
\usepackage{listings}% http://ctan.org/pkg/listings
\lstset{
  basicstyle=\ttfamily,
  mathescape
}
\crefname{lemma}{Lemma}{Lemmas}
\crefname{fact}{Fact}{Facts}
\crefname{theorem}{Theorem}{Theorems}
\crefname{corollary}{Corollary}{Corollaries}
\crefname{claim}{Claim}{Claims}
\crefname{example}{Example}{Examples}
\crefname{problem}{Problem}{Problems}
\crefname{setting}{Setting}{Settings}
\crefname{definition}{Definition}{Definitions}
\crefname{assumption}{Assumption}{Assumptions}
\crefname{subsection}{Subsection}{Subsections}
\crefname{section}{Section}{Sections}

\DeclareMathOperator*{\E}{\mathbb{E}}
\let\Pr\relax
\DeclareMathOperator*{\Pr}{\mathbb{P}}

\newcommand{\eps}{\varepsilon}
\newcommand{\inprod}[1]{\left\langle #1 \right\rangle}
\newcommand{\R}{\mathbb{R}}

\newcommand{\handout}[5]{
  \noindent
  \begin{center}
  \framebox{
    \vbox{
      \hbox to 5.78in { {\bf CS 270: Combinatorial Algorithms and Data Structures
        } \hfill #2 }
      \vspace{4mm}
      \hbox to 5.78in { {\Large \hfill #5  \hfill} }
      \vspace{2mm}
      \hbox to 5.78in { {\em #3 \hfill #4} }
    }
  }
  \end{center}
  \vspace*{4mm}
}

\newcommand{\lecture}[4]{\handout{#1}{#2}{#3}{Scribe: #4}{Lecture #1}}

\newtheorem{theorem}{Theorem}[section]
\newtheorem*{theorem*}{Theorem}
\newtheorem{itheorem}{Theorem}

\newtheorem{subclaim}{Claim}[theorem]
\newtheorem{proposition}[theorem]{Proposition}
\newtheorem*{proposition*}{Proposition}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem*{lemma*}{Lemma}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem*{conjecture*}{Conjecture}
\newtheorem{fact}[theorem]{Fact}
\newtheorem*{fact*}{Fact}
\newtheorem{exercise}[theorem]{Exercise}
\newtheorem*{exercise*}{Exercise}
\newtheorem{hypothesis}[theorem]{Hypothesis}
\newtheorem*{hypothesis*}{Hypothesis}
\newtheorem{conjecture}[theorem]{Conjecture}

\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{setting}[theorem]{Setting}
\newtheorem{construction}[theorem]{Construction}
\newtheorem{example}[theorem]{Example}
\newtheorem{question}[theorem]{Question}
\newtheorem{openquestion}[theorem]{Open Question}
% \newtheorem{algorithm}[theorem]{Algorithm}
\newtheorem{problem}[theorem]{Problem}
\newtheorem{protocol}[theorem]{Protocol}
\newtheorem{assumption}[theorem]{Assumption}
\newtheorem{exercise-easy}[theorem]{Exercise}
\newtheorem{exercise-med}[theorem]{Exercise}
\newtheorem{exercise-hard}[theorem]{Exercise$^\star$}
\newtheorem{claim}[theorem]{Claim}
\newtheorem*{claim*}{Claim}

\newtheorem{remark}[theorem]{Remark}
\newtheorem*{remark*}{Remark}
\newtheorem{observation}[theorem]{Observation}
\newtheorem*{observation*}{Observation}

% 1-inch margins, from fullpage.sty by H.Partl, Version 2, Dec. 15, 1988.
% \topmargin 0pt
% \advance \topmargin by -\headheight
% \advance \topmargin by -\headsep
% \textheight 8.9in
% \oddsidemargin 0pt
% \evensidemargin \oddsidemargin
% \marginparwidth 0.5in
% \textwidth 6.5in

% \parindent 0in
% \parskip 1.5ex

\begin{document}

\lecture{1 --- January 17, 2023}{Spring 2023}{Prof.\ Jelani Nelson}{Altan Haan}

\section{Single-Source Shortest Path}
In this lecture, we will cover the single-source shortest path problem, with a focus on the recent
  work by Bernstein, Nanongkai, and Wulff-Nilsen \cite{bernstein}.
We begin by covering some mathematical background, before jumping into a sketch of the algorithm.

\subsection{General Background}
\begin{definition}
  A \emph{weighted directed graph} is a tuple $G = (V, E, w)$ where $V$ is a set of vertices, $E$ is
    a set of directed edges of the form $(u, v)$ where $u,v \in V$, and $w : E \to \mathbb{R}$ gives
    the edge weights.
  The \emph{length} of a path $P = (v_0, \dots, v_r)$ is naturally defined as
    $w(P) = \sum_{i=1}^r w(v_{i-1}, v_i)$.
  Lastly, we will frequently use $m = |E|$ and $n = |V|$ to denote the number of edges and vertices
    respectively.
\end{definition}

\begin{definition}
  The \emph{single-source shortest path (SSSP)} task takes as input a directed weighted graph
    $G = (V, E, w)$ and a \emph{source vertex} $s \in V$, and outputs a directed tree rooted at $s$
    such that for all $v \in V$ the shortest path from $s \to v$ is given by the (unique) path in
    the tree from $s \to v$.

  For the result in \cite{bernstein}, we further constrain $w$ such that for all $e \in E$,
    $w(e) \in \mathbb{Z}$ and $-W \leq w(e) \leq W$ for some $W \geq 0$.
\end{definition}

\begin{remark}
We have seen two algorithms from undergrad algorithms for solving this problem:
\begin{itemize}
  \item \textbf{Dijkstra's algorithm}, which runs in $O(m + n \log n)$ time under the assumption that
    $w(e) \geq 0$ for all $e \in E$; and
  \item \textbf{Bellman-Ford}, which runs in $O(mn)$ time for unrestricted edge weights (whilst detecting
    negative weight cycles if any exist).
\end{itemize}
\end{remark}

\begin{definition}
  For convenience, we write $\tilde{O}(f)$ in place of $O(f \cdot (\log f)^k)$ for some sufficient $k$.
\end{definition}

\subsection{Price Functions and Scaling}
\begin{definition}
  A \emph{price function} is a function $\varphi : V \to \mathbb{R}$, which defines an associated
    transformed weight function $w_\varphi(u, v) = w(u, v) + \varphi(u) - \varphi(v)$.
\end{definition}

\begin{remark}\label{rem:price}
  For any path $P = (v_0, \dots, v_r)$ we have $w_\varphi(P) = w(P) + \varphi(v_0) - \varphi(v_r)$,
    by a simple telescoping argument (the prices of internal vertices cancel out).
  It follows that $w_\varphi(P) = w(P)$ if $P$ is a cycle, as $v_0 = v_r$.
\end{remark}

\begin{remark}
  As all paths $P$ from $s \to v$ have $w_\varphi(P) = w(P) + \varphi(s) - \varphi(v)$, the shortest
    path $P^* = \arg\min_{P} (w(P) + \varphi(s) - \varphi(v)) = \arg\min_{P} w(P)$ remains unchanged.
\end{remark}

With these observations, we can formulate a new strategy for solving SSSP: if we can find a $\varphi$
  such that $w_\varphi(e) \geq 0$ for all $e \in E$, then we can utilize the much cheaper Dijkstra's
  algorithm on the transformed weights. We'll call these ``good'' price functions.
But first, we need to show that such $\varphi$'s do in fact exist.

\begin{claim}
  There exists a $\varphi: V \to \mathbb{R}$ such that $w_\varphi(e) \geq 0$ for all $e \in E$,
    \textbf{if and only if} $G$ has no negative cycles.
\end{claim}
\begin{proof}
  The forward direction is simple: supposing we have such a $\varphi$, then by \cref{rem:price} we
  know any cycle $C$ satisfies $w(C) = w_\varphi(C) \geq 0$.

  For the other direction, assume there are no negative cycles and define $\varphi(v) = d_G(s, v)$
    where $d_G(s, v)$ is the length of the shortest path from $s\to v$ in $G$.
  Then for any $(u, v) \in E$, we have $w_\varphi(u, v) = w(u, v) + d_G(s, u) - d_G(s, v)$.
  By the triangle inequality, we also know that $d_G(s, v) \leq d_G(s, u) + w(u, v)$. Together it
  follows that
  \[w_\varphi(u, v) \geq w(u, v) + d_G(s, u) - (d_G(s, u) + w(u, v)) = 0.\]
\end{proof}

Now that we know $\varphi$ exists under the standard SSSP assumption, we state and prove a theorem
  which allows us to take some shortcuts on the way to utilzing Dijkstra's algorithm.

\begin{theorem}[Goldberg \cite{goldberg}]
  Suppose we have an algorithm $\texttt{solve}$ which takes $G$ and returns a good $\varphi$ in $T(m)$ time,
  under the assumption that $w(e) \geq -1$ for all $e \in E$. Then there is an algorithm $\texttt{solve}^*$
  that runs in $O(T(m) \log W)$ time in the general case of $w(e) \geq -W$. Note that $w(e)$ is assumed to
  be integral.
\end{theorem}
\begin{proof}
  Without loss of generality, we round up $W = 2^k$ to the nearest power of 2. We proceed by strong induction on $k$.

  \paragraph*{Base case.} This follows trivially from just calling \texttt{solve}.

  \paragraph*{Inductive case.} Define $\hat{w}(e) = \lceil w(e) / 2 \rceil$ and $\hat{G} = (V, E, \hat{w})$.
  Then, let $\hat{\varphi} = \texttt{solve}^*(\hat{G})$, and define $\varphi' = 2 \hat{\varphi}$. Note
  that $\hat{\varphi}$ is well-defined as $\lceil w(e) / 2\rceil \geq -2^{k-1}$. Furthermore,
  \[w(e) \geq 2\lceil w(e) / 2\rceil - 1 = 2 \hat{w}(e) - 1.\]
  It follows that for any $(u, v) \in E$,
  \begin{align*}
    w_{\varphi'}(u, v) = w(u, v) + \varphi'(u) - \varphi'(v) &\geq 2\hat{w}(u, v) - 1 + 2\hat{\varphi}(u) - 2\hat{\varphi}(v)\\
    &= 2(\hat{w}(u, v) + \hat{\varphi}(u) - \hat{\varphi}(v)) - 1\\
    &= 2\hat{w}_{\hat{\varphi}}(u, v) - 1\\
    &\geq -1,
  \end{align*}
  where the last inequality is due to the goodness of $\hat{\varphi}$ with respect to $\hat{w}$.

  This shows that $G_{\varphi'}$ (i.e.\ $G$ with the transformed weight under $\varphi'$) satisfies
    the conditions for $\texttt{solve}$, and so the final price function is given by
    $\varphi = \texttt{solve}(G_{\varphi'}) + \varphi'$ as $G_\varphi = (G_{\varphi'})_{\texttt{solve}(G_{\varphi'})}$.
\end{proof}

\subsection{Bernstein--Nanongkai--Wulff-Nilsen (BNWN)}
We now sketch out the high-level approach taken by BNWN. First we'll give the formal
  statement.
\begin{theorem}[Bernstein--Nanongkai--Wulff-Nilsen]\label{thm:bnwn}
  Let $G = (V, E, w)$ such that $-W \leq w(e) \leq W$ for some $W \geq 0$ and $w(e) \in \mathbb{Z}$
  for all $e \in E$, and let $s \in V$ be the source. Then there is an algorithm which computes SSSP
  in $\tilde{O}(m \log W)$ time.
\end{theorem}

We also give some definitions used in the proof sketch.

\begin{definition}[Weak diameter]
  Let $G = (V, E, w)$ and $S \subseteq V$ be a strongly connected component. Then the
  \emph{weak diameter} of $S$ is defined as $\max_{u, v \in S} d_G(u, v)$.
\end{definition}

\begin{definition}
  For a given source $s$ and target vertex $v$, we denote the minimum number of negative edges
  on any shortest path from $s\to v$ by $\eta_G(v)$.
\end{definition}

\begin{proof}[Proof sketch (\cref{thm:bnwn})]
  First, we augment $G$ with a dummy source node $\sigma$ by defining
  $G_\sigma = (V_\sigma, E_\sigma, w_\sigma)$, where
  \begin{align*}
    V_\sigma &= V \cup \{\sigma\},\\
    E_\sigma &= E \cup \{(\sigma, v) \mid v \in V\},\\
    w_\sigma(u, v) &= \begin{cases}
      0 &~\text{if}~u = \sigma,\\
      w(u, v) &~\text{otherwise}.
    \end{cases}
  \end{align*}
  Note that solving SSSP on $G_\sigma$ with $\sigma$ gives the solution for $G$ with $s$, so for the
  rest of the sketch we'll just refer to $G_\sigma$ as $G$.%
  \footnote{Assuming $n \ll m$, the time complexity remains unchanged.}

  We now cover the subroutines utilized by the full algorithm.

  \paragraph*{$\textsf{LowDiameterDecomp}(G, D)$.} This subroutine takes a graph $G$ \emph{with
  nonnegative edge weights} and $D \geq 0$ computes a set $E^\text{rem} \subseteq E$ such that:
  \begin{enumerate}[(1)]
    \item Each strongly connected component (SCC) of $G \setminus E^\text{rem}$ has \emph{weak diameter}
      less than or equal to $D$. That is, for all $u,v$ in the SCC, $d_G(u ,v) \leq D$ (where the
      distance is taken in the original graph containing $E^\text{rem}$).
    \item The probability of an edge being in $E^\text{rem}$ satisfies
      \[P(e \in E^\text{rem}) \leq O\left(\frac{w(e) \log^2 n}{D} + n^{-10}\right).\]
  \end{enumerate}
  This subroutine runs in $\tilde{O}(m)$ time.

  \paragraph*{$\textsf{FixDAGEdges}(G, P)$.} This subroutine takes in a graph $G$ and vertex partitioning
  $P$ such that (1) each partitioned subgraph has no negative weight edges and (2) the graph obtained
  by contracting each partition to a single vertex is a DAG. Under these assumptions,
  \textsf{FixDAGEdges} outputs a good price function in $O(m + n)$ time.

  \paragraph*{$\textsf{ElimNeg}(G)$.} This subroutine takes a graph $G$ with constant out-degree and
  outputs a good price function in $O(\log n \sum_{v\in V} (1 + \eta_G(v)))$ time. We briefly remark
  that any graph can be transformed into one with constant out-degree by replacing non-constant
  vertices with zero-weight cycles as depicted below:
  \begin{center}
  \includegraphics[width=0.75\textwidth]{transform.png}
  \end{center}

  \paragraph*{$\textsf{ScaleDown}(G, \Delta, B)$.} The subroutine takes a graph $G$ such that
  $\eta(G) = \max_{v\in V} \eta_G(v) \leq \Delta$ and $w(e) \geq -2B$ for all $e \in E$, and returns
  a price function $\varphi$ such that $\varphi(e) \geq -B$ for all $e \in E$.

  \paragraph*{Main algorithm.}
  At a high level, \textsf{ScaleDown} invokes \textsf{LowDiameterDecomp}, \textsf{FixDAGEdges}, and
  \textsf{ElimNeg}. \textsf{ScaleDown} is in turn invoked repeatedly by the main algorithm.
  Intuitively, \textsf{LowDiameterDecomp} produces partitions with small $\eta$ values.

\begin{lstlisting}
def main($G = (V, E, w)$):
    $B \leftarrow 2n$  // without loss of generality, round $n$ up to pow of 2
    $\overline{w} \leftarrow B \cdot w$
    $\overline{G} \leftarrow (V, E, \overline{w})$
    $\varphi_0 \leftarrow 0$
    for i from $1$ to $\log_2 B$:
        $\psi_i \leftarrow \textsf{ScaleDown}(\overline G_{\varphi_{i-1}}, n, B/2^i)$
        $\varphi_i \leftarrow \varphi_{i-1} + \psi_i$
    for each $e\in E$:
        $w^*(e) \leftarrow \overline{w}_{\varphi_{\log_2 B}}(e) + 1$
    run Dijkstra on $(V, E, w^*)$    
\end{lstlisting}
\end{proof}

\bibliographystyle{alpha}
\bibliography{bib}

\end{document}