\documentclass[12pt]{article}

\usepackage{amsmath, amsthm}
\usepackage{amssymb}

\usepackage{xcolor}

%\usepackage[textheight=8.5in, margin=1.6in]{geometry}
\usepackage[total={6in,8in}]{geometry}

\usepackage{tikz}
%\usepackage{pgfplots}
\tikzstyle{ball} = [circle,shading=ball, ball color=black,
    minimum size=1mm,inner sep=1.3pt]
%\usetikzlibrary{arrows.meta}
%\tikzset{>={Latex[length=2mm,width=1.5mm]}}

%\usepackage{graphicx}

\usepackage{needspace}  % <-- to prevent bad pagebreak over environment titles
% Use:  \Needspace{3\baselineskip} before opening an environment

\usepackage{enumitem}
\setlist[enumerate]{leftmargin=*}

\allowdisplaybreaks

%\usepackage[colorlinks=true,citecolor=black,linkcolor=black,urlcolor=blue]{hyperref}

\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\sn}{\mathfrak{S}}
\newcommand{\ve}{\varepsilon}
\newcommand{\ips}[2]{\langle{#1}, {#2}\rangle}
\DeclareMathOperator{\tr}{tr}
\DeclareMathOperator{\Span}{\mathrm{Span}}
\DeclareMathOperator{\rk}{\mathrm{rank}}
\DeclareMathOperator{\trace}{\mathrm{tr}}
\DeclareMathOperator{\im}{\mathrm{im}}
\DeclareMathOperator{\Sym}{\mathrm{Sym}}
\DeclareMathOperator{\Hom}{\mathrm{Hom}}
\DeclareMathOperator{\diag}{\mathrm{diag}}
\DeclareMathOperator{\glb}{\mathrm{glb}}
\DeclareMathOperator{\lub}{\mathrm{lub}}
\DeclareMathOperator{\wt}{\mathrm{wt}}

\parskip = 0.05in
\parindent = 0.0in

%\pagestyle{empty}

\begin{document}
\centerline{Math 372 lecture for Friday, Week 1}
\bigskip

Let~$G$ be any simple graph with vertices~$v_1,\dots,v_p$, and let~$E$ be the
set of edges.  Suppose we have a weight function for the edges
\[
\wt\colon E\to R
\]
where~$R$ is any commutative ring.  Let~$A_{\wt}$ be the {\em weighted adjacency
matrix} defined by~$(A_{\wt})_{ij}=\wt(v_i,v_j)$, where we
define~$\wt(v_i,v_j)=0$ if~$v_i,v_j$ is not an edge.  Given any walk~$\mathbf{w}$
in~$G$, define the weight of~$\mathbf{w}$ to be the product of the weights of
its edges.  Then a straightforward generalization of the argument used during
the first day of class shows that $(A_{\wt}^{\ell})_{ij}$ is the sum of the
weights of all~$\ell$-walks starting at~$v_i$ and ending at~$v_j$, Again, the
proof goes by induction, the case~$\ell=0$ being trivial.  Let~$\ell\geq1$, and
let~$B:=A_{\wt}^{\ell}$.  Then
\[
  (A_{\wt}^{\ell})_{ij}=(BA_{\wt})_{ij}=\sum_{k=1}^{p}B_{ik}(A_{\wt})_{kj}
  =\sum_{k=1}^{p}B_{ik}\wt(v_k,v_j)
\]
By induction,~$B_{ik}$ is the sum of the weights of all walks from~$v_i$
to~$v_k$, and the result follows.  

To recover the original result, take~$R=\Z$ and all weights equal to~$1$.  We
have that~$A_{\wt}$ is just the usual adjacency matrix, and~$(A^{\ell})_{ij}$ is
the number of~$\ell$-walks from~$v_i$ to~$v_j$.  
\bigskip

Next let~$G$ be a connected {\em multigraph} with vertex set~$V$.  This means
there may be multiple edges connecting the same two vertices.  For each~$u,v\in
V$, let~$\mu_{uv}$ be the number of edges joining~$u$ to~$v$, and
let~$d_u=\deg(u)$ be the {\em degree} of~$u$, i.e., the number of edges incident
on~$u$.

A {\em random walk} on~$G$ is one in which having arrived at a vertex~$u$ in the
walk, the next edge is determined uniformly at random among the edges incident
on~$u$.  Thus, one would move from~$u$ to~$v$ with probability~$\mu(u,v)/d_u$.
Let~$M=M(G)$ be the {\em probability matrix} with rows and columns indexed
by~$V$.  The $u,v$-th entry of~$M$ is defined to be
\[
  M_{uv}:=\frac{\mu(u,v)}{d_u}.
\]
\medskip

{\bf Lemma.} The probability of a random walk starting at~$u$ ends at~$v$
is~$(M^{\ell})_{uv}$.
\begin{proof}
 Let~$G'$ be the graph~$G$ where each multiedge is replaced by a
 single edge, then~$M$ may be interpreted as a weighted adjacency
 matrix~$A_{\wt}$ for~$G'$.  \hfill$\Box$
\end{proof}

So, as earlier, the question of diagonalizability becomes important.  Luckily:
\medskip

{\bf Theorem 3.2.} The probability matrix~$M$ is diagonalizable and has only
real eigenvalues. 
\begin{proof}
 Since~$G$ is connected,~$d_u>0$ for all~$u\in V$.  Let~$D$ be the
 diagonal matrix with rows indexed~$V$ and with~$v$-th diagonal
 entry~$\sqrt{d_v}$ for all~$v\in V$.  A calculation shows
 \[
 (DMD^{-1})_{uv}=\frac{\mu_{uv}}{\sqrt{d_ud_v}}
 \]
 for all~$u,v\in V$.  Hence,~$DMD^{-1}$ is symmetric and real, hence,
 diagonalizable with real eigenvalues.  Since~$M$ is similar to~$DMD^{-1}$, it
 is also diagonalizable and has the same eigenvalues.  \hfill$\Box$
\end{proof}

{\bf Hitting times.}
\smallskip

Let~$S(u,v)$ consisting of all walks from~$u$
to~$v$ meeting~$v$ for the first time at the last step of the walk.  Then
consider the random variable with sample space~$S(u,v)$ defined by
\begin{align*}
  X\colon S(u,v)&\to\R\\
  \mathbf{w}&\mapsto \mathrm{length}(\mathbf{w}).
\end{align*}
For each~$u,v\in V$, define the {\em hitting time} to be the expected length of a walk starting
at~$u$ and ending the first time it meets~$v$:
\[
  H(u,v):=\mathbb{E}(X):=\sum_{n\geq0}np_n
\]
where~$p_n:=\mathbb{P}(X=n)$, the probability the length of the random walk
is~$n$.
\medskip

{\bf Example.} $G=P_3$, the path graph with~$3$ vertices:
\begin{center}
  \begin{tikzpicture}
    \node[ball,label={below:$u$}] at (-1,0) (u) {};   
    \node[ball,label={below:$w$}] at (0,0) (w) {};   
    \node[ball,label={below:$v$}] at (1,0) (v) {};   
      \draw (u)--(w)--(v);
  \end{tikzpicture}
\end{center}
We can calculate the hitting time~$H(u,v)$ using the following tree
(the blue labels denote the probabilities):
\begin{center}
  \begin{tikzpicture}
    \node at (0,0) (u) {$u$};
    \node at (0,-1) (w) {$w$};
    \draw (u) edge node[label={[blue]left:\small$1$}] {} (w);
    \node at (-1,-2) (u2) {$u$};
    \node at (1,-2) (v2) {$v$};
    \draw (w) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=-3pt]above left:\small$\tfrac{1}{2}$}] {} (u2);
    \draw (w) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=10pt]above left:\small$\tfrac{1}{2}$}] {} (v2);
    \node at (-1,-3) (w3) {$w$};
    \draw (u2) edge node[label={[blue]left:\small$1$}] {} (w3);
    \node at (-2,-4) (u4) {$u$};
    \node at (0,-4) (v4) {$v$};
    \draw (w3) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=-3pt]above left:\small$\tfrac{1}{2}$}] {} (u4);
    \draw (w3) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=10pt]above left:\small$\tfrac{1}{2}$}] {} (v4);
    \node at (-2,-5) (w5) {$w$};
    \draw (u4) edge node[label={[blue]left:\small$1$}] {} (w5);
    \node at (-3,-6) (u6) {$u$};
    \node at (-1,-6) (v6) {$v$};
    \draw (w5) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=-3pt]above left:\small$\tfrac{1}{2}$}] {} (u6);
    \draw (w5) edge node[label={[blue,label distance=-0.1mm,anchor=center,
    yshift=2pt,xshift=10pt]above left:\small$\tfrac{1}{2}$}] {} (v6);
    \node at (-2,-5) (w3) {$w$};
    \draw[dotted,thick] (-2,-6.5)--(-2,-7.0);
    \begin{scope}[xshift=4cm]
      \node at (0,1) {length};
      \draw (-1,0.7)--(1,0.7);
      \node at (0,-2) {$2$};
      \node at (0,-4) {$4$};
      \node at (0,-6) {$6$};
      \draw[dotted,thick] (0,-6.5)--(0,-7.0);
    \end{scope}
  \end{tikzpicture}
