\documentclass[11pt]{article}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{latexsym}
\usepackage[pdftex]{graphicx}
\usepackage{url}
\usepackage{hyperref}
\hypersetup{colorlinks=true}
\setlength{\oddsidemargin}{.25in}
\setlength{\evensidemargin}{.25in}
\setlength{\textwidth}{6in}
\setlength{\topmargin}{-0.4in}
\setlength{\textheight}{8.5in}

\input{preamble.tex}

\begin{document}

\lecture{1: An Introduction to Spectral Theory}{Week 3}


\section{Motivation/Definitions}

For those of you who've been in the graph theory courses for the last week, something you might have noticed about graph theory is that we really, um, don't understand very much.  We don't have terribly good characterizations of graphs based on their chromatic number, we don't understand how $k$-flows work on graphs, we don't know the chromatic number of the unit distance graph, and we only just recently discovered a decent characterization of perfect graphs (which are honestly pretty simple, as far as graphs go!)


Conversely, for those of you who've been in the linear algebra sequence for the last week: something you might have noticed is that we're (honestly) pretty good at this stuff!  If I give you a linear map $f:\mathbb{R}^n \to \mathbb{R}^n$, you can:
\begin{itemize}
\item Describe $f$ as a $n \times n$ matrix, $A_f$!
\item Find all of the eigenvectors and eigenvalues of $A_f$ -- i.e. find all of the subspaces $E_i$ such that $f(E_i) = E_i$, and find the constants that $f$ dilates these subspaces by!
\item If $f$ happens to be particularly nice and has $n$ eigenvalues (counting multiplicity), then we can make a basis for $\mathbb{R}^n$ out of its eigenvectors!  
\item Furthermore, in such a nice case, we can write $A_f$ as $UDU^T$, where $U$ is a unitary matrix\footnote{A \textbf{unitary matrix} is a matrix whose columns form an orthonormal basis for $\mathbb{R}^n$.} and $D$ is a diagonal matrix\footnote{A \textbf{diagonal matrix} is a matrix where its only nonzero entries are on the diagonal.} with entries made out of $A_f$'s eigenvalues!
\end{itemize}

So: Graphs are hard.  Linear algebra is easy!  How can we combine these?

One way (specifically, the way we're going to focus on in this course:) the adjacency matrix!
\begin{definition}
Given a graph $G$ with vertex set $\{1, \ldots n\}$, we define its \textbf{adjacency matrix} $A_G$ as the following $n \times n$ matrix:
\begin{align*}
A = \{a_{ij}: a_{ij} = 1 \textrm{ if } \{i,j\} \in E(G), \textrm{ and }0 \textrm{ otherwise.}\}
\end{align*}
\end{definition}
There are a bunch of alternate/different ways to associate graphs to matrices (the Laplacian and incidence matrices, in particular, are fairly interesting things to study;) for now, however, we'll focus on the adjacency matrix, as it's easy to work with and fairly nice.  Specifically, one property of these matrices that we'll use constantly is that these matrices are \textbf{symmetric} and \textbf{real-valued}!  This allows us to apply the \textbf{spectral theorem}:
\begin{theorem}
Any real-valued symmetric matrix $A$ has $n$ eigenvalues (counting multiplicity) and $n$ corresponding eigenvectors, which we can choose to all be orthogonal to each other.  More explicitly, we can write $A = EDE^T$, where 
\begin{itemize}
\item $E$ is an orthonormal matrix whose columns are the eigenvectors of $A$, and 
\item $D$ is a diagonal matrix whose entries are the corresponding eigenvalues of $A$.
\end{itemize}
\end{theorem}

For reference, we calculate a few easy-to-find adjacency matrices:
\begin{example}
\begin{enumerate}
\item The graph $K_n$ has adjacency matrix with 0's on the diagonal and 1's everywhere else:
\begin{align*}
\left[ \begin{array}{ccccc}
0 & 1 & 1 & \ldots & 1 \\
1 & 0 & 1 & \ldots & 1 \\
1 & 1 & 0 & \ldots & 1 \\
\vdots & \vdots & \vdots & \ddots & \vdots \\
1 & 1 & 1 & \ldots & 0 \\
\end{array} \right]
\end{align*}
\item The empty graph $\overline{K_n}$'s adjacency matrix is identically 0:
\begin{align*}
\left[ \begin{array}{cccc}
0 & 0 & \ldots & 0 \\
0 & 0 & \ldots & 0 \\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \ldots & 0 \\
\end{array} \right]
\end{align*}
\item Enumerate the vertices of the cycle graph $C_n$ as $\{1, 2, \ldots n\}$ and its edges as $\{\{i,i+1\}: 1 \leq i \leq n\}$.  Then, its adjacency matrix has ones as depicted below:
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 &\ldots  & 1 \\
1 & 0 & 1 & 0 & \ldots  & 0 \\
0 & 1 & 0 & 1 & \ldots & 0 \\
0 & 0 & 1 & 0 & \ddots & 0 \\
\vdots & \vdots & \vdots & \ddots & \ddots  & 1 \\
1 & 0  & 0 & \ldots & 1 & 0 \\
\end{array} \right]
\end{align*}
\end{enumerate}
\end{example}

