% !TEX root =  centrtutorial.tex

\section{Exact Algorithms}
\begin{frame}
  \frametitle{Outline}
  \begin{enumerate}
    \item Exact algorithms for static graphs
      \begin{enumerate}
        \item the standard algorithm for closeness
        \item the standard algorithm for betweenness
        \item a faster betweenness algorithm through shattering and compression
        \item a GPU-Based algorithm for betweenness
      \end{enumerate}
    \item Exact algorithms for dynamic graphs
      \begin{enumerate}
        \item a dynamic algorithm for closeness
        \item four dynamic algorithms for betweenness
        \item a parallel streaming algorithm for betweenness
      \end{enumerate}
  \end{enumerate}
\end{frame}

\subsection{Exact Algorithms for Static Graphs}

\begin{frame}
  \centering
  \vfill
  {\huge Exact Algorithm for Closeness Centrality}
  \vfill
  {\Large(folklore)}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Exact Algorithm for Closeness}
    \vfill
    Recall the definition:
    \[
      \closeness(x)=\frac{1}{\sum_{y\neq x}d(x,y)}
    \]
    \vfill
    \pause
    Fastest known algorithm for closeness: \emph{All-Pairs Shortest Paths}
    \begin{itemize}
      \item Runtime: $O(nm+n^2\log n)$
    \end{itemize}
    \vfill
    \pause
    Too slow for \emph{web-scale} graphs!
    \begin{itemize}
      \item Later we'll discuss an \emph{approximation algorithm}
    \end{itemize}
    \vfill
\end{frame}

\begin{frame}
  \centering
  \vfill
  {\huge A Faster Algorithm for Betweenness Centrality}
  \vfill
  {\Large U.~Brandes}
  \vfill
  {\large Journal of Mathematical Sociology (2001)}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Why {\red faster}?}
  \vfill
  Let's take a step back. Recall the definition
  \[
    \sum_{\substack{s\neq x\neq t \in V\\s\neq t}}\frac{\sigma_{st}(x)}{\sigma_{st}}
    \vspace{-10pt}
  \]
  \begin{itemize}
    \item $\sigma_{st}$: no.~of \spath (SPs) from $s$ to $t$
    \item $\sigma_{st}(x)$: no.~of \spath from $s$ to $t$ that go through $x$
  \end{itemize}
  \pause
  We could:
  \begin{enumerate}
    \item obtain all the $\sigma_{st}$ and $\sigma_{st}(x)$ for all $x$, $s$,
      $t$ via APSP; and then
    \item perform the aggregation to obtain $\betw(x)$ for all $x$.
  \end{enumerate}
  \pause
  The first step takes $O(nm+n^2\log n)$, but the second step takes\ldots\pause
  $\Theta(n^3)$ (a sum of $O(n^2)$ terms for each of the $n$ vertices).
  \pause
  \vfill
  Brandes' algorithm interleaves the SP computation with the aggregation,
  achieving runtime $O(nm+n^2\log n)$\\
  \quad I.e., it is \emph{faster} than the APSP approach
\end{frame}

\begin{frame}
  \frametitle{Dependencies}
  Define: \emph{Dependency} of $s$ on $v$:
  \[
    \dep_s(v)=\sum_{t\neq s\neq v}\frac{\sigma_{st}(v)}{\sigma_{st}}
  \]
  Hence:
  \[
    \betw(v)=\sum_{s\neq v}\dep_s(v)
  \]
  \pause
  Brandes proved that $\delta_s(v)$ obeys a \emph{recursive relation}:
  \[
    \dep_s(v)=\sum_{w:v\in\pred_s(w)}\frac{\sigma_{sv}}{\sigma_{sw}}\left(1+\dep_s(w)\right)
  \]
  We can leverage this relation for efficient computation of betweenness
\end{frame}

\begin{frame}
  \frametitle{Recursive relation}
  \begin{theorem}[Simpler form]
    If there is exactly one \spath from $s$ to each $t$, then
    \[
      \dep_s(v)=\sum_{w: v\in\pred_s(w)}\left(1+\dep_s(w)\right)
    \]
  \end{theorem}
  \pause
  \emph{Proof sketch:}
  \begin{itemize}
    \item The \spdag from $s$ is a tree;
    \item Fix $t$. $v$ is either on the single \spath from $s$ to $t$ or not.
    \item $v$ lies on all and only the SPs to vertices $w$ for which $v$ is a
      predecessor (one \spath for each $w$) and the SPs that these lie on. Hence the
      thesis.
  \end{itemize}
  \pause
  The general version must take into account that not all SPs from $s$ to $w$ go
  trough $v$.
\end{frame}

\begin{frame}
  \frametitle{Brandes' Algorithm}
  \begin{enumerate}
    \item Initialize $\dep_s(v)$ to $0$ for each $v,s$ and $\betw(w)$ to $0$ for
      each $w$.
    \item Iterate the following loop for each vertex $s$:
      \begin{enumerate}
        \item Run Dijkstra's algorithm from $s$, keeping track of $\sigma_{sv}$ for
          each encountered vertex $v$, and inserting the vertices in a max-heap $H$ by
          distance from $s$;
        \item While $H$ is not empty:
          \begin{enumerate}
            \item Pop the max vertex $t$ in $H$;
            \item For each $w\in\pred_s(t)$, increment $\dep_s(w)$ by
              $\frac{\sigma_{sw}}{\sigma_{st}}(1+\dep_s(t))$;
            \item Increment $\betw(t)$ by $\dep_s(t)$;
          \end{enumerate}
      \end{enumerate}
  \end{enumerate}
\end{frame}

\begin{frame}
  \centering
  \vfill
  {\huge Shattering and Compressing Networks for Betweenness Centrality}
  \vfill
  {\Large A.~E.~Sar\i y\"uce, E.~Saule, K.~Kaya, \"U.~V.~\c{C}ataly\"urek}
  \vfill
  {\large SDM '13: SIAM Conference on Data Mining}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}
  \emph{Observations:}
  \begin{itemize}
    \item There are vertices with predictable betweenness (e.g., 0, or equal to one
      of their neighbors). We can remove them from the graph (\emph{compression})
    \item Partitioning the (compressed) graph into small components allows for
      faster SP computation (\emph{shattering})
  \end{itemize}
  \pause
  \emph{Idea}:
  We can iteratively compress \& shatter until we can't reduce the graph any
  more.\\
  \qquad Only at this point we run (a modified) Brandes's algorithm and then
  aggregate the ``partial'' betweenness in different components.
\end{frame}

\begin{frame}
  \frametitle{Introductory definitions}
  \vfill
  \begin{itemize}
    \item Graph $G=(V,E)$
    \item \emph{Induced graph} by $V'\subseteq V$: $G_{V'}=(V', E'=V'\times V'\cap E)$
    \pause
    \item Neighborhood of a vertex $v$: $\neighbors(v)=\{u~:~(v,u)\in E\}$
    \pause
  \item \emph{Side vertex}: a vertex $v$ such that $G_{\neighbors(v)}$ is a clique
    \pause
  \item \emph{Identical vertices}: two vertices $u$ and $v$ such that either
      $\neighbors(u)=\neighbors(v)$ or
      $\neighbors(u)\cup\{u\}=\neighbors(v)\cup\{v\}$
  \end{itemize}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Compression}
  \vfill
  Empirical / intuitive observations
  \begin{itemize}
    \item if $v$ has degree $1$, then $\betw(v)=0$
    \item if $v$ is a side vertex, then $\betw(v)=0$
    \item if $u$ and $v$ are identical, then $\betw(v)=\betw(w)$
  \end{itemize}
  \pause
  \vfill
  \emph{Compression}:
  \begin{itemize}
    \item remove degree-1 vertices and side vertices; and
    \item merge identical vertices
  \end{itemize}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Shattering}
  \vfill
  \begin{itemize}
    \item \emph{Articulation vertex}: vertex $v$ whose deletion makes the graph disconnected
    \item \emph{Bridge edge:} an edge $e=(u,v)$ such that $G'=(V,E\setminus\{e\})$ has
      more components than $G$ ($u$ and $v$ are articulation vertexes)
  \end{itemize}
  \pause
  \vfill
  \emph{Shattering}:
  \begin{itemize}
    \item remove bridge edges
    \item split articulation vertices in two copies, one per resulting component
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Example of shattering and compression}
  \begin{figure}
    \includegraphics{imgs/shatteringbadios.pdf}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Issues}
  Issues to take care of when iteratively compressing \& shattering:
  \begin{block}{Example of issue}
    A vertex may have degree 1 only after we removed another vertex: we can't
    just remove and forget it, as its original betweenness was not 0.
  \end{block}
  \pause
  \begin{block}{Example of issue}
    When splitting an articulation vertex into component copies, we need to know,
    for each copy, how many vertices in other components are reachable through
    that vertex.
  \end{block}
  ...and more
\end{frame}

\begin{frame}
  \frametitle{Solution}
  (Sketch)
  \begin{itemize}
    \item When we remove a vertex $u$, one of its neighbors (or an identical vertex)
      $v$ is elected as the representative for $u$ (and for all vertices that $u$
      was a representative of)
    \item We adjust the (current) values of $\betw(v)$ and $\betw(u)$ to
      appropriately take into account the removal of $u$\\
      \qquad the details are too hairy for a talk\ldots
    \item When splitting articulation vertices or removing bridges, similar
      adjustments take place
    \item Brandes' algorithm is slightly modified to take the number of vertices
      that a vertex represents into consideration when computing the
      dependencies and the betweenness values
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Speedup}
  ``org.'' is Brandes' algorithm, ``best'' is compress \& shatter
  \begin{figure}
    \includegraphics{imgs/runtimebadios.pdf}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Composition of runtime}
  \begin{itemize}
    \item Preproc is the time needed to compress \& shatter, Phase 1 is SSSP,
      Phase 2 is aggregation
    \item Different column for different variants of the algorithm (e.g., only
      compression of 1-degree vertices, only shattering of edges)
    \item the lower the better
  \end{itemize}
  \begin{figure}
    \includegraphics[width=0.9\textwidth]{imgs/runtimesplitbadios.pdf}
  \end{figure}
