Algebraic aspects of adjacency matrices

In our last encounter, we saw how there is a matrix naturally associated with every graph, and it can be used for representing the graph on a computer. While this already merits giving adjacency matrices our attention as useful constructs, we shall now see that there is a whole lot more to them than just a data structure.

I’d like to introduce some motivation for the study of this and related structures.

Graph Isomorphism

Given two graphs G=(V,E),G=(V,E), we say that a bijective function f:VV is a graph isomorphism if (u,v)E(f(u),f(v))E  u,vV. We say that G and G are isomorphic, and we note this GG. The idea is that two isomorphic graphs are really the same graph, just under a relabeling of the nodes. Most of the properties we are interested in when studying graphs are preserved under graph isomorphism. For instance, knowing that GG:

As you can see, many interesting properties of graphs are preserved by graph isomorphisms. Properties that do not talk solely about the structure of the graph, but perhaps the representation, need not be preserved under isomorphism. A common example of this is: if we’ve represented our nodes as numbers from 1 to n, graph isomorphism does not preserve the quantity i=1nideg(vi).

Now, here is how this relates to adjacency matrices.

Lemma. Given two graphs G=(V,E), G=(V,E) with adjacency matrices A and A respectively, and calling n=|V|, then GG there exists a permutation matrix P{0,1}n×n such that

PtAP=A

where Pt denotes the transpose of P.

) Suppose GG,with n=|V| and V={v1,...,vn},V={v1,...,vn}. Then there exists f:VV a graph isomorphism. This bijection gives rise to a permutation σ, where we define σ(i)=jf(vi)=vj. It is clear, then, that f(vi)=vσ(i).

Let P{0,1}n×n be defined as:

Pi,j={1,if σ(i)=j0,otherwise

It is clear that P has only one 1 per row or column, and that there are no two rows or columns alike, since σ is a permutation. Then, P is a permutation matrix. We can also see that what we need to prove is equivalent to PtA=APt.

Let us now consider a given entry (i,j) in PtA:

(PtA)i,j=k=1nPi,ktAk,j=k=1nPk,iAk,j

However, we know that Pk,i will only be 1 when σ(k)=i, and be 0 elsewhere. This is the same as saying that it will be 1 only when k=σ1(i).

(PtA)i,j=k=1nPk,iAk,j=Aσ1(i),j

What we can see here is that multiplying to the left by Pt has the effect of permuting the rows according to σ. In effect, what used to be the ith row of A is now the σ(i)th row of PtA.

Now let’s look at what happens with APt.

(APt)i,j=k=1nAi,kPk,jt=k=1nAi,kPj,k=Ai,σ(j)

So we must prove that Aσ1(i),j=Ai,σ(j). Before we do that, we note that if f(vi)=vj, then vi=f1(vj), and thus σ1(j)=i. Also, since f is a graph isomorphism, f1:VV is too.

(APt)i,j=1Ai,σ(j)=1(vi,f(vj))E(f1(vi),vj)E(vσ1(i),vj)EAσ1(i),j=1(PtA)i,j=1

) This is clear if we define f:VV, f(vi)=vjPi,j=1, and use the same proof as above.

Thus, the problem of finding whether or not two graphs are isomorphic is equivalent to finding if their adjacency matrices are simply permutations of eachother. This makes sense, since the intuitive idea of a graph isomorphism is that it doesn’t care if nodes have been relabeled or reordered.

An interesting offshoot of this is that the problem of finding whether or not two graphs are isomorphic (called GRAPH-ISOMORPHISM in complexity theory) has an unknown complexity. It is known to be in NP, but it is not known if it is in NP-complete, or if it’s in P, or where. It has its own complexity class, called GI. This algebraic approach lets us attack the problem using the tools of linear algebra. It is generalized by the mathematical branch of algebraic graph theory.

Walks

Another interesting property of adjacency matrices, is that they allow us to compute the amount of walks from a node to another, purely algebraically. A walk of length k from vi to vj in a graph is an ordered list of k+1 nodes, where each node shares an edge with the next one in the list, the first node is vi, and the last node is vj. This assertion is formalized as such:

