Skip to content

Advanced Graphs

Once edges have weights (distance, cost, time) plain BFS is not enough. Here you learn shortest paths with a heap (Dijkstra), cheapest ways to connect everything (minimum spanning tree) and ordering with dependencies.

After this topic: You can pick between BFS, Dijkstra, Bellman-Ford style relaxation and a spanning-tree algorithm, and implement each with a heap.

Do these first: Graphs

0 of 6 solved0%

Step 1 · Read the lesson

Advanced Graphs · Dijkstra & Spanning Trees

Weighted graphs: cheapest paths with a heap, cheapest ways to connect everything, and ordering by rules.

Step 2 · Solve the problems in order

Try each one for about 20 minutes first. Problems with a Run code tab are checked right here. If you are stuck, open Nudge, think again, then Idea. Go skeleton only gives the function shape, and Reference solution is for comparing after you have tried. Tick the box when you could solve it again without help.

  1. 1.Reconstruct ItineraryHard
  2. 2.Min Cost to Connect All PointsMedium
  3. 3.Network Delay TimeMedium
  4. 4.Swim in Rising WaterHard
  5. 5.Alien DictionaryHard
  6. 6.Cheapest Flights Within K StopsMedium