You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
A graph is an abstract object, but to compute with it — to let an algorithm or a computer process it — we need a concrete representation. The adjacency matrix turns a graph into a square array of numbers, opening the door to linear algebra: matrix multiplication counts walks, eigenvalues encode structure, and the whole apparatus of Further-Maths matrix theory becomes available. Alongside this we study graph isomorphism — the precise meaning of "two graphs are really the same graph drawn differently" — which is where careful definitions earn the AO2 communication marks.
This is a core representation topic of the Paper 3 Discrete option (7367/3D) (Paper 3: 2 h, 100 marks, 33⅓%; AO1 40% / AO2 25% / AO3 35%). It is the natural bridge between the Discrete option and the compulsory Matrices content of Papers 1 & 2: the adjacency matrix is a genuine matrix, so determinants, powers and (at stretch) eigenvalues all apply. Walk-counting via Ak tests AO1 (apply a technique); isomorphism arguments test AO2 (reason and communicate) and AO3 (decide a structural question and justify it).
Label the vertices 1,2,…,n. The adjacency matrix is the n×n matrix A with
Aij={10if vertices i and j are joined by an edge,otherwise.
For a multigraph, Aij is the number of edges between i and j (and a loop contributes 2 on the diagonal, matching its degree).
| Property | Statement |
|---|---|
| Symmetry | For an undirected graph, Aij=Aji, i.e. A=AT |
| Diagonal | Aii=0 for a simple graph (no loops) |
| Row / column sum | j∑Aij=deg(i) |
| Digraphs | Aij=1 iff there is an arc i→j; generally A=AT |
Vertices A, B, C, D with edges AB, AC, BC, CD. Write down A and read off the degrees.
A=0110101011010010
Row sums are 2,2,3,1, so deg(A)=2, deg(B)=2, deg(C)=3, deg(D)=1. (M1 for a symmetric 0/1 matrix with zero diagonal; A1 for the correct entries.) Check with the handshaking lemma: ∑deg=8=2∣E∣, so ∣E∣=4 — and indeed we listed four edges.
The same graph as a network reminder:
graph LR
A((A)) --- B((B))
A --- C((C))
B --- C
C --- D((D))
The central theorem makes the matrix do work:
(Ak)ij=the number of walks of length k from i to j.
Why. (A2)ij=∑mAimAmj; each product AimAmj is 1 exactly when both i−m and m−j are edges, i.e. when i−m−j is a length-2 walk. Summing over the intermediate vertex m counts all such walks. Induction on k extends this to every power. ■
Using A from §2, compute A2 and interpret two entries.
A2=2111121111301101
(M1 for a correct row × column multiplication; A1 for the full matrix.)
Vertices P, Q, R, S, T with edges PQ, PR, QR, RS, ST (a path P–Q–R–S–T plus the chord PR). Find (A2)RR and (A3)PT.
A=0110010100110100010100010,A3=2341132411442401140211020.
Here (A2)RR=deg(R)=3 (B1). And (A3)PT=1 (A1): there is exactly one walk of length 3 from P to T, namely P−R−S−T. (M1 for using the walk-count interpretation rather than re-listing by hand.)
Exam tip. Walk-counts include revisits and back-tracking — a length-4 walk C−A−C−A is counted in (A4)CA. Do not confuse "walks of length k" with "paths".
For a network, the distance matrix D records edge weights: Dij=w(ij) if i−j is an edge, Dii=0 (or "−"), and Dij=∞ when there is no direct edge. This is a different object from the adjacency matrix and is the input to Prim's matrix method and to Dijkstra's algorithm.
| A | B | C | D | |
|---|---|---|---|---|
| A | – | 3 | 5 | ∞ |
| B | 3 | – | 4 | 6 |
| C | 5 | 4 | – | 2 |
| D | ∞ | 6 | 2 | – |
Note the contrast: the adjacency matrix answers "is there an edge?"; the distance matrix answers "how heavy is the edge?". A third relative, the incidence matrix M, is a ∣V∣×∣E∣ array with Mve=1 when vertex v is an endpoint of edge e; it records the vertex–edge relationship rather than vertex–vertex, and satisfies the elegant identity MMT=A+D, where D=diag(degv) is the degree matrix. You are unlikely to be asked to manipulate the incidence matrix directly, but knowing it exists clarifies why the adjacency matrix — vertex by vertex — is the natural object for walk-counting.
For a digraph the adjacency matrix is generally not symmetric: Aij=1 records an arc i→j only. The ith row sum is then the out-degree deg+(i) and the jth column sum is the in-degree deg−(j). Walk-counting still holds verbatim — (Ak)ij counts directed walks of length k from i to j — which is exactly how one tests reachability in a one-way network: vertex j is reachable from i iff (A+A2+⋯+An−1)ij>0.
A digraph on A, B, C, D has arcs A→B, B→C, C→A, A→C. Write A (rows/columns in order A, B, C, D) and find the number of directed walks of length 2 from A to A.
A=0010100011000000,A2=1100001010100000.
The asymmetry of A signals a genuine digraph. The entry (A2)AA=1: exactly one directed length-2 walk returns to A, namely A→C→A. (M1 for an unsymmetric 0/1 matrix matching the arc directions; A1 for (A2)AA=1 with the walk identified.) Note D is an isolated sink/source here — its row and column are entirely zero, so no walk of any length involves D.
Two graphs G1=(V1,E1) and G2=(V2,E2) are isomorphic, written G1≅G2, if there is a bijection φ:V1→V2 that preserves adjacency:
uv∈E1⟺φ(u)φ(v)∈E2.
Informally, one graph can be relabelled and redrawn to become the other. In matrix terms, G1≅G2 iff there is a permutation matrix P with A2=PA1PT.
| Invariant | Must agree for isomorphic graphs |
|---|---|
| Number of vertices $ | V |
| Number of edges $ | E |
| Degree sequence (degrees, sorted) | Yes |
| Number of cycles of each length (e.g. triangles) | Yes |
| Connectedness, number of components | Yes |
These are necessary but not sufficient: graphs can share all of them yet differ. To prove isomorphism you must exhibit a bijection and verify every edge; to disprove it, find one invariant that differs.
Graph 1: vertices {1,2,3,4}, edges {12,13,24,34}. Graph 2: vertices {A,B,C,D}, edges {AB,BC,CD,DA}. Decide whether they are isomorphic.
Both have degree sequence [2,2,2,2] and are connected — each is the 4-cycle C4. Try φ: 1→A, 2→B, 3→D, 4→C.
| Edge of G1 | Image under φ | In E2? |
|---|---|---|
| 12 | AB | ✓ |
| 13 | AD | ✓ |
| 24 | BC | ✓ |
| 34 | DC | ✓ |
All four edges map onto edges of G2 and φ is a bijection, so G1≅G2. (M1 for proposing a bijection; A1 for verifying every edge correspondence.)
Two graphs each have 6 vertices, 7 edges and degree sequence [3,3,2,2,2,2], but Graph 1 contains a triangle and Graph 2 contains none. Are they isomorphic?
The number of triangles (length-3 cycles) is an isomorphism invariant. Graph 1 has ≥1 triangle; Graph 2 has 0. Since the invariants differ, the graphs are not isomorphic — even though ∣V∣, ∣E∣ and the degree sequence all agree. (B1 for naming a differing invariant; B1 for the correct conclusion.) You can also detect triangles algebraically: (A3)vv=2×(number of triangles through v), so tr(A3)=6×(number of triangles).
The complement Gˉ has the same vertices as G, with an edge exactly where G has none (loops excluded). In matrix form,
A(Gˉ)=J−I−A(G),
where J is the all-ones matrix and I the identity. A graph is r-regular if every vertex has degree r; then every row of A sums to r, so 1=(1,1,…,1)T is an eigenvector: A1=r1, giving r as an eigenvalue.
A degree sequence is the list of degrees in non-increasing order, e.g. [4,3,3,2,2]. Not every list is graphical: by the handshaking lemma its sum must be even, and the Erdős–Gallai conditions characterise the rest (beyond A-Level, but the even-sum check is fair game).
The graph G on {1,2,3,4} has edges 12,23,34 (a path). Write A(G), then use A(Gˉ)=J−I−A to find the complement's adjacency matrix and describe Gˉ.
A(G)=0100101001010010,J−I=0111101111011110.
Subtracting, A(Gˉ)=(J−I)−A(G):
A(Gˉ)=0011000110001100.
(M1 for forming J−I; A1 for the correct subtraction.) So Gˉ has edges 13,14,24. Its degree sequence is [2,2,1,1] — note that G had degree sequence [1,2,2,1] i.e. [2,2,1,1] too, which is why a path on four vertices is self-complementary up to relabelling. (A1 for identifying the complement's edges.)
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.