Skip to main content

Graphs, networks and adjacency matrices (QCE General Mathematics Unit 4)

Syllabus dot point

“Understand the meaning of graph, vertex, edge, loop, degree of a vertex, subgraph, simple, complete, bipartite, directed and weighted graphs and networks, construct network diagrams for practical situations, and construct an adjacency matrix from a graph or digraph and a graph or digraph from an adjacency matrix”

16 min read

Quick answer

A graph is vertices joined by edges; a loop joins a vertex to itself and adds 2 to its degree, and the sum of degrees is twice the number of edges. Know simple, complete, bipartite, directed (digraph) and weighted (network) graphs and subgraphs. An adjacency matrix records the number of edges from each vertex to each other vertex: symmetric for undirected graphs, loops on the diagonal, and directed edges read from row to column.

Jump to a section
  1. What this dot point is asking
  2. The answer
  3. Practice questions

What this dot point is asking

A graph is a way of drawing connections: towns joined by roads, people joined by friendships, camp sites joined by tracks, players joined by the matches they played. The QCAA General Mathematics 2025 syllabus opens Topic 3 (Graphs and networks) with the sub-topic "Graphs, associated terminology and the adjacency matrix". You must:

  • understand and use the terms graph, vertex (node), edge (arc), loop, degree of a vertex, subgraph, simple graph, complete graph, bipartite graph, directed graph (digraph), weighted graph and network;
  • construct a network diagram to represent a practical situation, such as tracks between camp sites, a social network, one-way streets or the results of a round-robin competition;
  • construct an adjacency matrix from a graph or digraph, and construct a graph or digraph from an adjacency matrix.

This vocabulary is used in every later networks question (planar graphs, Eulerian and Hamiltonian routes, spanning trees, critical paths, flow and assignment), so precise use of the terms earns marks throughout Unit 4.

The answer

Vertices, edges, loops and degree

A graph consists of vertices (also called nodes), drawn as dots, and edges (also called arcs), drawn as lines joining pairs of vertices. The position and length of the lines do not matter: only which vertices are joined.

  • A loop is an edge that starts and finishes at the same vertex.
  • Multiple edges are two or more edges joining the same pair of vertices (for example, two different roads between the same two towns).
  • The degree of a vertex is the number of edge ends at that vertex. A loop has both of its ends at the vertex, so it adds 2 to the degree.

Every edge has two ends, so adding up all the degrees counts every edge twice:

sum of degrees=2×number of edges.\text{sum of degrees} = 2 \times \text{number of edges}.

Because 2e2e is even, the number of vertices with odd degree is always even. This gives quick checks: a graph with degrees 1, 2, 3, 3, 4, 4, 4 is impossible (the sum, 21, is odd).

Key fact

Degree == number of edge ends at a vertex (a loop counts 2). Sum of degrees =2e= 2e, so there is always an even number of odd-degree vertices. A simple graph has no loops and no multiple edges; a complete graph joins every pair of vertices exactly once and has n(n−1)2\frac{n(n-1)}{2} edges on nn vertices.

Types of graphs

Term Meaning Example
Simple graph No loops and no multiple edges A friendship network (you are not friends with yourself, and a friendship is counted once)
Complete graph Every pair of vertices is joined by exactly one edge Every team plays every other team once
Subgraph A graph made from some of the vertices and edges of a larger graph The roads within one suburb of a city road map
Bipartite graph Vertices split into two sets, edges only join a vertex in one set to a vertex in the other Students and the electives they choose; workers and the jobs they can do
Directed graph (digraph) Each edge has a direction, shown by an arrow One-way streets; who beat whom in a competition; tasks that must come before others
Weighted graph (network) Each edge carries a number (weight) Distances, travel times, costs or capacities

Some words are used both loosely and precisely. In everyday use "network" means any system of connections; in the syllabus a network is a weighted graph. A complete graph on nn vertices has every vertex of degree n−1n - 1 and n(n−1)2\frac{n(n-1)}{2} edges: for 6 vertices, 6×52=15\frac{6 \times 5}{2} = 15.

Constructing network diagrams

