← Year 12: Networks

NSWMaths Standard 2Syllabus dot point

How is the shortest path between two vertices in a weighted network found?

Find the shortest path between two vertices in a weighted network by inspection or by systematic labelling

A focused answer to the HSC Maths Standard 2 dot point on shortest paths. Inspection method for small networks, systematic labelling for larger ones, and worked examples for road network distances and Sydney transport routes.

Generated by Claude OpusReviewed by Better Tuition Academy7 min answer

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

What this dot point is asking

NESA wants you to find the shortest path between two specified vertices in a weighted network. For small networks, inspection (listing all reasonable paths and picking the smallest) is enough. For larger ones, a systematic labelling method like Dijkstra's algorithm is expected.

The answer

Weighted graph with shortest path from A to D highlighted The same graph used for the MST example, but with the shortest path from A to D highlighted. Path A to C to D has total weight 2 plus 3 equals 5, which is shorter than any other route from A to D. 4 2 5 10 3 7 6 A B C D E Shortest A β†’ D path: A β†’ C β†’ D, total 5

What the question asks

Given a weighted graph with vertices and edge weights (distances, times, costs), find the path from a starting vertex to an ending vertex with the smallest total weight.

The shortest path may not be the path with the fewest edges. A long edge with low weight per edge can sometimes be faster than a short path with high weights.

Method 1: inspection

For small networks (say 55 vertices or fewer), list all sensible candidate paths between the start and end vertex, compute each total weight, and pick the smallest.

This works when:

  • The graph is small.
  • There are few branching options.
  • You can spot all reasonable paths visually.

Method 2: systematic labelling (Dijkstra's algorithm)

For larger networks, use systematic labelling:

  1. Label the start vertex with 00. Label all other vertices with ∞\infty (or just "unknown").
  2. From the current vertex (start with the start), look at each neighbour and compute the proposed label = current label + edge weight. If this is less than the neighbour's current label, update.
  3. Mark the current vertex as finalised.
  4. Move to the unfinalised vertex with the smallest current label.
  5. Repeat steps 2-4 until the end vertex is finalised.

The final label on the end vertex is the shortest total weight. Trace back through the predecessors to find the actual path.

Tracking the path

While labelling, record the predecessor: which vertex you came from when you set the current label. After finishing, trace backwards from the end vertex to the start using these predecessors, then reverse to get the path in forward order.

Equal-weight ties

If two paths have the same total weight, there are multiple shortest paths. State both (or all) in your answer.

Sanity checks

  • Total weight on the path equals the final label on the end vertex.
  • Each edge used was an actual edge in the graph.
  • The path is connected: each consecutive pair of vertices is joined by an edge.

Past exam questions, worked

Real questions from past NESA papers on this dot point, with our answer explainer.

2022 HSC Q244 marksIn a road network with vertices A,B,C,D,EA, B, C, D, E and weighted edges representing distances in km, find the shortest path from AA to EE and state its length.
Show worked answer β†’

List all possible paths from AA to EE and their lengths.

Say the paths are: AA-BB-EE (length 4+8=124 + 8 = 12), AA-CC-EE (length 5+6=115 + 6 = 11), AA-CC-DD-EE (length 5+3+2=105 + 3 + 2 = 10), AA-BB-DD-EE (length 4+4+2=104 + 4 + 2 = 10).

The shortest is 1010 km, via either AA-CC-DD-EE or AA-BB-DD-EE (both give the same length).

Markers reward listing the candidate paths systematically, computing each total, identifying the shortest, and noting if multiple paths tie. State all tied shortest paths if asked.

2023 HSC Q234 marksA driver in Sydney wants the shortest route from her home (vertex HH) to her workplace (vertex WW) using a weighted graph where edges are road segments and weights are typical drive times in minutes. Find the shortest route and its total time.
Show worked answer β†’

Apply systematic labelling: starting at HH, label each vertex with the shortest known total time from HH. Update labels as shorter paths are found.

Step through: label HH with 00. Label its neighbours with the edge weights to them. From the next vertex with the smallest label, update its neighbours, and so on, always taking the smallest unfinalised label next.

Continue until WW is labelled. The final label on WW is the shortest total time. Trace back via the predecessors to find the actual route.

Markers reward systematic application of the labelling, accurate intermediate values, the shortest time, and the route traced back. State the route as a sequence of vertices and the total time with units.

Related dot points