\end{frame}

%\begin{frame}
%  \frametitle{A Divide-and-Conquer Algorithm for Betweenness Centrality}
%  \centering
%  \vfill
%  {\huge D.~Erd\H{o}s, V.~Ishakian, A.~Bestravros, E.~Terzi}
%  \vfill
%  {\large SIAM Data Mining Conference (2015)}
%\end{frame}

%% Sariyüce et al.
\begin{frame}
  \centering
  \vfill
  {\huge Betweenness Centrality on GPUs and Heterogeneous Architectures}
  \vfill
  {\Large A.~E.~Sar\i y\"uce, K.~Kaya, E.~Saule, \"U.~V.~\c{C}ataly\"urek}
  \vfill
  {\large GPGPU '13: Workshop on General Purpose Processing Using GPUs}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Parallelism}

  \begin{itemize}
    \item Fine grained: single concurrent BFS
    \item Only one copy of auxiliary data structures
    \item Synchronization needed
    \item Better for GPUs, which have small memory
  \end{itemize}
  \begin{itemize}
    \item Coarse grained: many independent BFSs
    \item Sources are independent, embarrassingly parallel
    \item More memory needed
    \item Better for CPUs, which have large memory
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{GPU}

  \begin{quote}
    A GPU is especially well-suited to address problems that can be expressed as \textbf{data-parallel computations} - the same program is executed on many data elements in parallel - with \textbf{high arithmetic intensity} - the ratio of arithmetic operations to memory operations.

    Because the same program is executed for each data element, there is a lower requirement for sophisticated flow control, and because it is executed on many data elements and has high arithmetic intensity, the memory access latency can be hidden with calculations instead of big data caches.\footnote{\url{docs.nvidia.com/cuda/cuda-c-programming-guide/index.html}}
  \end{quote}
\end{frame}

\begin{frame}
  \frametitle{Execution model}
  \begin{columns}[onlytextwidth]

    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item One thread per data element
        \item Thread scheduled in blocks with barriers (wait for others at the end)
        \item Program runs on the whole data (kernel)
      \end{itemize}
      \begin{itemize}
        \item Minimize synchronization
        \item Balance load
        \item Coalesce memory access
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/cuda}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item GPUs have huge number of cores
    \item Use them to parallelize BFS
    \item One core per vertex, or one core per edge
    \item Vertex-based parallelism creates load imbalance for graphs with skewed degree distribution
    \item Edge-based parallelism requires high memory usage
  \end{itemize}
  \begin{itemize}
    \item Use vertex-based parallelism
    \item Virtualize high-degree vertices to address load imbalance
    \item Reduce memory usage by removing predecessors lists
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Difference}

  \begin{columns}[onlytextwidth]
    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/gpu-vertex-bfs}
        \caption{Vertex-based BFS}
      \end{figure}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/gpu-edge-bfs}
        \caption{Edge-based BFS}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Vertex-based}

  \begin{columns}[onlytextwidth]
    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item For each level, for each vertex in parallel
        \item If vertex is on level
        \item For each neighbor, \\ adjust \pred and \paths
        \item Atomic update on \paths needed (multiple paths can be discovered concurrently)
        \item While backtracking, if $u \in \pred(v)$ accumulate $\dep(u) = \dep(u) + \dep(v)$
        \item Possible load imbalance if degree skewed
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/gpu-algo-vertex}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Edge-based}

  \begin{columns}[onlytextwidth]
    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item For each level, for each edge in parallel
        \item If edge endpoint is on level
        \item Same as above...
        \item While backtracking, if $u \in \pred(v)$ accumulate $\dep(u) = \dep(u) + \dep(v)$ \emph{atomically}
        \item Multiple edges can try to update \dep concurrently
        \item More memory (edge-based layout) and more atomic operations
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/gpu-algo-edge}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Vertex virtualization}

  \begin{columns}[onlytextwidth]
    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item AKA, edge batching, \\ hybrid between vertex- and edge-based
        \item Split high degree vertices into virtual ones with maximum degree $mdeg$
        \item Equivalently, pack up to $mdeg$ edges belonging to the same vertex together
        \item Very small $mdeg = 4$
        \item Need additional auxiliary maps
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/gpu-algo-hybrid}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Benefits}

  \begin{itemize}
    \item Compared to vertex-based:
      \begin{itemize}
        \item Reduce load imbalance
      \end{itemize}
    \item Compared to edge-based:
      \begin{itemize}
        \item Reduce number of atomic operations
        \item Reduce memory footprint
      \end{itemize}
    \item Predecessors stored implicitly in the \spdag level (reduced memory usage)
    \item Memory layout can be further optimized to coalesce latency via \emph{striding}:
      \begin{itemize}
        \item Distribute edges to virtual vertices in round-robin
        \item When accessed in parallel, they create faster sequential memory access pattern
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/gpu-results1}
    \caption{Speedup over Brandes' on CPU on real graphs with 32-core GPU ($s= 1k, \ldots, 100k$)}
  \end{figure}

  \begin{itemize}
    \item Results computed only on a sample of sources and extrapolated linearly
  \end{itemize}
\end{frame}

%\begin{frame}
%  \frametitle{Results}
%
%  \begin{figure}[t]
%    \centering
%    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/gpu-results2}
%    \caption{Speedup over Brandes' on CPU on real graphs with 32-core GPU}
%  \end{figure}
%
%\end{frame}

\subsection{Exact Algorithms for Dynamic Graphs}

%% Green et al.
\begin{frame}
  \centering
  \vfill
  {\huge A Fast Algorithm for Streaming Betweenness Centrality}
  \vfill
  {\Large O. Green, R. McColl, D. A. Bader}
  \vfill
  {\large SocialCom '12: International Conference on Social Computing}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item Make Brandes' algorithm incremental
    \item Keep additional data structures to avoid recomputing partial results
      \begin{itemize}
        \item Rooted \spdag for each source $s \in V$
        \item Depth in the tree for $t$ = distance of $t$ from $s$
      \end{itemize}
    \item Re-run parts of modified Brandes' algorithm on edge update
    \item Support only edge addition (on unweighted graphs)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Data structures}

  \begin{itemize}
    \item One $\spdag_s$ for each source $s \in V$, which contains for each other vertex $t \in V$:
      \begin{itemize}
        \item Distance $\dist_{st}$, paths $\paths_{st}$, dependencies $\dep_{s}(t)$, predecessors $\pred_{s}(t)$
        \item Additional per-level queues for exploration
      \end{itemize}
  \end{itemize}
  \begin{itemize}
    \item On addition of edge $(u,v)$, let $dd = |d_{su} - d_{sv}|$:
      \begin{itemize}
        \item $dd = 0$ same~level
        \item $dd = 1$ adjacent~level
        \item $dd > 1$ non-adjacent~level
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Same level addition}
  \begin{columns}[onlytextwidth]

    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item $dd = 0$
        \item Edge creates no new shortest paths
        \item No change to betweenness \\ due to this source
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/green-0lvl-compressed}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Adjacent level addition}
  \begin{columns}[onlytextwidth]

    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item $dd = 1$
        \item Let $u_{high} = u ,\, u_{low} = v$
        \item Edge creates new shortest paths
        \item \spdag unchanged
        \item Changes in \paths confined to sub-dag rooted in $u_{low}$
        \item Changes in \dep also spread above to decrease old dependency and account for new dependency
        \item Example: $w$ and predecessors have now only $\sfrac{1}{2}$ of dependency on sub-dag rooted in $u_{low}$
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/green-1lvl-compressed}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Algorithm}
  \begin{columns}[onlytextwidth]

    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item During exploration:
          \begin{itemize}
            \item Fix \paths
            \item Mark visited vertices
            \item Enqueue for further processing
          \end{itemize}
      \end{itemize}
    \end{column}
    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item During backtracking:%
          \begin{itemize}
            \item Fix \dep and \betw
            \item Recurse up the whole \spdag
          \end{itemize}
      \end{itemize}
    \end{column}
  \end{columns}
      \begin{figure}[t]
        \centering
        %        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/green-algo}
        \includegraphics[width=0.45\textwidth, height=0.6\textheight, keepaspectratio, valign=t]{imgs/green-algo1}
        \includegraphics[width=0.6\textwidth, height=0.6\textheight, keepaspectratio, valign=t]{imgs/green-algo2}
      \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Non-adjacent level addition}

  \begin{columns}[onlytextwidth]

    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item $dd > 1$
        \item Edge creates new shortest paths
        \item Changes to \spdag (new distances)
        \item Algorithm only sketched \\ (most details missing)
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics<1>[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/green-2lvl-before-compressed}
        \includegraphics<2>[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/green-2lvl-after-compressed}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Complexity}

  \begin{itemize}
    \item Time: $O(n^2 + nm)$ $\leftarrow$ same as Brandes'
    \item In practice, algorithm is much faster
  \end{itemize}
  \begin{itemize}
    \item Space: $O(n^2 + nm)$ $\leftarrow$ higher than Brandes'
    \item For each source, a \spdag of complexity $n + m$
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/green-results1}
    \caption{Speedup over Brandes' on synthetic graphs ($n = 4096$)}
  \end{figure}

\end{frame}

\begin{frame}
  \frametitle{Conclusions}

  \begin{itemize}
    \item Up to 2 orders of magnitude speedup
    \item Super-quadratic space bottleneck
  \end{itemize}

\end{frame}

%% QUBE
\begin{frame}
  \centering
  \vfill
  {\huge QUBE: a Quick algorithm for Updating BEtweenness centrality}
  \vfill
  {\Large M. Lee, J. Lee, J. Park, R. Choi, C. Chung}
  \vfill
  {\large WWW '12: International World Wide Web Conference}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item No need to update all vertices when a new edge is added
    \item Prune vertices whose \betw does not change
    \item Large reduction in all-pairs shortest paths to be re-computed
    \item Support both edge additions and removals
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Minimum Cycle Basis}

  \begin{itemize}
    \item $G=(V,E)$ undirected graph
    \item \emph{Cycle} $C \subseteq E$ s.t. $\forall v \in V$, $v$ incident to even number of edges in $C$
    \item Represented as edge incidence vector $\nu \in \{ 0,1 \}^{|E|}$, where $\nu(e) = 1 \iff e \in C$
    \item \emph{Cycle Basis} = set of linearly independent cycles
    \item \emph{Minimum Cycle Basis} = on weighted graph with non-negative weights $w_e$, cycle basis of minimum total weight $w(C) = \sum_{i} w(C_i)$ where $w(C_i) = \sum_{e \in C_i} w_e$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Minimum Cycle Basis Example}
  \begin{itemize}
    \item Three cycle basis sets: $\{C_1, C_2\} , \{C_1, C_3\} , \{C_2, C_3\}$
    \item If all edges have same weight $w_e = 1$, $MCB = \{C_1, C_2\}$
  \end{itemize}
  \begin{figure}[H]
    \centering
    \includegraphics[scale=2]{imgs/qube-mcb}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Minimum Union Cycle}

  \begin{itemize}
    \item Given a MCB $C$ and minimum cycles $C_i \in C$
    \item Let $V_{C_i}$ be the set of vertices induced by $C_i$
    \item Recursively union two $V_{C_i}$ if they share at least one vertex
    \item The final set of vertices is a \emph{Minimum Union Cycle} $MUC$
  \end{itemize}

  \begin{itemize}
    \item $MUC$s are disjoint sets of vertices
    \item $MUC(v)$ = the $MUC$ which contains vertex $v$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Connection Vertex}

  \begin{itemize}
    \item \emph{Articulation Vertex} = vertex $v$ whose deletion makes the graph disconnected
    \item Biconnected graph = graph with no articulation vertex
    \item Vertex $v$ is an articulation vertex $\iff$ v belongs to two biconnected components
  \end{itemize}

  \begin{itemize}
    \item \emph{Connection Vertex} = vertex $v$ that
      \begin{itemize}
        \item is an articulation vertex
        \item has an edge to vertex $w \not\in MUC(v)$
      \end{itemize}
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Connection Vertex Example}

  \begin{columns}[onlytextwidth]
    \begin{column}{0.5\textwidth}
      \begin{itemize}
        \item If $(v_3, v_4)$ is added, $MUC(v_3) = \{ v_1, v_2, v_3, v_4 \}$
        \item $v_1, v_2, v_3$ are connection vertices of $MUC(v_3)$
        \item Let $G_i$ be the disconnected subgraph generated by removing $v_i$
      \end{itemize}
    \end{column}

    \begin{column}{0.5\textwidth}
      \begin{figure}[t]
        \centering
        \includegraphics[width=\textwidth, height=0.8\textheight, keepaspectratio]{imgs/qube-biconnected}
      \end{figure}
    \end{column}
  \end{columns}

