← Networks

πŸ“– Shortest path

The rule

  • A weighted network has a number on each edge. It can be a distance, a time or a cost.
  • The length of a route is the sum of the numbers along it.
  • The shortest path from A to B is the route with the smallest total.
  • Fewest edges does not mean shortest. Always add the numbers.
  • Taking the cheapest next edge each time can trap you in a dear road later. List the routes.
  • List routes in order: leave A along each edge in turn, and never visit a dot twice.
  • Write each total as a sum, like 3 + 4 + 5 = 12, so you can check it.

Examples

Find the shortest path from A to C. β†’ 8

  1. A β†’ B β†’ C: 5 + 3 = 8
  2. A β†’ D β†’ C: 6 + 4 = 10
  3. The smallest is 8

Add along each route. The smaller total wins.

5364ABCD

Find the shortest path from A to C. Does the cheapest first road win? β†’ 7

  1. A β†’ B β†’ C: 1 + 8 = 9
  2. A β†’ D β†’ C: 3 + 4 = 7
  3. The cheapest first road (1) gave 9, not the shortest
  4. The smallest is 7

The cheapest first road leads on to a dear one.

1834ABCD

Find the shortest path from A to E. β†’ 9

  1. A β†’ E direct: 10
  2. A β†’ B β†’ C β†’ D β†’ E: 2 + 2 + 3 + 2 = 9
  3. More stops, but less total
  4. The smallest is 9

Fewer stops, but a bigger total.

223210ABCDE

Find the shortest path from A to E. β†’ 12

  1. A β†’ C β†’ E: 3 + 10 = 13
  2. A β†’ C β†’ D β†’ E: 3 + 4 + 5 = 12
  3. A β†’ B β†’ C β†’ E: 7 + 2 + 10 = 19
  4. A β†’ B β†’ C β†’ D β†’ E: 7 + 2 + 4 + 5 = 18
  5. The smallest is 12

List every route and add each one.

7324105ABCDE

Home is A and school is C. Via the shop B it is 2 km then 6 km. Via the park D it is 4 km then 3 km. Which way is shorter? β†’ Via the park, 7 km

  1. Via the shop: 2 + 6 = 8 km
  2. Via the park: 4 + 3 = 7 km
  3. The park way is shorter: 7 km

Add each way. 7 is less than 8.

2643ABCD

Watch out

  • β€œFewest roads is quickest.” No: add the numbers. More roads can add up to less.
  • β€œTake the cheapest road each time.” No: it can lead to a dear road later. Check every route.
  • Missing a route or adding a wrong number. Write the sum, like 3 + 4 + 5 = 12.
Start the lesson β–Ά