42 worked problems

Graphs

BFS, DFS, shortest paths and spanning trees. Entities form arbitrary connections and the task asks about reachability, ordering, shortest paths, or connectivity.

Recognition signal

When should you think of Graphs?

Entities form arbitrary connections and the task asks about reachability, ordering, shortest paths, or connectivity.

Core invariant

What must stay true?

Visited or distance state records the strongest fact proven for each vertex so far.

Practice in a deliberate order

What to learn in this cluster

  1. 01BFS and DFS
  2. 02Topological order and components
  3. 03Shortest paths and spanning trees

All Graphs problems

42 of 42 walkthroughs
Continue the cluster

Related patterns and study guides