\end{center}
The hitting time is
\begin{align*}
  H(u,v)&=   \tfrac{1}{2}\cdot 2 +\left(\tfrac{1}{2}\right)^2\cdot
  4+\left(\tfrac{1}{2}\right)^3\cdot 6+\dots\\[10pt]
  &= 1+ \tfrac{1}{2}\cdot 2 +\left(\tfrac{1}{2}\right)^2\cdot
  3+\dots\\[10pt]
  &= \sum_{n\geq0}(n+1)\left( \tfrac{1}{2} \right)^n.
\end{align*}
Note that~$\sum_{n\geq0}z^{n+1}=\frac{z}{1-z}$
for~$|z|<1$ (geometric series).  Differentiating, we get that
\[
  \sum_{n\geq0}(n+1)z^{n}=\frac{1}{(1-z)^2}
\]
also converges for~$|z|<1$.  Therefore,~$H(u,v)=4$.

Alternatively, if~$Y$ is the random variable
\begin{align*}
  Y\colon S(u,v)&\to\R\\
 \mathbf{w}&\mapsto
  \begin{cases}
    0&\text{if~$\mathrm{length}(\mathbf{w})\leq 2$}\\
    1&\text{otherwise,}
  \end{cases}
\end{align*}
then we may use the fact that
\[
\mathbb{E}(X)=\mathbb{E}(X|Y=0)\mathbb{P}(Y=0)+ \mathbb{E}(X|Y=1)\mathbb{P}(Y=1)
\]
to get
\[
  H(u,v)=\tfrac{1}{2}\cdot 2 +\tfrac{1}{2}\left( 2+H(u,v) \right),
\]
from which it again follows that~$H(u,v)=4$.
\medskip