\section{Applications of the Adjacency Matrix: Counting Paths / Walks}
So: we have these graphs, and we've turned them into matrices.  How can we use these matrices to get back information about these graphs?

One quick application is to \textbf{counting walks on a graph}!  Specifically: suppose we have a graph $G$ on $n$ vertices, and two nodes $i,j \in V(G).$  How do we count all of the walks\footnote{A \textbf{walk} of length $n$ from vertex $i$ to vertex $j$ is a sequence $P = (i, \{i,x_1\}, x_1, \{x_1,x_2\}, \ldots \{x_n,j\},j)$.} of length $k$ from $i$ to $j$?

Well: let's limit ourselves to just walks of length 1.  Then, it's trivially just 1 if there is an edge connecting $i$ and $j$, and 0 otherwise.  What about walks of length 2?  Well: any walk of length two will have to connect $i$ to some vertex $v$, and then connect $v$ to $j$: i.e. it's the sum
\begin{align*}
\sum_{v=1}^n  \textrm{isEdge}(i,v) \cdot \textrm{isEdge}(v,j).\\
\end{align*}

But wait!  We've defined these isEdge functions earlier -- specifically, we defined the adjacency matrix $A_G$ of $G$ in such a way that $a_{ij} = 1$ whenever there is an edge from $i$ to $j$, and 0 otherwise.  So, in this notation, we have that the number of walks from $i$ to $j$ is just 
\begin{align*}
\sum_{v=1}^n  a_{iv} \cdot a_{vk},
\end{align*}
which we can recognize as the dot product 
\begin{align*}
\left[\begin{array}{cccc} a_{i1} & a_{i2} & \ldots & a_{in} \end{array} \right] \cdot \left[\begin{array}{c} a_{1j} \\ a_{2j} \\ \ldots \\ a_{nj}\\ \end{array} \right].
\end{align*}

But this is just the dot product of the $i$-th row and the $j$-th row of $A_G$!  So, we've just proven the following:
\begin{proposition}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  Then the $(i,j)$-th entry of $A^2$ denotes the number of walks of length $2$ from $i$ to $j$.
\end{proposition}

We can easily generalize this to walks of length $k$:

\begin{theorem}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  Then the $(i,j)$-th entry of $A^k$ denotes the number of distinct walks of length $k$ from $i$ to $j$.
\end{theorem}
\begin{proof}
As discussed above, this is trivially obvious for $k=1$.

We proceed by induction on $k$.  Suppose that we know that the entries of $A^k$ correspond to the number of walks of length $k$ from $i$ to $j$.  Given $i$ and $j$, how can we find all of the walks of length $k+1$ from $i$ and $j$?  Well: any walk of length $k+1$ from $i$ to $j$ can be described as a walk from $i$ to some vertex $v$ of length $k$, and then a walk of length 1 from $v$ to $j$ itself!  So, if we just simply use the summation trick we used before, we can see that
\begin{align*}
\textrm{numberOfWalks}_{k+1}(i,j) &= \sum_{v=1}^n  \textrm{numberOfWalks}_{k}(i,v) \cdot \textrm{isEdge}(v,j)\\
&= (i,j)-\textrm{th entry of }A_G^k \cdot A_G\\
&= (i,j)-\textrm{th entry of }A_G^{k+1}.\\
\end{align*}
\end{proof}

