topological-sort

← ~/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

⏮◀◀▶▶STEP0.25x1xZOOM

t=0s

practical uses #

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.

← mechanism-designjacobian →