← ~/visualizations

topological-sort

Visualizes topological sorting on a DAG using Kahn’s algorithm: nodes with indegree 0 light up as the current frontier, one is selected each step and appended to the growing linear order. A second panel shows a directed cycle where the frontier becomes empty, illustrating that a topological ordering exists iff the graph is acyclic.

canvasclick to interact
t=0s

practical uses

  • 01.Build systems / task scheduling (compile steps before dependents)
  • 02.Course prerequisite planning
  • 03.Dependency resolution in package managers and pipelines

technical notes

Two side-by-side panels. Left panel simulates Kahn’s algorithm with discrete steps (~650ms) and smooth easing for highlights; edges fade when their source is removed. Right panel draws a cyclic graph with a moving token along the cycle and shows that no indegree-0 frontier exists. All drawing uses a snapped 4px grid for a blocky aesthetic and GREEN/GREEN_DIM on black.