As a quick corollary, we have the following:
\begin{corollary}
Suppose $G$ is a graph with vertex set $\{1,\ldots n\}$ with adjacency matrix $A$.  The number of distinct triangles\footnote{A \textbf{triangle} in $G$ is a triple $(v_1, v_2, v_3)$ where all of the edges $\{v_1, v_2\}, \{v_2, v_3\}, \{v_3, v_1\}$ are contained within $G$.} $(v_1, v_2, v_3)$ contained within $G$ is $tr(A^3)/6$.
\end{corollary}
\begin{proof}
A triangle with a fixed starting point and order in which to visit its vertices is precisely a closed walk of length 3.  There are three possible starting points $(v_1, v_2, v_3)$ and two possible orientations (clockwise, counterclockwise) in which to traverse any such closed walk; therefore, the number of triangles is just $1/6$-th of the number of closed walks on a graph of length 3.

But the number of closed walks on a graph of length 3 is just the sum over all $v \in V(G)$ of the closed length-3 walks starting at $v$: i.e. the sum of the diagonal entries in $A^3$, which is (by definition) $tr(A^3)$.
\end{proof}


\begin{question}
Can you derive a similar formula for 4-gons?
\end{question}

\section{Adjacency Matrices and Isomorphism}

As we saw in the introduction to graph theory class, to really work with graphs we need to consider them only up to isomorphism -- i.e. we want to think of the Petersen graph as just anything with the same vertex-edge relations as the Petersen graph, and not care so much about the labeling of its vertices.  However, adjacency matrices care \textbf{very much} about the labeling of our vertices: i.e. for the two graphs below,
\begin{center}
\includegraphics[width=3.5in]{mc2011_spectral_GT_isospec.pdf}
\end{center}
despite the fact that they're both ``pentagons,'' their adjacency matrices are quite different:
\begin{align*}
A_{G_1} = \left[ \begin{array}{ccccc}
0 & 1 & 0 & 0 & 1\\
1 & 0 & 1 & 0 & 0\\
0 & 1 & 0 & 1 & 0\\
0 & 0 & 1 & 0 & 1\\
1 & 0 & 0 & 1 & 0\\
\end{array} \right], \qquad \qquad A_{G_2} = \left[ \begin{array}{ccccc}
0 & 1 & 1 & 0 & 0\\
1 & 0 & 0 & 1 & 0\\
1 & 0 & 0 & 0 & 1\\
0 & 1 & 0 & 0 & 1\\
0 & 0 & 1 & 1 & 0\\
\end{array} \right]
\end{align*}

This is \ldots troublesome.  If we're going to use linear algebra to study our graphs, getting different results whenever we label our graph differently is going to give us no end of trouble.  So: can we say anything about the relation between these matrices at all?  

Thankfully, there is!  To say precisely what it is, we need the following definition:

\begin{definition}
A $n \times n$ matrix $P$ whose entries are all either 0 or 1 is called a \textbf{permutation matrix} if $P$ has exactly one 1 in each of its rows and columns.  For example, the following matrix is a permutation matrix:
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
\end{array} \right]
\end{align*}
The reason we call this a permutation matrix is because multiplying a vector $\mathbf{v}$ on the left by $P$ ``permutes'' $\textbf{v}$' entries!  For example 
\begin{align*}
\left[ \begin{array}{cccccc}
0 & 1 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 0 & 1 \\
1 & 0 & 0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 & 1 & 0 \\
0 & 0 & 0 & 1 & 0 & 0 \\
0 & 0 & 1 & 0 & 0 & 0 \\
\end{array} \right] \cdot 
\left[ \begin{array}{c}
v_1 \\
v_2 \\
v_3 \\
v_4 \\
v_5 \\
v_6 \\
\end{array} \right] = \left[ \begin{array}{c}
v_2 \\
v_6 \\
v_1 \\
v_5 \\
v_4 \\
v_3 \\
\end{array} \right] 
\end{align*} 

Given a permutation $\sigma: \{1, \ldots n\} \to \{1, \ldots n\}$, we will sometimes write $P_\sigma$ to denote the permutation matrix such that $P(v_1, \ldots v_n) = (v_{\sigma(1)}, \ldots v_{\sigma(n)})$.  It bears noting that every permutation matrix $P$ can be expressed as $P_\sigma$ for some permutation $\sigma$, by just tracking where it sends a generic vector $(v_1, \ldots v_n)$.
\end{definition}

