Python Quest

Track 16 · Lesson 11 of 12

Graphs: routes, networks and hierarchies

Represent connections as adjacency lists, find shortest routes with breadth-first search, and explore networks and org charts with depth-first search.

About 55 minAdvanced4 exercises

You will be able to

  • Model roads, friendships and reporting lines as graphs stored in a dict of adjacency lists
  • Find the shortest route by number of steps with breadth-first search and rebuild the path
  • Explore everything reachable with depth-first search, iteratively or recursively
  • Count connected components and protect searches against cycles with a visited set

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.