Returning to the general set-up, for each vertex~$v$, define~$M[v]$ to be
the probability matrix~$M$ with its~$v$-th row and column deleted, and
define~$T[v]$ to be the~$v$-th column of~$M$ with its~$v$-th row deleted.
\medskip

{\bf Theorem 3.4.} For each pair of vertices~$u\neq v$,
\[
  H(u,v)=\left(\left( I_{p-1}-M[v] \right)^{-2}T[v]\right)_u.
\]
\begin{proof} Let~$G'$ be the graph formed from~$G$ by removing the vertex~$v$
  and all of its incident edges.  Define the weight of an edge~$a,b$ in~$G'$
  by~$\wt(a,b):=M_{ab}$.  Then~$M[v]$ is a weighted adjacency matrix for~$G'$,
  and~$(M[v]^{\ell})_{a,b}$ is the sum of the weight of the~$\ell$-walks
  starting at~$a$ and ending at~$b$.  It coincides with the probability of a
  walk of length~$\ell$ from~$a$ to~$b$ in~$G$ that never passes through~$v$.
 
It turns out the formula~$\sum_{n\geq}(n+1)x^{n}=1/(1-x)^2$, which holds for
real numbers~$x$ with norm less than~$1$, also holds when
$x$ is the matrix $M[v]$. A proof relying on the Perron-Frobenius Theorem is given in our
text. The probability of moving from vertex~$w$ to vertex~$v$ in one step
is~$\mu(w,v)/d_w$, which is the~$w$-th entry of~$T[v]$. Therefore, summing
over~$w\neq v$,
 \begin{align*}
   H(u,v)&= \sum_{w}\sum_{n\geq0}(n+1)(M[v]^n)_{uw}\frac{\mu(w,v)}{d_w}\\[8pt]
   &=  \sum_{w}\frac{\mu(w,v)}{d_w}\sum_{n\geq0}(n+1)(M[v]^n)_{uw}\\[8pt]
   &=  \sum_{w}\frac{\mu(w,v)}{d_w}\left(\sum_{n\geq0}(n+1)(M[v]^n)\right)_{uw}\\[8pt]
   &=  \sum_{w}\frac{\mu(w,v)}{d_w}\left((I_{p-1}-M[v])^{-2}\right)_{uw}\\[8pt]
   &= \left( (I_{p-1}-M[v])^{-2}T[v] \right)_u
 \end{align*}