We first note the following property of permutation matrices:
\begin{proposition}
If $P$ is a $n \times n$ permutation matrix with associated permutation $\sigma$, then $(v_1, \ldots v_n) \cdot P = (v_{\sigma^{-1}(1)}, \ldots v_{\sigma^{-1}(n)})$.
\end{proposition}
\begin{proof}
On the HW!
\end{proof}

\begin{proposition}
If $P$ is a $n \times n$ permutation matrix with associated permutation $\sigma$, then $P^{-1}$ is also a permutation matrix with associated permutation $\sigma^{-1}$ (and furthermore is equal to $P^T$.)
\end{proposition}
\begin{proof}
On the HW!
\end{proof}

\begin{proposition}
If $P$ is a $n \times n$ permutation matrix, $P$ is unitary; furthermore, if $E$ is any other unitary matrix, $P\cdot E$ is still unitary.
\end{proposition}
\begin{proof}
On the HW!
\end{proof}

Given this, we can prove the following remarkably useful fact about adjacency matrices of isomorphic graphs:


\begin{proposition}
If $G_1$ and $G_2$ are a pair of isomorphic graphs with adjacency matrices $A_1, A_2$, then $A_1$ and $A_2$ are conjugate via a permutation matrix $P$: i.e. 
\begin{align*}
A_2 = PA_1P^{-1}.
\end{align*}
\end{proposition}
\begin{proof}
Suppose that $G_1$ and $G_2$ are isomorphic graphs, both with vertex set $\{1, \ldots n\}$.  Then there is some permutation $\sigma$ of $\{1, \ldots n\}$ that realizes this isomorphism (i.e. such that $(i,j)$ is an edge in $A_1$ iff $(\sigma(i), \sigma(j))$ is an edge in $A_2$.)  

Let $P$ be the associated permutation to this map $\sigma$; then, we have that 
\begin{itemize}
\item $PA_1$ is the matrix where we've taken each column of $A_1$ and permuted its entries according to $\sigma:$ in other words, $PA_1$ is $A_1$ if we permute its rows by $\sigma.$
\item Similarly, $A_1P^{-1}$ is the matrix where we permute $A_1$'s columns by $(\sigma^{-1})^{-1} = \sigma$, by our earlier two lemmas.
\item By combining these two results, $PA_1P^{-1}$ is the matrix where we permute $A_1$'s rows by $\sigma$, and then permute the resulting matrices' columns by $\sigma$ again! 
\end{itemize}
What does this mean?  Well: we've started by taking any point $(i,j)$ in $A_1$, and have sent it to $(\sigma(i), \sigma(j))$.  But this means that we've sent the indicator function for the edge $(i,j)$ to the location $(\sigma(i), \sigma(j))$!  In other words, we've sent $A_1$ to $A_2$: i.e. we've proven $A_2 = PA_1P^{-1}$, as claimed.
\end{proof}

One remarkable consequence of this is the following corollary:
\begin{corollary}
If $G_1$ and $G_2$ are isomorphic graphs, their adjacency matrices $A_1$ and $A_2$ have the same set of eigenvalues (counting multiplicity.)
\end{corollary}
\begin{proof}
Pick any permutation matrix $P$ such that $A_2 = PA_1P^{-1}$.  We know that $A_1$ is real-valued and symmetric; therefore, we can write it in the form $EDE^T$, for some unitary matrix $E$ and diagonal matrix of eigenvalues $D$.  But this means that we've written
\begin{align*}
A_2 &= (P\cdot E)\cdot D \cdot (E^T \cdot P^T)\\
& = (P\cdot E)\cdot D \cdot (P \cdot E)^T.\\
\end{align*}
But what have we done here?  We've expressed $A_2$ as $D$ conjugated by a unitary matrix.  But this means that\footnote{By a HW exercise!} $A_2$'s eigenvalues are precisely the entries on the diagonal of $D$!  So we've proven our claim.
\end{proof}

This motivates us to make the following definition:

\begin{definition}
The \textbf{spectrum} of a graph $G$ is the set of all of $A_G$'s eigenvalues, counted with multiplicity.  For example, we say that the empty graph on 3 vertices, $\overline{K_3}$, has spectrum $\{0^3\}$, where by $0^3$ we mean that it has the eigenvalue 0 repeated three times.
\end{definition}


\end{document}