# Word ladder

> Shortest word ladders, distance profiles, and connected components over Knuth's Stanford GraphBase five-letter words, solved over four representations of the same graph: an implicit adjacency that stores no edge, and the three stored layouts of `knotkit/graph`.

Shortest word ladders, distance profiles, and connected components over Knuth’s Stanford GraphBase five-letter words, solved over four representations of the same graph: an implicit adjacency that stores no edge, and the three stored layouts of `knotkit/graph`.

## Result

> 16 shortest ladders take 0.79 ms on compressed-sparse-row against 14.12 ms on the implicit graph; packed postings retain 96.8% less memory

## Modules

* [`knotkit/graph`](/modules/graph/): Provides breadth-first search, Dijkstra, topological order, and connected components over integer-vertex graphs, stored as adjacency lists, compressed sparse rows, or an adjacency matrix
* [`knotkit/inverted-index`](/modules/inverted-index/): Indexes records by exact keys and scans sorted record IDs for one key or the union of several, using packed posting lists

## Figures

* chaos to order: 12 single-letter changes.
* chaos -> chaps -> chops -> coops -> corps -> cores -> codes -> coder -> cider -> eider -> elder -> older -> order
* The Stanford GraphBase dictionary has 5757 words. From chaos, 1264 are unreachable.

Hover or focus a chart for exact values. Drawn by [`demo.ts`](https://github.com/jkomyno/knotkit/blob/main/problems/word-ladder/demo.ts) at build time, from the fixtures the benchmark uses; it reproduces the README figure.

## Reproduce

```bash
git clone https://github.com/jkomyno/knotkit.git && cd knotkit && bun install
bun run demo:problem:word-ladder
```

[`problems/word-ladder/README.md`](https://github.com/jkomyno/knotkit/blob/main/problems/word-ladder/README.md) states the fixture, the seed, and the result table.
