Graphs
The structure behind maps, networks, and dependencies.
Graphs generalize trees to any network - roads, social connections, task dependencies. Learn how to represent them, traverse with BFS and DFS, find shortest paths, sort dependencies topologically, and group connected components with union-find.
Lessons in this stage
- 01
Representing a Graph
IntermediateAdjacency list vs. adjacency matrix, directed vs. undirected, weighted vs. unweighted - and how to model a problem as a graph in the first place.
14 min - 02
BFS & DFS
AdvancedThe two fundamental traversals: breadth-first for shortest unweighted paths and levels, depth-first for connectivity and exploring fully - with a visited set to avoid cycles.
17 min - 03
Grids as Graphs
IntermediateCounting islands, flood fill, shortest path in a maze - 2D grids are graphs where each cell connects to its neighbors, and BFS/DFS solve them directly.
14 min - 04
Topological Sort
AdvancedOrdering tasks so every dependency comes first - course schedules, build systems - and how it detects cycles along the way.
15 min - 05
Shortest Paths & Union-Find
AdvancedDijkstra for weighted shortest paths, and union-find (disjoint sets) for connectivity and grouping in near-constant time.
16 min