\end{proof}

{\bf Example.} Consider our earlier example $G=P_3$:
\begin{center}
  \begin{tikzpicture}
    \node[ball,label={below:$u$}] at (-1,0) (u) {};   
    \node[ball,label={below:$w$}] at (0,0) (w) {};   
    \node[ball,label={below:$v$}] at (1,0) (v) {};   
      \draw (u)--(w)--(v);
  \end{tikzpicture}
\end{center}
We have
\begin{center}
  \begin{tikzpicture}
    \begin{scope}
      \node at (0,0) {$\displaystyle
	M =\quad 
	\left(\begin{array}{ccc}
	    0&1&0\\
	    \tfrac{1}{2}&0&\tfrac{1}{2}\\
	    0&1&0
	\end{array} \right),
      $};
      \node at (0.0,1) {$u$};
      \node at (0.6,1) {$w$};
      \node at (1.15,1) {$v$};
      \node at (-0.8,0.5) {$u$};
      \node at (-0.8,-0.0) {$w$};
      \node at (-0.8,-0.5) {$v$};
    \end{scope}
    \begin{scope}[xshift=5.7cm]
      \node at (0,0) {$
	M[v] = 
	\left(\begin{array}{cc}
	    0&1\\
	    \tfrac{1}{2}&0
	\end{array} \right),
	\quad
	T[v] = 
	\left(\begin{array}{c}
	    0\\\tfrac{1}{2}
	\end{array} \right).
      $};
    \end{scope}
  \end{tikzpicture}
\end{center}
Therefore,
\[
  (I_2-M[v])^{-2}
  =
  \left(\begin{array}{rr}
      1&-1\\
      -\tfrac{1}{2}&1
  \end{array} \right)^{-2}
  =
  \left(\left(\begin{array}{rr}
      1&-1\\
      -\tfrac{1}{2}&1
\end{array} \right)^{-1}\right)^{2}
  =
  \left(2\left(\begin{array}{rr}
      1&1\\
      \tfrac{1}{2}&1
\end{array} \right)\right)^{2}
 =
 \left(\begin{array}{cc}
     6&8\\
     4&6
 \end{array} \right),
\]
and
\[
  (I_2-M[v])^{-2}T[v]=
 \left(\begin{array}{cc}
     6&8\\
     4&6
 \end{array} \right)
 \left(\begin{array}{c}
     0\\
     \tfrac{1}{2}
 \end{array} \right)
 =
 \left(\begin{array}{c}
     4\\3
 \end{array} \right).
\]
It follows that~$H(u,v)=4$ and~$H(w,v)=3$.
\medskip

\end{document}


