The Adjacency Matrix

Given a directed or undirected graph G of n vertices v1, , vn, we can represent the graph by an n n matrix A over , i.e.

in which aij = the number of arrows from vi to vj if G is a directed graph, and aij = the number of edges connecting vi to vj if G is an undirected graph.

Examples

  1. The adjacency matrix of digraph

    is

  2. The adjacency matrix of graph

    is

Let A = (aij) and B = (bij) be two n n matrices, the product of A and B, i.e. AB, is another n n matrix C=(cij) in which \dis cij = nk=1   aikbkj, i.e.

To brush up on the matrix multiplications, please consult the Preliminary Mathematics at the very beginning of these notes.

Theorem Let G be a directed or undirected graph of n vertices v1, v2, , vn, and A be the adjacency matrix of G. Then for any positive integer m, the (i, j)-th entry of Am is equal to the number of walks of length m from vi to vj, where i,j = 1, 2, n.

Proof Let Sm denote the statement that (i, j)th entry of Am is equal to the number of walks of length m from vi to vj. Then for m = 1, S1 is true because the adjacency matrix A is defined that way. For the induction purpose we now assume Sk is true with k 1. Let B = (bij) = Ak, then bsj = the number of walks of length k from vs to vj due to the induction assumption. Hence
(i,j)-th element of Ak+1 = (i,j)-th element of AB
=
= the number of walks of length k+1 from vi to vj
(taking any vertex as the 2nd vertex)

i.e. Sk+1 is true. Hence Sm is true for all m 1, and the proof of the theorem is thus completed.

Example

  1. Consider the digraph

    which has the adjacency matrix A below

    Since

    we see there are exactly \shade{2} walks of length 2 that start at v3 and end at v1. Since

    has only 0's in the third column, we conclude that no vertex can reach v3 via a walk of nonzero length.