Skip to main content
ExamExplained
SA · General Mathematics
General Mathematics study scene
§-Syllabus dot point
SAGeneral MathematicsSyllabus dot point

How can matrices store the connections in a network and count routes between vertices?

Represent networks with adjacency matrices and use matrix powers to count walks of a given length between vertices.

How to build an adjacency matrix from a network, read direct connections, and use powers of the matrix to count the number of two-step and longer walks between vertices.

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. Building an adjacency matrix
  3. Counting two-step walks with matrix powers
  4. Reading the diagonal and the row sums
  5. Why matrix powers count walks
  6. Directed networks and dominance
  7. Direct plus indirect connections

What this dot point is asking

You must build an adjacency matrix from a graph, interpret its entries, and use A2A^2 or higher powers to count multi-step connections.

Building an adjacency matrix

A network (graph) has vertices joined by edges. Its adjacency matrix AA is square, with one row and one column per vertex. Each entry counts the edges joining that pair of vertices.

For an undirected network the matrix is symmetric (a link from AA to BB is also a link from BB to AA). For a directed network the entry in row ii, column jj counts only edges pointing from ii to jj, so the matrix need not be symmetric.

Counting two-step walks with matrix powers

A walk of length 2 uses two edges, passing through one intermediate vertex. The entry of A2A^2 in row ii, column jj counts exactly these two-edge walks from ii to jj.

Reading the diagonal and the row sums

The diagonal entries of A2A^2 count two-step walks that return to the starting vertex. In the example each diagonal entry is 2, because each town can reach two others and come straight back, giving two such loops.

Row sums of AA are also useful: in an undirected network the sum of row ii gives the degree of vertex ii, the number of edges meeting it.

Why matrix powers count walks

The walk-counting property follows directly from how matrix multiplication works. The entry in row ii, column jj of A2A^2 is the sum over every intermediate vertex kk of aikakja_{ik}a_{kj} - the number of edges from ii to kk times the number from kk to jj. Each such product counts the two-edge routes that pass through kk, and summing over all kk counts every two-step walk from ii to jj. The same reasoning extends to higher powers: A3A^3 sums over all pairs of intermediate vertices, so it counts three-step walks, and so on. Understanding this explains why the technique works rather than treating it as a rule to memorise.

Directed networks and dominance

For a directed network, where edges have a direction, the adjacency matrix is generally not symmetric, and its powers count directed walks that respect the arrows. A common application is a dominance matrix for a round-robin competition, where aij=1a_{ij} = 1 if player ii beat player jj. The row sums of AA give first-order dominance (direct wins), and the row sums of A+A2A + A^2 combine direct wins with "wins over someone who beat someone", giving an overall ranking. This is a standard SACE context for adjacency matrices beyond simple road maps.

Direct plus indirect connections

A common task is to add matrices to combine route lengths. For example, A+A2A + A^2 gives the number of routes of length 1 or 2 between each pair of vertices, useful for asking "in how many ways can I get from P to R in at most two steps?"

Exam-style practice questions

Practice questions written in the style of SACE Board exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

SACE 20234 marksCalculator-assumed. Towns P, Q, R have direct roads P to Q, Q to R and P to R, with the adjacency matrix A=[011101110]A = \begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix}. (a) Find A2A^2. (b) State how many two-step routes go from P to R and describe one.
Show worked answer →

(a) A2=[211121112]A^2 = \begin{bmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{bmatrix}. (2 marks)

(b) The entry in row P (row 1), column R (column 3) of A2A^2 is 11, so there is one two-step route: P to Q to R. (2 marks)

Marks: two for squaring the matrix, two for reading the correct entry and describing the route.

SACE 20223 marksCalculator-assumed. For the adjacency matrix A=[011101110]A = \begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix}, find the number of routes of length 1 or 2 from Q to R using A+A2A + A^2.
Show worked answer →

A+A2=[011101110]+[211121112]=[222222222]A + A^2 = \begin{bmatrix} 0 & 1 & 1 \\ 1 & 0 & 1 \\ 1 & 1 & 0 \end{bmatrix} + \begin{bmatrix} 2 & 1 & 1 \\ 1 & 2 & 1 \\ 1 & 1 & 2 \end{bmatrix} = \begin{bmatrix} 2 & 2 & 2 \\ 2 & 2 & 2 \\ 2 & 2 & 2 \end{bmatrix}. [2 marks]

The entry in row Q (row 2), column R (column 3) is 22, so there are 2 routes of length at most 2 from Q to R (the direct road Q to R, and Q to P to R). [1 mark]

ExamExplained