To turn a practical situation into a graph:

  1. Decide what the vertices are (the places, people, teams or tasks).
  2. Decide what an edge means (a road, a friendship, a match, a result, a dependency).
  3. Decide whether direction matters. One-way streets, "beat" relationships and task order need a digraph.
  4. Decide whether edges need weights (distance, time, cost, capacity). If so, it is a network.
  5. Draw it neatly, labelling every vertex (and every weight), avoiding unnecessary crossings.

For example, camp sites A to E joined by walking tracks A-B 4 km, A-C 3 km, B-C 2 km, B-D 5 km, C-E 6 km and D-E 3 km form an undirected, weighted graph (a network) with 5 vertices and 6 edges.

The adjacency matrix

An adjacency matrix records a graph as a square table of numbers. With the vertices listed in the same order along the rows and the columns, the entry in row X and column Y is the number of edges joining X to Y.

A graph and its adjacency matrixLeft: a graph with vertices A, B, C and D. A and B are joined by two edges, A to C and B to C by one edge each, C to D by one edge, and there is a loop at D. Right: its adjacency matrix in the order A, B, C, D. Row A is 0, 2, 1, 0. Row B is 2, 0, 1, 0. Row C is 1, 1, 0, 1. Row D is 0, 0, 1, 1. The matrix is symmetric, the 2s record the double edge and the 1 on the diagonal records the loop at D.ABCDlooptwo edges A to BABCDABCD0210201011010011symmetric: the graph is undirectedEntry in row X, column Y: the number of edges joining X and Y.

Reading and writing the matrix:

  • Undirected graphs give symmetric matrices: an edge between A and C is counted in row A, column C and row C, column A.
  • Multiple edges show as numbers greater than 1 (the 2s above).
  • Loops appear on the leading diagonal. A loop is usually entered as 1 (one edge joins the vertex to itself), even though it adds 2 to the degree. Follow the convention given in the question if it states one.
  • For a simple graph with no loops, the diagonal is all zeros, every entry is 0 or 1, and each row sum is the degree of that vertex.

To draw a graph from a matrix, place a vertex for each row, then for each entry above the leading diagonal draw that many edges between the row vertex and the column vertex, and draw a loop for each diagonal entry. Counting edges from a symmetric matrix: add the entries above the diagonal, then add the diagonal entries (loops).

Adjacency matrices of digraphs

For a digraph, the entry in row X and column Y is the number of edges directed from X to Y. The matrix is generally not symmetric. In a round-robin competition where an arrow runs from the winner to the loser, the row sums give each player's number of wins and the column sums give losses.

Round robin among P, Q, R and S: P beat Q and R; Q beat R; R beat S; S beat P and Q.

PQRSP0110Q0010R0001S1100\begin{array}{c|cccc} & P & Q & R & S \\ \hline P & 0 & 1 & 1 & 0 \\ Q & 0 & 0 & 1 & 0 \\ R & 0 & 0 & 0 & 1 \\ S & 1 & 1 & 0 & 0 \end{array}

Row sums: P 2, Q 1, R 1, S 2. Column sums (losses): P 1, Q 2, R 2, S 1.

Worked examples: terminology, adjacency matrices and modelling

Degrees and the sum of degrees

A graph has edges PQ, PR, QR, RS and a loop at S. Find each degree and check the sum.

Degrees. P 2, Q 2, R 3, S 3 (RS plus 2 for the loop).

Check. Sum =10= 10; there are 5 edges; 2×5=102 \times 5 = 10.

Marker's note: the most common error is counting a loop as 1. Write "loop counts 2" next to the vertex.

From a graph to an adjacency matrix

Write the adjacency matrix for the graph with edges AB, AC, BC, BD and CD (order A, B, C, D).

Fill row by row. Row A: B and C are joined to A, so (0, 1, 1, 0). Row B: A, C, D, so (1, 0, 1, 1). Row C: A, B, D, so (1, 1, 0, 1). Row D: B, C, so (0, 1, 1, 0).

[0110101111010110]\begin{bmatrix} 0 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 0 & 1 & 1 & 0 \end{bmatrix}

Check. Symmetric, zero diagonal, row sums 2, 3, 3, 2 are the degrees, total 10=2×510 = 2 \times 5 edges.

Marker's note: label the rows and columns when you write a matrix in an exam, so the order is unambiguous.

From an adjacency matrix to a graph

Rows (0, 2, 1, 0), (2, 0, 0, 1), (1, 0, 1, 1), (0, 1, 1, 0) in the order A, B, C, D. Describe the graph.

