TweakCode
Graphs lessons

Course 04 · Orientation

Graphs

Decision trees and adjacency

Choose, recurse, undo. Then graphs: floods, copies, dependency order, union-find, weighted shortest paths, and graphs built from data.

Start with Backtracking

The course journey

Build one family of skills at a time

Each technique is three short lessons, and each one builds on the lesson before it. A lesson walks through one problem step by step, then hands it to you along with a few more to solve on your own.

  1. 01Start here

    Backtracking

    Choose, explore, unchoose: include or skip each element, place unused ones in order, and cut paths the moment a rule breaks.

    1. Stage 1Subsets & Include/Exclude DecisionsBranch on taking or skipping each element to explore 2^n subsets1 Lesson · 3 Problems
    2. Stage 2Permutations & Used-State TrackingPick any unused element next and undo the choice on return1 Lesson · 3 Problems
    3. Stage 3Constraint Pruning on Grids & BoardsAbandon partial paths the moment a placement violates a rule1 Lesson · 3 Problems
  2. 02Pro

    Graphs

    Nodes, edges, and a visited set. Depth-first and breadth-first are the two walks.

    1. Stage 1

      Connected Components with DFS

    2. Stage 2

      Graph Traversal with a Visited Map

    3. Stage 3

      Topological Sort

    Preview
  3. 03Pro

    Advanced Graphs

    Peel dependencies in layers, settle weighted shortest paths with a heap, and merge components with union-find.

    1. Stage 1

      Topological Sort & Indegree Queues

    2. Stage 2

      Weighted Shortest Paths (Dijkstra)

    3. Stage 3

      Union-Find (Disjoint Set)

    Preview