Skip to content

Presets

Each preset carries the phenomenon it exists to show. Open one, then press play.

  • A minimal edit

    One line changes. D is small and most of the lattice is one long snake — this is why diff is fast on real edits.

  • A pure insertion

    Nothing is deleted. The path only moves down, then runs the diagonal: D equals the number of inserted lines.

  • A pure deletion

    The mirror of a pure insertion: the path only moves right. D equals the number of deleted lines.

  • A transposition

    Two blocks swap places. A line diff has no notion of "move", so one block is deleted and inserted again elsewhere.

  • The misattributed brace

    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-misattribution
  • Where patience wins

    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.

  • The worst case

    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.

  • Character granularity

    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.