Above the diagonal
A-B: 2 edges. A-C: 1. A-D: 0. B-C: 0. B-D: 1. C-D: 1.
Diagonal
C has a loop.
Total
2+1+1+1+1=62 + 1 + 1 + 1 + 1 = 6 edges. The graph is not simple (double edge and loop).

Marker's note: never add every entry and halve it when there are loops; the loop appears only once in the matrix.

Modelling with a bipartite graph

Five students choose electives: Amy (Art, Drama), Ben (Music), Cai (Art, Music), Dev (Drama), Eve (Art, Music, Drama). Model the situation.

Vertex sets
Students {Amy, Ben, Cai, Dev, Eve}; electives {Art, Music, Drama}.
Edges
One from each student to each chosen elective: 9 edges, none between two students or between two electives.
Use
The degree of each elective vertex is its enrolment: Art 3, Music 3, Drama 3.

Marker's note: bipartite graphs set up the assignment problems (Hungarian algorithm) later in the unit.

Where this leads

The same graph language feeds every later sub-topic in Unit 4:

  • Planar graphs and Euler's formula v+f−e=2v + f - e = 2 (see the planar graphs page).
  • Walks, trails, paths and Eulerian or Hamiltonian routes, decided using the degrees you calculate here (see the Eulerian and Hamiltonian page).
  • Shortest paths and minimum spanning trees in weighted graphs.
  • Critical path analysis on directed activity networks, flow networks on directed weighted graphs, and assignment problems on bipartite graphs.
Common traps
Counting a loop as 1 in the degree
A loop adds 2 to the degree of its vertex.
Adding every entry of an adjacency matrix and halving, when there are loops
Loops appear once on the diagonal; count them separately.
Making a digraph's matrix symmetric
For a digraph, row X column Y counts edges from X to Y only.
Confusing complete and connected
Connected means you can get from any vertex to any other; complete means every pair is joined directly.
Calling any two-group situation bipartite
It is bipartite only if no edge joins two vertices in the same group.
Mixing the vertex order
Rows and columns must list the vertices in the same order.
Exam technique

Before drawing a graph from a description, write a one-line key: "vertices = ..., edges = ..., directed? weighted?". For adjacency matrices, label the rows and columns, then check symmetry (undirected), the diagonal (loops) and the row sums (degrees) against the graph. Use "sum of degrees =2e= 2e" as a final check on any count of edges.

Note

A graph is just dots joined by lines, where the dots are things (towns, people, teams) and the lines are connections (roads, friendships, games). The number of lines at a dot is its degree. You can also write a graph as a table, called an adjacency matrix, where each box says how many lines join one dot to another. If the lines have arrows, like one-way streets, the table records the direction too, so it is no longer the same when you flip it.

Practice questions

Original practice questions graded from foundation to exam level, each with a full worked solution. Try them before revealing the solution.

foundation2 marks
A graph has vertices P, Q, R and S and edges PQ, PR, QR, RS and a loop at S. Find the degree of each vertex and check that the degrees add to twice the number of edges.
Show worked solution →

P: PQ, PR, so 2. Q: PQ, QR, so 2. R: PR, QR, RS, so 3. S: RS plus the loop (which counts 2), so 3. (1 mark)

Sum =2+2+3+3=10= 2 + 2 + 3 + 3 = 10. There are 5 edges (four ordinary edges and the loop), and 2×5=102 \times 5 = 10. The check works. (1 mark)

foundation2 marks
(a) How many edges does the complete graph on 6 vertices have? (b) What is the degree of each vertex?
Show worked solution →

(a) Every pair of the 6 vertices is joined once: 6×52=15\frac{6 \times 5}{2} = 15 edges. (1 mark)

(b) Each vertex is joined to the other 5, so each has degree 5. (Check: 6×5=30=2×156 \times 5 = 30 = 2 \times 15.) (1 mark)

foundation2 marks
Write the adjacency matrix, in the order A, B, C, D, for the graph with edges AB, AC, BC, BD and CD.
Show worked solution →

Put the number of edges joining each pair of vertices in the matching row and column:

[0110101111010110]\begin{bmatrix} 0 & 1 & 1 & 0 \\ 1 & 0 & 1 & 1 \\ 1 & 1 & 0 & 1 \\ 0 & 1 & 1 & 0 \end{bmatrix}

