Start Learning
Javaneer
Back to roadmap
🕸️
Stage 5

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.

5 Lessons in this stage1 h 16 min
Start the first lesson

Lessons in this stage

  1. 01

    Representing a Graph

    Intermediate

    Adjacency 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
  2. 02

    BFS & DFS

    Advanced

    The 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
  3. 03

    Grids as Graphs

    Intermediate

    Counting 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
  4. 04

    Topological Sort

    Advanced

    Ordering tasks so every dependency comes first - course schedules, build systems - and how it detects cycles along the way.

    15 min
  5. 05

    Shortest Paths & Union-Find

    Advanced

    Dijkstra for weighted shortest paths, and union-find (disjoint sets) for connectivity and grouping in near-constant time.

    16 min