Examples
Each example carries the phenomenon it exists to show. Open one, then press play.
A minimal edit
D = 2N 5 · M 5minimal scripts: 2
One line changes. D is small and most of the lattice is one long snake — this is why diff is fast on real edits.
Open in the edit graph →#p=minimal-editA pure insertion
D = 2N 3 · M 5minimal scripts: 1
Nothing is deleted. The path only moves down, then runs the diagonal: D equals the number of inserted lines.
Open in the edit graph →#p=pure-insertA pure deletion
D = 2N 5 · M 3minimal scripts: 1
The mirror of a pure insertion: the path only moves right. D equals the number of deleted lines.
Open in the edit graph →#p=pure-deleteA transposition
D = 6N 6 · M 6minimal scripts: 2
Two blocks swap places. A line diff has no notion of "move", so one block is deleted and inserted again elsewhere.
Open in the edit graph →#p=transpositionThe misattributed brace
D = 4N 7 · M 11minimal scripts: 3
A new function is inserted between two existing ones. Three edit scripts are equally minimal — step through the alternatives and one of them attributes the closing brace to the wrong function: the ugly diff everybody has seen. This implementation happens to pick a readable one; which you get is decided by tie-breaking, not by any judgement about which reads better.
Open in the edit graph →#p=brace-misattributionWhere patience wins
D = 5N 10 · M 13minimal scripts: 13
One entry is replaced by two new ones. All three algorithms agree on D = 5 — equally minimal — but Myers splits it into two separate hunks, because it is free to match the repeated "enabled" and "replicas" lines across entry boundaries. Patience refuses to anchor on any line appearing more than once, so it anchors on the unique "- name:" lines and keeps the change in one block. Same length, different readability.
Open in the edit graph →#p=patience-winsThe worst case
D = 80N 40 · M 40minimal scripts: ≥ 1,000,000
No element is shared, so D = N + M and there are no free diagonals at all. The pathological path is deliberately reachable: the search runs in a worker with a step budget, so the UI never freezes.
Open in the edit graph →#p=worst-caseCharacter granularity
D = 5N 7 · M 6minimal scripts: 7
The same input at character level. What counts as an element is a choice, not a property of diff — change the granularity and the lattice changes completely.
Open in the edit graph →#p=char-level