(2 marks) The matrix is symmetric because the graph is undirected, and the diagonal is all zeros because there are no loops.

core3 marks
An adjacency matrix, rows and columns in the order A, B, C, D, has rows (0, 2, 1, 0), (2, 0, 0, 1), (1, 0, 1, 1) and (0, 1, 1, 0). (a) Describe the graph, including any loops or multiple edges. (b) How many edges does it have? (c) Is it a simple graph?
Show worked solution →

(a) A and B are joined by two edges (entry 2). A-C, B-D and C-D are single edges. The 1 on the diagonal in row C means a loop at C. (1 mark)

(b) Count each edge once: A-B 2, A-C 1, B-D 1, C-D 1, loop at C 1: a total of 6 edges. (1 mark) (Adding every entry above the diagonal and then the diagonal: 2+1+0+0+1+1=52 + 1 + 0 + 0 + 1 + 1 = 5, plus 1 loop =6= 6.)

(c) No. A simple graph has no loops and no multiple edges, and this graph has both. (1 mark)

core3 marks
In a round-robin tennis competition, each of four players plays every other player once. P beat Q and R; Q beat R; R beat S; S beat P and Q. (a) Draw a directed graph with an arrow from each winner to the loser. (b) Write its adjacency matrix with rows as winners, in the order P, Q, R, S. (c) What do the row sums tell you?
Show worked solution →

(a) Arrows: P to Q, P to R, Q to R, R to S, S to P, S to Q. (1 mark)

(b)

[0110001000011100]\begin{bmatrix} 0 & 1 & 1 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ 1 & 1 & 0 & 0 \end{bmatrix}

(1 mark)

(c) Each row sum is the number of wins: P 2, Q 1, R 1, S 2. P and S are equal first on wins. (1 mark) The matrix is not symmetric, because "P beat Q" does not mean "Q beat P".

core2 marks
Five students (Amy, Ben, Cai, Dev, Eve) each choose electives from Art, Music and Drama. Amy: Art, Drama. Ben: Music. Cai: Art, Music. Dev: Drama. Eve: Art, Music, Drama. (a) What type of graph models this? (b) How many edges does it have?
Show worked solution →

(a) A bipartite graph: one set of vertices is the students, the other is the electives, and edges only join a student to an elective. (1 mark)

(b) One edge per choice: 2+1+2+1+3=92 + 1 + 2 + 1 + 3 = 9 edges. (1 mark)

exam3 marks
Camp sites A, B, C, D and E in a national park are joined by walking tracks: A-B 4 km, A-C 3 km, B-C 2 km, B-D 5 km, C-E 6 km and D-E 3 km. (a) Explain why this is a weighted graph (a network). (b) Write the weighted adjacency information as a table of distances. (c) Explain why the table is symmetric and what a 0 or blank entry would mean.
Show worked solution →

(a) Each edge carries a number (the track length), so the graph is weighted; a weighted graph is called a network. (1 mark)

(b)

A B C D E
A 4 3
B 4 2 5
C 3 2 6
D 5 3
E 6 3

(1 mark)

(c) The tracks can be walked in either direction, so the distance from X to Y equals the distance from Y to X. A blank (or 0) means there is no direct track between those two sites. (1 mark)

exam3 marks
A simple graph has 7 vertices. (a) What is the greatest possible number of edges? (b) If the graph has vertex degrees 1, 2, 2, 3, 3, 4 and kk, what are the possible values of kk? (c) Explain why a simple graph cannot have degrees 1, 2, 3, 3, 4, 4 and 4.
Show worked solution →

(a) The maximum is the complete graph: 7×62=21\frac{7 \times 6}{2} = 21 edges. (1 mark)

(b) The sum of degrees must be even: 1+2+2+3+3+4=151 + 2 + 2 + 3 + 3 + 4 = 15, so kk must be odd. In a simple graph with 7 vertices a degree is at most 6. So kk is 1, 3 or 5. (1 mark)

(c) The sum is 1+2+3+3+4+4+4=211 + 2 + 3 + 3 + 4 + 4 + 4 = 21, which is odd. The sum of degrees always equals 2e2e, an even number, so these degrees are impossible. (1 mark)

Practise this

Sources & how we know this

ExamExplained