Lemma. Let G=(V,E) be a graph, A its adjacency matrix. Let n=|V|, and let δk(i,j) be the amount of walks of length k from node vi to node vj. Then δk(i,j)=Ai,jk.

This is an easy induction proof. First, we note that this is true for k=1. Indeed, if k=1, then there is a walk of length 1 if and only if vi and vj are neighbors, meaning they share an edge. Obviously there is only one such walk if this edge exists, and no such walks if it does not. Hence δ1(i,j)=Ai,j.

Now let us assume that this works for k, and attempt to prove it for k+1.

Ai,jk+1=(AkA)i,j=r=1nAi,rkAr,j

By induction, Ai,rk=δk(i,r). Thus

Ai,jk+1=r=1nδk(i,r)δ1(r,j)

It is true that any walk of length k+1 from vi to vj, can be decomposed as a walk of length k to some neighbor vr of vj, plus an edge from vr to vj. The amount of walks is the summation of all such possible paths. Thus, the amount of ways to get from vi to vj using in a walk of length k+1 is the same as summing over all possible ways to get from vi to a neighbor of vj, using walks of length k. Thus

δk+1(i,j)=r=1nδk(i,r)δ1(r,j)=Ai,jk+1

Knowing this, we can derive some other information about a graph. For instance, the number of induced K3 subgraphs that G has, call it GK3 is exactly

GK3=tr(A3)6=i=1nAi,i36

We also have that

|E|=tr(A2)2=i=1nAi,i22

The proofs of these facts are left as an exercise, they are not hard.

Regularity

An interesting class of graphs is those such that deg(vi)=d, for some constant d. These are called the d-regular graphs. We shall now prove the following result about the adjacency matrix of a d-regular graph:

Lemma. Let G be a d-regular graph, with A its adjacency matrix. Then ρ(A)=d, where ρ(A) is the matrix’s spectral radius, max{|λ|:λ eigenvalue of A}.

We will first prove that d is an eigenvalue of A, and then that it is the largest one.

Let n=|V|, and take v=(1,,1)Rn. Since

deg(vi)=d=j=1nAi,j  1in

we have

(Av)i=j=1nAi,jvj=j=1nAi,j1=deg(vi)=d Thus Av=(d,,d), and Av=dv. Thus d is an eigenvalue with eigenvector v.

To see that it is the largest one, we note that ||A||=d, since ||A||=maxij=1|Ai,j|. But since it is a consistent norm, we have that ||Av||||A||||v||. Now let λ be an eigenvalue of A, with an eigenvector v, which by definition is nonzero. Then

||Av||||A||||v||||λv||d||v|||λ|||v||d||v|||λ|d

This completes the proof.

An easy property related to regulaity, is that there are no d-regular graphs G=(V,E) with n=|V|, such that n and d are both odd. The proof is a straightforward application of the handshake lemma. If we wanted to do this again with the adjacency matrix, the proof revolves around the fact that adjacency matrices always have an even amount of 1s by virtue of being symmetric, and if we have an odd amount n of columns, and each column has an odd amount d of 1s, then the amount of 1s in the matrix would be odd, which we know can’t happen.

Graph properties

When a property of a graph is preserved under graph isomorphism, we call it a graph property, or a graph invariant. Given that two isomorphic graphs share the same adjacency matrix, only under a permutation of the rows and columns, this tells us that some properties of the adjacency matrix are graph invariants. For instance

One usually talks about the spectrum of the graph, and the characteristic or minimal polynomial of the graph, referring to its adjacency matrix. Note, however, that while being isomorphic implies these qualities, the converse does not hold. For example, the following two graphs (taken from Godsil & Royle’s Algebraic Graph Theory) have the same characteristic polynomial, and thus share a spectrum:

They both have adjacency matrices with the characteristic polynomial (x+2)(x+1)2(x1)2(x22x6), yet they are clearly not isomorphic. The problem here is that their adjacency matrices are similar, but not permutation similar. In particular, we see how planarity is not encoded in the graph’s spectrum, nor is the degree of its vertices.

Conclusion

I hope you got a taste of how we can extract information about a graph using its adjacency matrix, and why it is important other than because of its use as a data structure. The fields of algebraic graph theory and, in particular, spectral graph theory, are the ones who study this structure and a related one, the incidence matrix, which we will see in future discussions.