\end{frame}

\begin{frame}
  \frametitle{Finding MUCs}

  \begin{itemize}
    \item Finding an $MCB$ is well studied
    \item Kavitha, Mehlhorn, Michail, Paluch. ``A faster algorithm for minimum cycle basis of graphs''. ICALP 2004
    \item Finding $MUC$ from $MCB$ relatively straightforward (just union sets of vertices)
    \item Also find connection vertices for each $MUC$
    \item All done as a preprocessing step
    \item Need to be updated at runtime
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Updating MUCs -- Addition}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/qube-addition}
  \end{figure}

  \begin{itemize}
    \item Adding $a$ does not affect the $MUC$ (endpoints in the same $MUC$)
    \item Adding $b$ creates a new $MUC$ (endpoints do not belong to a $MUC$)
    \item Adding $c$ merges two $MUC$s (merge $MUC$s of vertices on the \spath between endpoints)
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Updating MUCs -- Removal}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/qube-removal}
  \end{figure}

  \begin{itemize}
    \item Removing $a$ destroys the $MUC$ (cycle is removed $\rightarrow$ no biconnected component)
    \item Removing $b$ does not affect the $MUC$ ($MUC$ is still biconnected)
    \item Removing $c$ splits the $MUC$ in two (single vertex appears in all \spath between endpoints)
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Betweenness Centrality Dependency}

  \begin{itemize}
    \item Only vertexes inside the $MUC$s of the updated endpoints need to be updated
    \item However, recomputing all centralities for the $MUC$ still requires new shortest paths to the rest of the graph
      \begin{itemize}
        \item Shortest paths to vertices outside the $MUC$
        \item Shortest paths that pass through the $MUC$
      \end{itemize}
  \end{itemize}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/qube-btwmuc}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Betweenness Centrality outside the MUC}

  \begin{itemize}
    \item Let $s \in V_{G_j}$, $t \in MUC$,
    \item Let $j \in MUC$ be a connection vertex to subgraph $G_j$
    \item Each vertex in $\spath_{jt}$ is also in $\spath_{st}$
    \item Therefore, betweenness centrality due to vertices outside the $MUC$:
  \end{itemize}

  \begin{align*}
    %\large
    \betw_{o}(v) = \begin{cases}
      \frac{|V_{G_j}|}{\paths_{st}}		& \text{ if } v \in\{ \spath_{jt} \setminus t \} \\
      0 						& \text{ otherwise }
    \end{cases}
  \end{align*}
\end{frame}

\begin{frame}
  \frametitle{Betweenness Centrality trough the MUC}

  \begin{itemize}
    \item Let $s \in V_{G_j}$, $t \in V_{G_k}$,
    \item Let $j \in MUC$ be a connection vertex to subgraph $G_j$
    \item Let $k \in MUC$ be a connection vertex to subgraph $G_k$
    \item Each vertex in $\spath_{jk}$ is also in $\spath_{st}$
    \item Therefore, betweenness centrality due to paths through the $MUC$:
  \end{itemize}

  \begin{align*}
    \betw_{x}(v) = \begin{cases}
      \frac{ |V_{G_j}| |V_{G_k}| }{ \paths_{st} }		& \text{ if } v \in \spath_{jk} \\
      0 						& \text{ otherwise }
    \end{cases}
  \end{align*}

  More caveats apply for subgraphs that are disconnected, as every path that connects vertices in different connected component passes through $v$
\end{frame}

\begin{frame}
  \frametitle{Updating Betweenness Centrality}

  {\Large
    \begin{align*}
      \betw(v) = \betw_{MUC}(v) + \sum_{G_j \subset G} \betw_{o}(v) + \sum_{G_j, G_k \subset G} \betw_{x}(v)
    \end{align*}
  }
\end{frame}

\begin{frame}
  \frametitle{QUBE algorithm}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/qube-algorithm1}
  \end{figure}

  %  \begin{columns}[onlytextwidth]
  %    \begin{column}{0.5\textwidth}
  %      \begin{figure}[t]
  %        \centering
  %        \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/qube-algorithm1}
  %      \end{figure}
  %    \end{column}

  %    \begin{column}{0.5\textwidth}
  %      \begin{figure}[t]
  %        \centering
  %        \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/qube-algorithm2}
  %      \end{figure}
  %    \end{column}
  %  \end{columns}
\end{frame}

\begin{frame}
  \frametitle{QUBE algorithm}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{imgs/qube-algorithm2}
  \end{figure}

\end{frame}

\begin{frame}
  \frametitle{QUBE + Brandes}

  \begin{itemize}
    \item QUBE is a pruning rule that reduces the search space for betweenness recomputation
    \item Can be paired with any existing betweenness algorithm to compute $\betw_{MUC}$
    \item In the experiments, Brandes' is used
    \item Quantities computed by Brandes' (e.g., \paths) reused by QUBE for $\betw_o$ and $\betw_x$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/qube-results1}
    \caption{Update time as a function of the percentage of vertices of the graph in the updated $MUC$ for synthetic Erd\"{o}s-R\'{e}nyi graphs ($n = 5000$)}
  \end{figure}

\end{frame}

\begin{frame}
  \frametitle{Conclusions}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/qube-results2}
  \end{figure}

  \begin{itemize}
    \item Improvement depends highly on structure of the graph (bi-connectedness)
    \item From 2 orders of magnitude (best) to 2 times (worst) faster than Brandes'
  \end{itemize}

\end{frame}

%% Kas et al.
\begin{frame}
  \centering
  \vfill
  {\huge Incremental Algorithm for Updating Betweenness Centrality in Dynamically Growing Networks}
  \vfill
  {\Large M. Kas, M. Wachs, K. M. Carley, L. R. Carley}
  \vfill
  {\large ASONAM '13: International Conference on Advances \\in Social Networks analysis and Mining}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item Extend an existing dynamic all-pairs shortest path algorithm to betweenness
    \item G. Ramalingam and T. Reps, ``\emph{On the Computational Complexity of Incremental Algorithms},'' CS, Univ. of Wisconsin at Madison, Tech. Report 1991
    \item Relevant quantities: number of shortest paths \paths, distances \dist, predecessors \pred
    \item Keep a copy of the old quantities while updating
    \item Support only edge addition (on weighted graphs)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Edge update}

  \begin{itemize}
    \item Compute new shortest paths from updated endpoints $(u,v)$
    \item If a new shortest path of the same length is found, updated number of paths as
  \end{itemize}
  {\Large
    \begin{align*}
      \paths_{st} = \paths_{st} + \paths_{su} \times \paths_{vt}
    \end{align*}
  }
  \begin{itemize}
    \item If a new \emph{shorter} shortest path to any vertex is found, update \dist, clear \paths
    \item Betweenness decreased if new shortest path found
    \item Edge betweenness updates backtrack via DFS over $\pred_s(t)$
  \end{itemize}
  {\Large
    \begin{align*}
      \betw(w) = \betw(w) - \paths_{sw} \times \paths_{wt} / \paths_{st}
    \end{align*}
  }
\end{frame}

