Adjacency Matrices, Counting Walks and Transition Matrices | Applications and Interpretation IB Maths notes

Free preview: Adjacency Matrices, Counting Walks and Transition Matrices

The Adjacency Matrix: a Graph as a Table

Applications and interpretation: HL only (AHL 3.15)

Here's a question. In a small network of four towns, how many different routes of exactly 3 roads go from A to D, if you are allowed to go back and forth? For a tiny graph you can list them. For a network with 20 towns, listing is hopeless.

  • A graph can be stored as a table of numbers, the adjacency matrix. Then matrix multiplication, done on the GDC, counts routes through the graph for you.
  • Recall the words from graph theory: vertices (the dots), edges (the lines joining them), and the degree of a vertex (the number of edges at it).
  • In a directed graph each edge has an arrow and can only be travelled one way.

Left: graph G with vertices A, B, C, D and edges AB, AC, BC, BD, CD. Right: a directed graph of four web pages with links A to B, A to C, B to C, C to A, C to D and D to A.

What the picture shows

  1. Left: graph G with vertices A, B, C, D and edges AB, AC, BC, BD and CD.
  2. Right: a directed graph of four web pages, with links A to B, A to C, B to C, C to A, C to D and D to A.

The adjacency matrix

  1. Label the rows and columns with the vertices in the same order. Why: entry (i, j) must mean "from i to j" every time.
  2. The entry in row i, column j is the number of edges joining vertex i to vertex j.
  3. Put 0 where there is no edge (including the diagonal, unless there is a loop).

๐Ÿ‘€ Watch me do it: the adjacency matrix of graph G (order A, B, C, D)

What I writeWhy I do it
Row A: 0, 1, 1, 0A is joined to B and C only. No loop, so (A, A) = 0.
Row B: 1, 0, 1, 1B is joined to A, C and D.
Row C: 1, 1, 0, 1C is joined to A, B and D.
Row D: 0, 1, 1, 0D is joined to B and C.
M=(0110101111010110)Check: the matrix is symmetric, because each edge works both ways.
Row sums 2, 3, 3, 2These are the degrees. Total 10 = twice the 5 edges.
  • An undirected graph gives a symmetric matrix. The sum of a row is the degree of that vertex.
  • A loop at a vertex is usually counted as 1 on the diagonal; follow the question's convention. Multiple edges give entries bigger than 1.
  • For a directed graph, the entry in row i, column j counts the edges from i to j, so the matrix need not be symmetric.

๐Ÿ“ Here's the trap

  • Forgetting that an undirected edge appears twice in the adjacency matrix (in row i and in row j). Wrong: AB gives a 1 only in row A. Right: a 1 at (A, B) and at (B, A).

โœ๏ธ YOUR TURN 1

Try this first:

Write down the adjacency matrix for the directed graph of web pages (order A, B, C, D), with entry (i, j) counting links from i to j. Is it symmetric?

Answer:

  • (0110001010011000)

  • Row A: links to B and C. Row B: to C. Row C: to A and D. Row D: to A.
  • Not symmetric: A links to B, but B does not link to A.

Counting Walks with Powers of M

  • A walk of length k is a sequence of k edges, one after another. Vertices and edges may be repeated.
  • The entry in row i, column j of Mk is the number of walks of length k from i to j.

Why squaring counts walks of length 2

  • A walk of length 2 from i to j goes i โ†’ (some middle vertex m) โ†’ j.
  • For each possible middle vertex m, the number of ways is (edges i to m) ร— (edges m to j).
  • Adding over all m is exactly "row i of M times column j of M": the rule for matrix multiplication.
  • Repeat the argument and M3, M4, ... count longer walks.

Unlock the full note: start 7 days free.

Log in or subscribe to read the rest of this note. Members also get the AI tutor, practice quizzes, mock exams and flashcards for this topic.

Log in ยท Subscribe ยท Start free trial

All notes in HL: Graphs and networks (AHL 3.14โ€“3.16)

  1. The Language of Graphs: Degrees, Paths, Trees and Special Graphs
  2. Eulerian and Hamiltonian Graphs
  3. Adjacency Matrices, Counting Walks and Transition Matrices
  4. Kruskal's and Prim's Algorithms on a Network
  5. Prim's Algorithm on a Distance Matrix and Spanning Tree Problems
  6. Route Inspection: Eulerian Routes and Two Odd Vertices
  7. Route Inspection with Four Odd Vertices and Different Start and Finish Points
  8. The Travelling Salesperson Problem: Least Distances and Nearest Neighbour Upper Bounds
  9. Lower Bounds for the Travelling Salesperson Problem: The Deleted Vertex Method

What's inside for this topic

9 teacher notes, 65 practice questions, 40 flashcards, 2 quizzes.

Get the full notes, every practice question, flashcards, quizzes and mock papers.

Start your free 7-day trial

Questions? Chat with us on WhatsApp ยท Try one live lesson

Previous note: Eulerian and Hamiltonian Graphs Next note: Kruskal's and Prim's Algorithms on a Network

All Applications and Interpretation IB Maths topics ยท IB Maths