Day 21 — Shortest Paths
This chapter is being written. Check back soon!
What you’ll learn here
- BFS — the simplest shortest-path algorithm, perfect for unweighted graphs
- Dijkstra’s algorithm — O((V + E) log V) with a priority queue, for non-negative weights
- Bellman-Ford — slower (O(V·E)) but handles negative edge weights and detects negative cycles
- Floyd-Warshall — all-pairs shortest paths in O(V³), great for dense graphs
Picking the right algorithm depends on the graph: which weights, how dense, do you need one path or all of them.