\begin{frame}
  \frametitle{Edge update}

  \begin{itemize}
    \item Complex bookkeeping: need to consider all affected vertices which have new alternative shortest paths of equal length (not covered in the original algorithm)
    \item Amend \pred during update propagation $\rightarrow$ concurrent changes to the \spdag
    \item Need to track now-unreachable vertices separately
  \end{itemize}

  \begin{itemize}
    \item After having fixed \dist, \paths, \betw, increase \betw due to new paths
    \item Update needed $\forall s,t \in V$ affected by changes (tracked from previous phase)
    \item Betweenness increase analogous to above decrease
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/kas-results1}
    \caption{Speedup over Brandes' on real-world graphs}
  \end{figure}

  \begin{itemize}
    \item Speedup depends on topological characteristics (e.g., diameter, clust. coeff.)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Comparison with QUBE}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/kas-results2}
    \caption{Speedup over Brandes' in comparison with QUBE}
  \end{figure}

  \begin{itemize}
    \item Datasets from the QUBE paper
    \item About 1 order of magnitude faster than QUBE
  \end{itemize}

\end{frame}

%% Nasre et al.
\begin{frame}
  \centering
  \vfill
  {\huge Betweenness Centrality -- Incremental and Faster}
  \vfill
  {\Large M. Nasre, M. Pontecorvi, V. Ramachandran}
  \vfill
  {\large MFCS '14: Mathematical Foundations of Computer Science}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item Keep \spdag for each vertex
    \item Re-use information from \spdag of updated edge endpoints
    \item Adding new edges will \emph{not} make old edges part of a \spath
    \item Support only edge addition (on weighted graphs)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Main Result}

  %  \begin{figure}[H]
  %    \centering
  %    \includegraphics[width=0.5\textwidth]{imgs/npr14-main-result}
  %  \end{figure}

  \begin{itemize}
    \item Let $\displaystyle E^* = \bigcup_{e \in \allspath} e \subseteq E$ be the set of edges that are part of any shortest path
    \item Let $\displaystyle m^* = |E^*|$ and $\displaystyle \nu^* = \max_{v \in V} |\spdag_v|$ the maximum number of edges in shortest paths through any single vertex $v$
    \item $n < \nu^* < m^* < m$
    \item After incremental update, betweenness can be recomputed in
      \begin{itemize}
        \item $O(\nu^* n)$ time using $O(\nu^* n)$ space
        \item $O(m^* n)$ time using $O(n^2)$ space
      \end{itemize}
    \item Bounded by $O(mn + n^2)$
    \item Logarithmic factor better than Brandes' (on weighted graphs)
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Lemma 1}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, trim={0 8cm 0 0}, clip]{imgs/npr14-lemmas}
  \end{figure}

  \begin{itemize}
    \item Edge $(u,v) \not\in \spath_{xu} \, \wedge \, (u,v)\not\in \spath_{vx}$ as edge weights are positive
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Lemma 2}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, trim={0 0 0 3.5cm}, clip]{imgs/npr14-lemmas}
  \end{figure}

  \begin{itemize}
    \item Updates to \paths and \dist in constant time
    \item Need to update \pred to complete \spdag update
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{\spdag Update}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth]{imgs/npr14-algo3}
  \end{figure}

  \begin{itemize}
    \item UN-changed $\rightarrow dd=0$
    \item NUM-changed $\rightarrow dd=1$
    \item WT-changed $\rightarrow dd>1$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Edge Update}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth]{imgs/npr14-algo4}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Space-Efficient Variant $O(n^2)$}

  \begin{itemize}
    \item Do not store the \spdag
    \item Store only $E^*$
    \item Updated \spdag can be build in $O(m^*)$ time
      \begin{itemize}
        \item Time $O(m^* \, n)$
        \item Compute ${E'}^*$ from $E^*$, then $\spdag'_{s}$ from ${E'}^*$
      \end{itemize}
    \item Space $O(m^* + n^2)$ to store $E^*$ and $n^2$ distances $\dist(s,t)$ and shortest paths $\paths_{st}$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Comparison}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth]{imgs/npr14-comparison}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Conclusions}

  \begin{itemize}
    \item Provably faster than Brandes' on weighted graphs
    \item However $m^*$ can be large in practice
    \item No experiments
    \item Hard to parallelize (need to access pairs of \spdag at a time)
    \item Still has main bottleneck of most algorithms: $O(n^2)$ memory
  \end{itemize}
\end{frame}

%% Sariyuce et al. (incremental closeness)
\begin{frame}
  \centering
  \vfill
  {\huge Incremental Algorithms for Closeness Centrality}
  \vfill
  {\Large A. E. Sar\i y\"uce, K. Kaya, E. Saule, U.~V.~\c{C}ataly\"urek }
  \vfill
  {\large IEEE BigData '13: International Conference on Big Data}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item Algorithm with pruning based on level difference (similar to Green et al.)
    \item Additional pruning by bi-connected decomposition (similar to QUBE)
    \item Applied to closeness centrality (still solves APSP)
    \item Reminder: closeness centrality
    \item $\displaystyle \closeness(v)=\frac{1}{\displaystyle  \sum_{u \in V} d(u,v)}$
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Preliminaries}

  \begin{itemize}
    \item Best static algorithm $O(nm)$ time
  \end{itemize}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/sksc-algo1}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Cases}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth]{imgs/sksc-cases}
  \end{figure}

  \begin{itemize}
    \item Usual cases: $dd=0$, $dd=1$, $dd>1$
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Pruning - level difference}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.7\textheight, keepaspectratio]{imgs/sksc-algo2}
  \end{figure}
\end{frame}

\begin{frame}
  \frametitle{Pruning - biconnected components}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/sksc-biconnected}
  \end{figure}

  \begin{itemize}
    \item If graph has articulation points
    \item Change in $A$ can change closeness of any vertex in $B$
    \item It is enough to compute change for $u$ (constant factor is added for the rest of $B$)
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Maintaining biconnected decomposition}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/sksc-bidecomp}
  \end{figure}

  \begin{itemize}
    \item Assume edge $(b,d)$ added
    \item Similar to QUBE
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{\sssp hybridization}

  \begin{itemize}
    \item BFS can be performed in two ways
    \item \emph{Top-down:} process vertices at distance $d$ to find vertices at distance $d+1$
    \item \emph{Bottom-up:} after vertices at distance $d$ are found, process all unprocessed vertices to see if they are neighbors of the frontier
    \item Top-down is better for initial rounds, bottom-up better for final rounds
    \item Hybridization: use best option at each round
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Fraction of cases}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/sksc-results1}
  \end{figure}

  \begin{itemize}
    \item Probability distribution for level difference $dd$
    \item Most edges are easy cases
  \end{itemize}
\end{frame}

\begin{frame}
  \frametitle{Speedup}

  \begin{figure}[H]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/sksc-results2}
  \end{figure}

  \begin{itemize}
    \item Speedup of 2 orders of magnitude
    \item Mostly due to level pruning
    \item Biconnected decomposition and hybridization also give good speedups
  \end{itemize}
\end{frame}

%% Kourtellis et al.
\begin{frame}
  \centering
  \vfill
  {\huge Scalable Online Betweenness Centrality in Evolving Graphs}
  \vfill
  {\Large N. Kourtellis, G. De-Francisci-Morales, F. Bonchi}
  \vfill
  {\large TKDE: IEEE Transactions on Knowledge and Data Engineering (2015)}
  \frametitle{Scalable Online Betweenness Centrality in Evolving Graphs}
  \vfill
\end{frame}

\begin{frame}
  \frametitle{Intuition}

  \begin{itemize}
    \item Incremental, exact, space-efficient, out-of-core, parallel version of Brandes'
    \item Handles edge addition and removal
    \item Vertex and edge betweenness
    \item Scalable to graphs with millions of vertices
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Algorithm}

  \begin{itemize}
    \item Run a modified Brandes' on the initial graph
    \item Keep track of \dist, \paths, \dep in a \spdag (no \pred)
    \item On edge update, adjust the \spdag and update \betw
  \end{itemize}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/kdb-algo}
  \end{figure}

\end{frame}

\begin{frame}
  \frametitle{Data structure}

  \begin{itemize}
    \item $\spdag_s$ for each source $s \in V$
    \item \spdag contains \dist, \paths, \dep for each other vertex $t \in V$
    \item No predecessors \pred, re-scan neighbors and use \dist to find them
      \begin{itemize}
        \item Save memory - space complexity $O(n^2)$
        \item Fixed size data structure - efficient out-of-core management
        \item Same time complexity $O(nm)$ - in practice, makes the algorithm faster
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Pivot}

  \begin{itemize}
    \item When adding or removing an edge, consider $dd = |d_{su} - d_{sv}|$
    \item Three cases: $dd=0$, $dd=1$, $dd>1$ (analogous to Green et al.)
    \item Last case $dd>1$ hardest - structural changes in \spdag
    \item Find \emph{pivots} to discover structural changes
  \end{itemize}

  \begin{definition}[Pivot]
    Let $s$ be the current source, let $\dist$ and $\dist'$ be the distance before and after an update, respectively, we define \emph{pivot} a vertex $p \mid \dist(s,p) = \dist'(s,p) \wedge \exists \, w \in \neighbors(p)$$: \dist(s,w)$$\neq$$\dist'(s,w)$.
  \end{definition}

  \begin{itemize}
    \item Pivots' distance unchanged $\rightarrow$ use as starting points to correct distances
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Finding pivots}

  \begin{itemize}
    \item Addition - pivots in sub-dag rooted in $u_L = v$
    \item vertices moved closer must be reachable from $u_L$
    \item Can be found during exploration while fixing \paths
  \end{itemize}
  \begin{itemize}
    \item Removal - pivots may be anywhere
    \item Need one exploration to find them
    \item Need separate exploration from found pivots to correct distances
  \end{itemize}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/kdb-bfs}
  \end{figure}

\end{frame}

\begin{frame}
  \frametitle{Structural changes}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.5\textheight, keepaspectratio]{imgs/kdb-cases}
  \end{figure}

  \begin{itemize}
    \item Consider $x \in \neighbors(y)$, $x$ can either be a sibling or a predecessor of $y$
    \item Each case requires slightly different combination of corrections for \dist, \paths, \dep
    \item $y$ is pivot in 1d, 2e, 2f
    \item Removal for case 1d can be optimized (pivot $y$ is sibling of $x$)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Scalability}

  \begin{itemize}
    \item Out-of-core - stream \spdag from disk
      \begin{itemize}
        \item In-place update on disk to minimize writes
      \end{itemize}
    \item Columnar storage for \dist, \paths, \dep
      \begin{itemize}
        \item Read only \dist, skip rest if $dd=0$
      \end{itemize}
    \item Parallelization - coarse grained over $s$
      \begin{itemize}
        \item Implementation in MapReduce
        \item Amenable to Apache Storm/Flink/Spark
      \end{itemize}
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.6\textheight, keepaspectratio]{imgs/kdb-results1}
    \caption{Speedup over Brandes' on synthetic and real graphs ($n = 10k$)}
  \end{figure}

  \begin{itemize}
    \item In-memory (M-) version faster than out-of-core (D-)
    \item Without predecessor (-O) always faster than with predecessors (-P)
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Results}

  \begin{figure}[t]
    \centering
    \includegraphics[width=\textwidth, height=0.3\textheight, keepaspectratio]{imgs/kdb-results21}
    \\ \qquad \quad
    \includegraphics[width=\textwidth, height=0.3\textheight, keepaspectratio]{imgs/kdb-results22}
    \caption{Speedup over Brandes' for out-of-core version on synthetic and real graphs ($n = 1M$)}
  \end{figure}

  \begin{itemize}
    \item Out-of-core version scales up to 1M vertices
    \item Speedup up to 2 orders of magnitude
  \end{itemize}

\end{frame}

\begin{frame}
  \frametitle{Conclusions}

  \begin{itemize}
    \item Fully dynamic (addition and removal)
    \item Algorithm can scale to graphs with realistic size
    \item Ideal horizontal scalability
    \item $O(n^2)$ space bottleneck
  \end{itemize}
\end{frame}


\ifpdf
\graphicspath{{Chapter5/Figs/}}
\else
\graphicspath{{Chapter5/Figs/}}
\fi

\chapter{Contribution 1: A more Efficient Serial Number Signature of Knowledge}
\label{ch:Contribution 1: A more Efficient Serial Number Signature of Knowledge}
\section{Problem with Original SNSoK}
\label{sec:5-Problem with Original SNSoK}
The most problematic NIZK proof out of the three proofs in Zerocoin is the SNSoK as it has the biggest size and takes the longest time to verify. The inefficiency in the SNSoK is mainly due to the proof requiring 80 iterations of the same proof process (\S\ref{sec:3-Serial Number Signature of Knowledge}), which means that 80 sets of proof parameters are generated and verified to in one SNSoK. This differs from the standard scheme of the Fiat-Shamir heuristic, where the verification of the resultant proof only requires a single iteration.

\section{Construction of Proposed SNSoK}
\label{sec:5-Construction of Proposed SNSoK}
This research proposes a more efficient SNSoK that modifies the ZK proof for a committed value in a Pedersen commitment outlined by Hohenberger \cite{Hohenberger2002}. The standard Fiat Shamir Heuristics is used to make the proof non-interactive and the resultant proof can be verified in a single iteration.

The proposed SNSoK starts off in a same way as the original SNSoK. In order to hide the \kwCoin{} $c$ that is being proven, the prover creates a Pedersen commitment $y$ of $c$ using a random trapdoor $z\in\expIntGroup{\varQSok}$, such that $y=\expSoKCoinComm{c}=\expSoKCoinComm{\expPedCommCoin}$. Also, like in the original proof, the SNSoK proves in zero-knowledge that $y$ contains a $c$ that is a commitment of the serial number $S$ and trapdoor $r$ as follows:

$$\eqnSNSoKActual$$

However of the proposed SNSoK does not required 80 $(t,s,s')$ values to be included in the proof. Instead, alluding to the methods by Hohenberger, the prover computes a single $t=\varGSok^{\varGComm^{S}\varHComm^{v_1}}\varHSok^{v_2}$ where $v_1\in\expIntGroup{\varQComm},v_2\in\expIntGroup{\varQSok}$. Following the principle of the Fiat-Shamir heuristics, the prover then computes the challenge string $\varChallenge=H(\expConcatSNSoKImproved)$ which also doubles up as the signature for the transaction contents $m$ (\S\ref{sec:3-Serial Number Signature of Knowledge}). The prover then computes a single $s=\varHComm^{v_1}-\varChallenge\varHComm^{r}$ and $s'=v_2-\varChallenge z$. The prover writes $y,t,s,s'$ and the transaction content $m$ into the \kwTransaction{Spend }{}. Upon receiving the \kwTransaction{Spend }{}, the verifying node recomputes $\varChallenge=H(\expConcatSNSoKImproved)$ using the received $y,t,m$, the serial number $S$ of the \kwCoin{} and the public parameters $\varGSok,\varHSok$. The verifier then verifies the proof by checking $t=y^{\varChallenge}\varGSok^{\varGComm^{S}s}\varHSok^{s'}$.

Since only a single tuple $(t,s,s')$ is included in the proposed SNSoK as opposed to the 80 $(t,s,s')$ in the original SNSoK, the proof size of the proposed SNSoK should be smaller by about 80 times. Similarly, the time needed to verify the proposed SNSoK should also decrease by a similar amount since verification is done in one iteration instead of the 80 iterations in the original SNSoK. The exact improvements in performance brought by the proposed SNSoK is shown in \S\ref{sec:5-Performance of Proposed SNSoK and Future Work}.

\section{Zero-Knowledge Properties of Proposed SNSoK}
\label{sec:5-Zero-Knowledge Properties of Proposed SNSoK}
In order for the proposed SNSoK to be valid, it must satisfy the three ZK properties defined in \S\ref{sec:3-Properties of Zero-Knowledge Proofs}.

\subsection{Completeness}
The completeness property of the improved SNSoK can be shown by demonstrating that the proof produced by an honest prover who knows $S,r,z$ can always to be verified. Hence it suffices to show that the verification equation is correct. To prove that $t=y^{\varChallenge}\varGSok^{\varGComm^{S}s}\varHSok^{s'}$, the equation can be expanded as such:

\begin{equation*}
	\begin{split}
	t &= y^{\varChallenge}\varGSok^{\varGComm^{S}s}\varHSok^{s'} \\
	&= (\expSoKCoinComm{\expPedCommCoin})^{\varChallenge}\varGSok^{\varGComm^{S}(\varHComm^{v_1}-\varChallenge\varHComm^{r})}\varHSok^{v_2-\varChallenge z} \\
	&= \varGSok^{\varChallenge\varGComm^{S}\varHComm^{r}}\varHSok^{\varChallenge z}\varGSok^{\varGComm^{S}\varHComm^{v_1}-\varChallenge\varGComm^{S}\varHComm^{r})}\varHSok^{v_2-\varChallenge z} \\
	&= \varGSok^{\varGComm^{S}\varHComm^{v_1}}\varHSok^{v_2} \\
	&= t
	\end{split}
\end{equation*}

As seen, the verification equation is indeed correct and the proposed SNSoK is complete.

\subsection{Soundness}
The soundness property of improved SNSoK can be shown by demonstrating that a hypothetical knowledge extractor can obtain $c$ and $z$ from two accepting proofs that uses the same $t$ but different $(\varChallenge,s,s')$ (\S\ref{sec:3-Properties of Zero-Knowledge Proofs}). Given these conditions, and let the two different $(\varChallenge,s,s')$ be $(\varChallenge_1,s_1,s'_1)$ and $(\varChallenge_2,s_2,s'_2)$, the following equations be can constructed:

$$t=y^{\varChallenge_1}\varGSok^{\varGComm^{S}s_1}\varHSok^{s'_1}=y^{\varChallenge_2}\varGSok^{\varGComm^{S}s_2}\varHSok^{s'_2}$$

Hence it can be derived that:

\begin{align*}
y^{\varChallenge_{1}}\varGSok^{\varGComm^{S}s_{1}}\varHSok^{s'_{1}} &= y^{\varChallenge_{2}}\varGSok^{\varGComm^{S}s_{2}}\varHSok^{s'_{2}} \\
y^{\varChallenge_{1}-\varChallenge_{2}} &= \varGSok^{\varGComm^{S}(s_{2}-s_{1})}\varHSok^{s'_{2}-s'_{1}} \\
y &= \varGSok^{\frac{\varGComm^{S}(s_2-s_1)}{\varChallenge_1-\varChallenge_2}}\varHSok^{\frac{s'_2-s'_1}{\varChallenge_1-\varChallenge_2}}
\end{align*}

Since $y=\expSoKCoinComm{c}$, the knowledge extractor can successfully determine that $c=\frac{\varGComm^{S}(s_2-s_1)}{\varChallenge_1-\varChallenge_2}$ and $z=\frac{s'_2-s'_1}{\varChallenge_1-\varChallenge_2}$. Hence the success of the knowledge extractor in extracting the secret \kwCoin{} $c$ and the secret trapdoor $z$ shows that the proposed proof is sound.

\subsection{Statistical Zero-Knowledge}
The statistical zero-knowledge property of the improved SNSoK can be shown by demonstrating that a hypothetical simulator can generate $s$ and $s'$ that are statistically indistinguishable from the $s$ and $s'$ generated by the prover (\S\ref{sec:3-Properties of Zero-Knowledge Proofs}).

Firstly it can be shown that the $s$ and $s'$ generated by the prover are random numbers. Since $\varHComm$ is the generator for the subgroup of order $\varQComm$, $\varHComm^{x}$ produces all element in the subgroup exactly once for $x$ from 1 to $\varQComm$. Thus there is a one-to-one mapping between $v_1$ and $\varHComm^{v_1}$ and since $v_1\in\expIntGroup{\varQComm}$ and $v_1$ is random, $\varHComm^{v_1}$ is also random. As a random number added with a constant still produces a random number, $s=\varHComm^{v_1}-\varChallenge\varHComm^{r}$ is also random. Similarly, since $v_2$ is random, $s'=v_2-\varChallenge z$ is also random.

As such the simulator can be just a random number generator that produces random numbers $s\in\expIntGroup{\varQComm}$ and $s'\in\expIntGroup{\varQSok}$. Since the $s$ and $s'$ produced by the simulator and the $s$ and $s'$ produced by the prover are both uniformly distributed, they are statistically indistinguishable. Hence the proposed SNSoK achieves statistical zero-knowledge.

\section{Performance of Proposed SNSoK and Future Work}
\label{sec:5-Performance of Proposed SNSoK and Future Work}
The performance of the proposed SNSoK is measured using some basic performance metrics defined in \S\ref{sec:4-Performance Metrics and Benchmarks}. The results are shown in Table~\ref{tab:SNSoK_improvement_performance}.

\begin{table}[H]
	\centering
	\begin{tabular}{ l | c | c }
		\multirow{2}{*}{} & \multicolumn{2}{c}{\textit{Average over 50 iterations}} \\
		& \textbf{Proposed} & \textbf{Original} \\
		\hline
		\hline
		Size of one SNSoK & 390 bytes & 17,420 bytes \\
		\hline
		Verification time of one SNSoK & 1.8ms & 163ms \\
		\hline
	\end{tabular}
	\caption{Performance of proposed SNSoK using basic performance metrics}
	\label{tab:SNSoK_improvement_performance}
\end{table}

As seen, the proposed SNSoK has drastically reduced the verification time and size of one SNSoK. The verification time is reduced by about 80 times. This is within expectation as the proposed SNSoK essentially reduces the 80 iterations required for each verification to one iteration. The size of the SNSoK is reduced by about 44 times. While this is a huge improvement, it does not match up to expectations as the proposed SNSoK should have reduced the size of the proof by 80 times since it reduces the 80 sets of proof parameters $(t,s,s')$ to just a single set.

The original SNSoK is smaller than expected because it has been optimised. The idea of the original SNSoK is the same as the standard NIZK proof, where the verifier test whether the $t$ sent by the prover equals to the one that it computes using the response $s$ from the prover and the challenge $\varChallenge$. Specifically the verifier of the original SNSoK checks for the equality between the received $t$ and the $t'$ computed based on the received $s_i,s'_i,\varChallenge$ (\S\ref{sec:3-Serial Number Signature of Knowledge}). However, the verifier in the original SNSoK does not check for this equality directly. Since the $\varChallenge$ sent by the prover is a hash that contains of all the $t_i$ (\S\ref{sec:3-Serial Number Signature of Knowledge}), the verifier simply checks that the $\varChallenge'$ obtained by hashing all the $t'_i$ equals to $\varChallenge$. Under this scheme, a single 256 bits $\varChallenge$ is included in the proof instead of the 80 1024 bits $t_i$, resulting in a much smaller proof size. Currently, the proposed SNSoK does not make use of this optimisation and includes $t$ in the proof. However such optimisation is likely to be applicable to the proposed SNSoK and will be explored in the subsequent phase of the research.

The tests conducted to evaluate the proposed SNSoK are still preliminary. This research has yet to show the effects of the proposed SNSoK on the Zerocoin network. Going forward, the research will conduct experiments to examine the performance of the original and the improved Zerocoin protocol on a network level using the performance metrics outlined in \S\ref{sec:4-Performance Metrics and Benchmarks}.


\subsection{String resonance angular distributoon}

\begin{figure}[htb]
\begin{center}
\includegraphics[width=0.45\linewidth]{../figures/strings/angle_gg_gg}
\includegraphics[width=0.45\linewidth]{../figures/strings/angle_qq-bar_gg}
\includegraphics[width=0.45\linewidth]{../figures/strings/angle_gq_gq}
\includegraphics[width=0.45\linewidth]{../figures/strings/angle_gg_qq-bar}
\end{center}
\caption{Angular distribution of the outgoing partons from string
resonances in the centre of mass system:
(top-left) $gg\to gg$,
(top-right) $q\bar{q}\to gg$,
(bottom-left) $gq\to gq$,
(bottom-right) $gg\to q\bar{q}$.}
\label{fig:stringangle}
\end{figure}

The string resonance consist of a combination excited quark, excited
gluon, and colour singlet states, depending on the subprocess.
In choosing the $y^*$ cut it is useful to examine the decay angular
distributions.
Figure~\ref{fig:stringangle} shows the angular distribution of the outgoing partons
in the center of mass system for four different string resonance
subprocesses.
The case of string scale $\Ms = 8$~TeV is shown but the distributions
are similar for the other generated string scales.
The angular distribution for the process $g\bar{q}\to g\bar{q}$ (not
shown) is similar to $gq\to gq$.
The red curves show the calculated angular distributions for a string
mass equal to \Ms.


\documentclass{slnotes}
\newcommand*{\slbx}[1]{{\ifmmode\smash{\boxed{#1\vphantom{X}}}\else\smash{\fbox{#1\vphantom{X}}}\fi}}
\newcommand*{\ve}[1]{\mathbf{#1}}
\newcommand*\cve[3][]{\begin{pmatrix}\ifx\relax#1\relax\else#1\\\fi#2\\#3\end{pmatrix}}
\newcommand*{\im}{\mathrm{i}}
\DeclareMathOperator*{\Prb}{P}
\DeclareMathOperator*{\Pois}{Po}
\DeclareMathOperator*{\Binom}{B}
\DeclareMathOperator*{\Norm}{N}
\DeclareMathOperator*{\Exp}{E}
\DeclareMathOperator*{\Var}{Var}
\begin{document}
\chapter{Functions}
A relation \(f \colon X \to Y\) where \(X, Y \subseteq \mathbb R\) is a function if, \(\mathrel\forall a \in X\), the vertical line \(x = a\) cuts the graph of \(f\) at exactly one point.

A relation \(f\) can be proven to be not a function if there is some \(a \in X\) for which the vertical line \(x = a\) cuts the graph of \(f\) zero times or more than once.

A function \(f\) is one-one if, \(\mathrel\forall a \in \mathbb R\), the horizontal line \(y = a\) cuts the graph of \(f\) at most once.

A function \(f\) can be proven to be not one-one if there is some \(a \in \mathbb R\) for which the horizontal line \(y = a\) cuts the graph of \(f\) more than once.
\chapter{APGP}
For a series \(S_n\), the \(n\)th term of the corresponding progression \[T_n = S_n - S_{n-1}\]

For an arithmetic progression \(T_n\) and an arithmetic series \(S_n\) the \(n\)th term \begin{align*}T_n &= a + (n-1)d\\S_n &= \frac{n}{2}(a + l)\\&= \frac{n}{2}(2a+(n-1)d)\end{align*} where \(a\) is the first term, \(l\) is the last term and \(d\) is the common difference. To prove that a series \(S_n\) is an arithmetic series, \[T_n - T_{n-1}\text{ is a constant} \iff S_n\text{ is an arithmetic series}\]

For a geometric progression \(T_n\) and a geometric series \(S_n\) the \(n\)th term \begin{align*}T_n &= ar^{n-1}\\S_n &= a\frac{r^n-1}{r-1}\end{align*} where \(a\) is the first term and \(r\) is the common ratio. To prove that a series \(S_n\) is a geometric series, \[\frac{T_n}{T_{n-1}}\text{ is a constant} \iff S_n\text{ is a geometric series}\]

For a geometric progression with \(|r| < 1\) the sum to infinity \[S_\infty = \frac{a}{1-r}\]
\chapter{Induction format}
Let \(P_n\) be the statement \(\slbx{\text{LHS}} = \slbx{\text{RHS}}\text{, }n \in \slbx{X}\).

\begin{tabbing}
When \(n = \slbx{n}\), \=\(\text{LHS} = \slbx{\text{LHS}} = \slbx{\text{LHS value}}\).\\
\>\(\text{RHS} = \slbx{\text{RHS}} = \slbx{\text{RHS value}} = \text{LHS}\).\\
\>\(\mathrel\therefore P_\slbx{n}\text{ is true.}\)\\
\end{tabbing}

Assume \(P_k\) is true for some \(k \in \slbx{X}\) i.e. \(\slbx{\text{LHS}} = \slbx{\text{RHS}}\).

To prove \(P_{k+1}\) is also true i.e. \(\slbx{\text{LHS}} = \slbx{\text{RHS}}\) \begin{align*}\text{LHS} &= \slbx{\text{LHS}} = \cdots\\&= \slbx{\text{RHS}} = \text{RHS}\end{align*} \(\mathrel\therefore P_k\text{ is true} \implies P_{k+1}\text{ is true}\).

Since \(P_\slbx{n}\) is true, and \(P_k\text{ is true} \implies P_{k+1}\text{ is true}\), by mathematical induction, \(P_n\text{ is true}\mathrel\forall n \in \slbx{\mathrm X}\).
\chapter{Vectors}
Let there be two points \(A\) and \(B\) which have position vectors \(\ve a\) and \(\ve b\).

For the vectors \(\ve a\) and \(\ve b\), their dot product where \(\theta\) is the angle between them \begin{align*}\ve a \cdot \ve b &= |\ve a||\ve b|\cos\theta\\&=\cve[x_{\ve a}]{y_{\ve a}}{\vdots} \cdot \cve[x_{\ve b}]{y_{\ve b}}{\vdots} = x_{\ve a}x_{\ve b} + y_{\ve a}y_{\ve b} + \cdots\end{align*}

Their cross product where \(\theta\) is the angle between them and \(\ve{\hat n}\) is a unit vector perpendicular to both in the direction of a right-handed screw turned from \(\ve a\) to \(\ve b\) \begin{align*}\ve a \times \ve b &= \ve{\hat n}|\ve a||\ve b|\sin\theta\\&= \cve[x_{\ve a}]{y_{\ve a}}{z_{\ve a}} \times \cve[x_{\ve b}]{y_{\ve b}}{z_{\ve b}} = \cve[y_{\ve a}z_{\ve b} - y_{\ve b}z_{\ve a}]{z_{\ve a}x_{\ve b} - z_{\ve b}x_{\ve a}}{x_{\ve a}y_{\ve b} - x_{\ve b}y_{\ve a}}\end{align*}

From the above definitions \begin{align*}\ve a \mathrel\bot \ve b &\iff \ve a \cdot \ve b = 0\\\ve a \parallel \ve b &\iff \mathrel\exists \lambda \in (\mathbb{R} \setminus \{0\}): \ve b = \lambda\ve a\end{align*}

The angle between the vectors \[\theta = \cos^{-1}\frac{\ve a \cdot \ve b}{|\ve a||\ve b|}\]

The length of projection and the projection vector of \(\ve a\) onto \(\ve b\) where \(F\) is the foot of the perpendicular from \(A\) to \(OB\)\begin{align*}OF &= |\ve a \cdot \ve{\hat b}|\\\overrightarrow{OF} &= (\ve a \cdot \ve{\hat b})\ve{\hat b}\end{align*} The perpendicular distance from \(A\) to \(OB\) \[AF = |\ve a \times \ve{\hat b}|\]

A vector normal to \(\ve a\) and \(\ve b\) is simply \(\ve a \times \ve b\).

If \(ABCD\) is a parallelogram then \begin{align*}\text{area of }ABD &= \frac{1}{2}\left|\overrightarrow{AB} \times \overrightarrow{AD}\right|\\\text{area of }ABCD &=  \left|\overrightarrow{AB} \times \overrightarrow{AD}\right|\end{align*}

For three points \(A\), \(B\) and \(C\), {\jot0pt\begin{multline*}A\text{, }B\text{ and }C\text{ are collinear}\\\iff \mathrel\exists\lambda\in(\mathbb R \setminus \{0\}): \overrightarrow{AB} = \lambda\overrightarrow{AC}\end{multline*}}

The general equation of a line is \[\ve r = \ve a + \lambda\ve d\quad\lambda\in\mathbb R\] where \(\ve d\) is the direction vector of the line.

The parametric equation of a plane is \[\ve r = \ve a + \lambda\ve m_1 + \mu\ve m_2\quad\lambda,\mu\in\mathbb R\] The vector equation of the same plane is \[\ve r \cdot \ve n = D\quad D = \ve a \cdot \ve n\] The cartesian equation of the plane is \[\ve r = \cve[x]{y}{z} \wedge \ve a = \cve[a]{b}{c} \implies ax+by+cz = D\]
\chapter{Complex Numbers}
For a complex number \begin{align*}z &= x + \im y\\&= |z|(\cos(\arg z) + \im\sin(\arg z)) \\&= |z|e^{\im(\arg z)}\end{align*} its conjugate and magnitude \begin{align*}z^* &= x - \im y\\zz^* &= |z|^2 = x^2 + y^2 \implies |z| = \sqrt{x^2+y^2}\end{align*} and its argument \[\arg z = \begin{cases}\tan^{-1} \frac{y}{x} & x > 0\\\pi + \tan^{-1} \frac{y}{x} & x < 0 \wedge y \geq 0\\-\pi + \tan^{-1} \frac{y}{x} & x < 0 \wedge y < 0\end{cases}\]

The properties of the argument \(\arg z\) are identical to the properties of the logarithm.

If a polynomial with real coefficients has complex root \(\alpha\), then \(\alpha^*\) is also a root.

The fundamental theorem of algebra states that every polynomial equation of degree \(n\) has \(n\) roots that may not be distinct.
\chapter{Probability}
Some useful results are \begin{gather*}\Prb(A') = 1-\Prb(A)\\\Prb(A\cup B) = \Prb(A) + \Prb(B) - \Prb(A \cap B)\\\Prb(A | B) = \frac{\Prb(A \cap B)}{\Prb(B)}\end{gather*}

If \(A\) and \(B\) are independent events then \[\Prb(A|B) = \Prb(A) \wedge \Prb(B|A) = \Prb(B) \wedge \Prb(A\cap B) = \Prb(A)\Prb(B)\]

If \(A\) and \(B\) are mutually exclusive events then \[\Prb(A\cap B) = 0 \wedge \Prb(A \cup B) = \Prb(A) + \Prb(B)\]
\chapter{Distributions}
For an random variable to be modelled by a binomial distribution, it must have \begin{slinenum}
\item a fixed number of trials
\item independent trials
\item identical trials
\item the same probability of success for each trial
\item two possible outcomes.
\end{slinenum}

For an event to be modelled by a Poisson distribution, it must \begin{slinenum}
\item occur at a constant average rate
\item occur singly
\item have independent occurrences.
\end{slinenum}

For an event \(X\) \begin{gather*}X \sim \Norm(\mu, \sigma^2) \implies Z = \frac{X-\mu}{\sigma} \sim\Norm(0, 1)\\\Prb(X \leq x) = \Prb(Z \leq \frac{x- \mu}{\sigma})\end{gather*}
\chapter{Expectation and Variance}
The expected value of a random variable is the prob\-ability-weighted average of all possible values: \[\Exp(X) = \sum x \Prb(X = x) = \int_{-\infty}^\infty xf(x)\slid x\] where \(f(x)\) is the probability density function of weighing \(X\), if it is a continuous random variable..

If \(X\) and \(Y\) are independent random variables, \(X_1\) and \(X_2\) are independent observations of \(X\), and \(a\) and \(b\) are constants then \begin{align*}\Exp(a) &= a\\\Exp(aX + bY) &= a\Exp(X) + b\Exp(Y)\\\Var(a) &= 0\\\Var(aX + bY) &= a^2\Var(X) + b^2\Var(Y)\\\Var(X_1 + X_2) &= \Var(X_1) + \Var(X_2) = 2\Var(X)\end{align*}
\chapter{Approximations}
If \(X\) is a random discrete variable such that \[X \sim \Binom(n, p)\] then if \(n\) is large and \(p\) is small such that \(np < 5\), \[X \sim \Pois(np)\text{ approximately}\]

If \(X\) is a random discrete variable such that \[X \sim \Binom(n, p)\] then if \(n\) is large such that \(np > 5 \wedge nq > 5\), \[X \sim \Norm(np,npq)\text{ approximately}\]

If \(X\) is a random discrete variable such that \[X \sim \Pois(\lambda)\] then if \(\lambda > 10\), \[X \sim \Norm(\lambda,\lambda)\text{ approximately}\]

When a normal distribution is used to approximate a discrete distribution, continuity correction must be done.
\chapter{Sampling}
If \(X\) is a random variable with unknown or non-normal distribution where \[\Exp(X) = \mu\text{ and }\Var(X) = \sigma^2\] central limit theorem states that if sample size \(n\) is large, \[\overline{X} \sim \Norm(\mu,\frac{\sigma^2}{n})\text{ approximately}\]

Unbiased estimates of \(\mu\) and \(\sigma^2\) are sample mean \(\overline{x}\) and \(s^2\) respectively. \[s^2 = \frac{n}{n-1}(\text{sample variance})\]
\chapter{Hypothesis Testing}
\section{Format}
Let \(X\) be the \slbx{something} of a randomly chosen \slbx{thing}.

Let \(\mu\) be the population mean \slbx{something} of \slbx{things}.

{\fboxsep=3pt\fbox{\begin{varwidth}{0.5\textwidth}\begin{tabbing}
\textbf{One of} \=Given \(X \sim \Norm(\mu, \sigma^2)\),\\
\textbf{or}\>Assume \(X \sim \Norm(\mu, \sigma^2)\),\\
\textbf{or}\>Since \(n = \slbx{n}\), by central limit theorem,\end{tabbing}\end{varwidth}}}
\[\overline{X} \sim \Norm\left(\mu, \frac{\sigma^2}{n}\right)\ \slbx{\text{approximately}}\]

\textbf{H}\textsubscript0: \(\mu = \mu_0\); \textbf{H}\textsubscript1: \slbx{\(\mu < \mu_0\) \textbf{or} \(\mu > \mu_0\) \textbf{or} \(\mu \neq \mu_0\)}

Test statistic:

{\fboxsep=3pt\fbox{\begin{varwidth}{0.5\textwidth}\begin{tabbing}
\textbf{One of} \=\(T = \dfrac{\overline{X}-\mu}{S/\sqrt{n}} \sim t_{n-1}\)\\\\
\textbf{or}\>\(Z = \dfrac{\overline{X}-\mu}{\sigma/\sqrt{n}}\)\\\\
\textbf{or}\>\(Z = \dfrac{\overline{X}-\mu}{S/\sqrt{n}}\)\end{tabbing}\end{varwidth}}}

Level of significance: \slbx{\(100\alpha\%\)}; reject H\textsubscript0 if p-value < \slbx{\(\alpha\)}.

Under H\textsubscript0, p-value = \slbx{p-value}.

Since p-value = \slbx{p-value} \slbx{\(<\) \textbf{or} \(>\)} \(\alpha\), we \slbx{do not} reject H\textsubscript0 and conclude that there is \slbx{in}sufficient evidence, at \slbx{\(100\alpha\%\)} level, that \slbx{H\textsubscript1}.
\section{Definitions}
If the level of significance is \(100\alpha\%\), there is a probability of \(\alpha\) of concluding that H\textsubscript1 is true when in fact, H\textsubscript0 is true.

The p-value is the probability of obtaining a sample mean \textbf(less than or equal to \textbf{or} more than or equal to \textbf{or} as extreme or more extreme than\textbf) \(\overline{x}\), assuming H\textsubscript0 is true.
\chapter{Sampling Methods}
A population is a collection of individuals or objects from which we may collect data.

A random sample is a small representative of the population in which every member in the population has an equal probability of being selected.

We often take a sample instead of collecting data from the entire population as \begin{slinenumor}
\item it may be too costly or time consuming to collect the information from the whole population
\item the population may be infinite or too large.
\end{slinenumor}
\section{Quota sampling}
To take a quota sample, we \begin{slinenum}
\item divide the population into mutually exclusive subgroups called strata, namely \slbx{group} and \slbx{group}
\item select \slbx{number} \slbx{group} and \slbx{number} \slbx{group} to form the sample. The sample from each stratum is non-random.
\end{slinenum}

Quota sampling is advantageous as \begin{slinenum}
\item it is easy to select the sample and administer the survey
\item no sampling frame needed
\item it incurs low cost.
\end{slinenum}

However, it is bad in that \begin{slinenum}
\item the sample obtained is non-random
\item it is likely to result in selection bias as interviewer may select those who are easier to interview.
\end{slinenum}
\section{Simple random sampling}
To take a simple random sample, we \begin{slinenum}
\item obtain the list of \slbx{samplees} and number all \slbx{samplees} from 1 to \slbx{number}
\item use a random number generator to randomly select \slbx{number} numbers
\item select the \slbx{samplees} corresponding to the numbers to form the sample.
\end{slinenum}

Simple random sampling is advantageous as \begin{slinenum}
\item the data collected generally free from bias
\item analysis of data is relatively easy.
\end{slinenum}

However, it is bad in that \begin{slinenum}
\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population
\item it may be difficult to get access to members who have been chosen for the sample
\end{slinenum}
\section{Systematic sampling}
To take a systematic sample, we \begin{slinenum}
\item obtain the list of \slbx{samplees} and number all \slbx{samplees} from 1 to \slbx{number}
\item compute the sampling interval \(k = \slbx{\text{calculation}}\)
\item randomly select an integer from 1 to \slbx{number} as the start
\item select every \slbx{\(k\)}th member of the population thereafter until the sample of \slbx{number} is obtained.
\end{slinenum}

Systematic sampling is advantageous as \begin{slinenum}
\item the data collected is generally free from bias
\item analysis of data is relatively easy.
\end{slinenum}

However, it is bad in that \begin{slinenum}
\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population
\item it may be difficult to get access to members who have been chosen for the sample
\item there may be selection bias if the members of the population is arranged in a periodic or cyclic pattern.
\end{slinenum}
\section{Stratified sampling}
To take a stratified sample, we \begin{slinenum}
\item obtain the list of \slbx{samplees} and divide the population into mutually exclusive subgroups called strata, namely \slbx{group} and \slbx{group}
\item calculate the sample size that should be taken for each stratum, proportional to their size i.e. \(\slbx{\text{calculation}} = \slbx{\text{number}}\) for \slbx{group}, and \slbx{number} for \slbx{group}
\item select the sample from each stratum using simple random sampling.
\end{slinenum}

Stratified sampling is advantageous as \begin{slinenum}
\item it is more likely to give a good representative sample of the population
\item when there are clear strata present, it usually gives more reliable estimates of the population parameters than random or systematic sampling.
\end{slinenum}

However, it is bad in that \begin{slinenum}
\item it may be difficult to draw up the sampling frame as it is difficult to identify every member of the population
\item it is more difficult to conduct than random sampling
\item it may be difficult to identify appropriate strata
\item strata may not be clearly defined.
\end{slinenum}
\end{document}


\subsection{Spline basis sets}
\label{sec:spo_spline}
In this section we describe the use of spline basis sets to expand the \texttt{sposet}.
Spline basis sets are designed to work seamlessly with plane wave DFT code, e.g.\ Quantum ESPRESSO as a trial wavefunction generator.

In QMC algorithms, all the SPOs $\{\phi(\vec{r})\}$ need to be updated every time a single electron moves.
Evaluating SPOs takes very large portion of computation time.
In principle, PW basis set can be used to express SPOs directly in QMC like in DFT.
but it introduces an unfavorable scaling due to the fact
that the basis set size increases linearly as the system size.
For this reason, it is efficient to use a localized basis with compact
support and a good transferability from plane wave basis.

In particular, 3D tricubic B-splines provide a basis in which only
64 elements are nonzero at any given point in space~\cite{blips4QMC}.
The one-dimensional cubic B-spline is given by,
\begin{equation}
f(x) = \sum_{i'=i-1}^{i+2} b^{i'\!,3}(x)\,\,  p_{i'},
\label{eq:SplineFunc}
\end{equation}
where $b^{i}(x)$ are the piecewise cubic polynomial basis functions
and $i = \text{floor}(\Delta^{-1} x)$ is the index of
the first grid point $\le x$.  Constructing a tensor product in each Cartesian
direction, we can represent a 3D orbital as
\begin{equation}
  \phi_n(x,y,z) =
  \!\!\!\!\sum_{i'=i-1}^{i+2} \!\! b_x^{i'\!,3}(x)
  \!\!\!\!\sum_{j'=j-1}^{j+2} \!\! b_y^{j'\!,3}(y)
  \!\!\!\!\sum_{k'=k-1}^{k+2} \!\! b_z^{k'\!,3}(z) \,\, p_{i', j', k',n}.
\label{eq:TricubicValue}
\end{equation}
This allows the rapid evaluation of each orbital in constant time.
Furthermore, this basis is systematically improvable with a single spacing
parameter, so that accuracy is not compromised compared with plane wave basis.

The use of 3D tricubic B-splines greatly improves the computational efficiency.
The gain in computation time from plane wave basis set to an equivalent B-spline basis set
becomes increasingly large as the system size grows.
On the downside, this computational efficiency comes at
the expense of increased memory use, which is easily overcome by the large
aggregate memory available per node through OpenMP/MPI hybrid QMC.

The input xml block for the spline SPOs is give in Listing~\ref{listing:splineSPOs}. A list of options is given in
Table~\ref{table:splineSPOs}. \texttt{QMCPACK} has a very useful command line option \texttt{--save\_wfs} which allows to dump
the real space B-spline coefficient table into a h5 file on the disk.
When the orbital transformation from k space to B-spline requires more than available amount of scratch memory on the compute nodes,
users can perform this step on fat nodes and transfer back the h5 file for QMC calculations.

\begin{table}[h]
\begin{center}
\begin{tabularx}{\textwidth}{l l l l l l }
\hline
\multicolumn{6}{l}{\texttt{determinantset} element} \\
\hline
\multicolumn{2}{l}{parent elements:} & \multicolumn{4}{l}{\texttt{wavefunction}}\\
\multicolumn{2}{l}{child  elements:} & \multicolumn{4}{l}{\texttt{slaterdeterminant}}\\
\multicolumn{2}{l}{attribute      :} & \multicolumn{4}{l}{}\\
   &   \bfseries name                   & \bfseries datatype & \bfseries values & \bfseries default & \bfseries description \\
   &   \texttt{type}                    &  text              &   bspline        &                   &  Type of \texttt{sposet}. \\
   &   \texttt{href}                    &  text              &                  &                   &  Path to the h5 file made by pw2qmcpack.x. \\
   &   \texttt{tilematrix}              &  9 integers        &                  &                   &  Tiling matrix used to expand supercell. \\
   &   \texttt{twistnum}                &  integer           &                  &                   &  Index of the super twist. \\
   &   \texttt{twist}                   &  3 floats          &                  &                   &  Super twist. \\
   &   \texttt{meshfactor}              &  float             &  $\le 1.0$       &                   &  Grid spacing ratio. \\
   &   \texttt{precision}               &  text              &  single/double   &                   &  Precision of spline coefficients. \\
   &   \texttt{gpu}                     &  text              &  yes/no          &                   &  GPU switch. \\
   &   \texttt{Spline\_Size\_Limit\_MB} &  integer           &                  &                   &  Limit B-spline table size on GPU. \\
   &   \texttt{check\_orb\_norm}        &  text              &  yes/no          &  yes              &  Check norms of orbitals from h5 file. \\
   &   \texttt{source}                  &  text              &  \textit{any}    &  ion0             &  Particle set with atomic positions. \\
  \hline
\end{tabularx}
\end{center}
\caption{Options for the \texttt{determinantset} xml-block associated with B-spline single particle orbital sets.}
\label{table:splineSPOs}
\end{table}

%%\begin{lstlisting}[caption=.]
%%<sposet_builder type="bspline" href="pwscf.h5" tilematrix="2 0 0 0 2 0 0 0 2" twistnum="0"
%%                 source="i" meshfactor="1.0" precision="float" truncate="no">
%%   <sposet type="bspline" name="spo_ud" size="208" spindataset="0"/>
%%</sposet_builder>
%%<determinantset>
%%   <slaterdeterminant>
%%      <determinant id="updet" group="u" sposet="spo_ud" size="208"/>
%%      <determinant id="downdet" group="d" sposet="spo_ud" size="208"/>
%%   </slaterdeterminant>
%%</determinantset>
%%\end{lstlisting}

\begin{lstlisting}[caption=Determinant set XML element.\label{listing:splineSPOs}]
<determinantset type="bspline" source="i" href="pwscf.h5"
                tilematrix="1 1 3 1 2 -1 -2 1 0" twistnum="-1" gpu="yes" meshfactor="0.8"
                twist="0  0  0" precision="double">
  <slaterdeterminant>
    <determinant id="updet" size="208">
      <occupation mode="ground" spindataset="0">
      </occupation>
    </determinant>
    <determinant id="downdet" size="208">
      <occupation mode="ground" spindataset="0">
      </occupation>
    </determinant>
  </slaterdeterminant>
</determinantset>
\end{lstlisting}

Additional information:
\begin{itemize}
\item \texttt{precision}. Only effective on CPU version without mixed precision, `single' is always imposed with mixed precision. Using single precision not only saves memory usage but also speeds up the B-spline evaluation. It is recommended to use single precision since we saw little chance of really compromising the accuracy of calculation.
\item \texttt{meshfactor}. It is the ratio of actual grid spacing of B-splines used in QMC calculation with respect to the original one calculated from h5. Smaller meshfactor saves memory usage but reduces accuracy. The effects are similar to reducing plane wave cutoff in DFT calculation. Use with caution!
\item \texttt{twistnum}. If positive, it is the index. It is recommended not to take this way since the indexing may show some uncertainty. If negative, the super twist is referred by \texttt{twist}.
\item \texttt{Spline\_Size\_Limit\_MB}. Allows to distribute the B-spline coefficient table between the host and GPU memory. The compute kernels access host memory via zero-copy. Though the performance penaty introduced by it is significant but allows large calculations to go.
\end{itemize}