From Dijkstra to contraction hierarchies

A route is the answer.
Watch how we get there.

Five algorithms. The same graph. Follow the frontier, reveal the route, and see how much work each search does.

3 seeded scenes30 fixed source–goal pairs150 recorded searches

The explorer

One settled node at a time.

Keyboard guide

These are fixed presets replayed from real library runs on small synthetic graphs. The page does not compute new routes, edit graphs, or measure runtime.

Synthetic graph

Recorded search

Recorded search
Selected graph and search state. The step summary gives the state in words; the legend explains shapes and strokes.
FrontierSettledFinal route
1× · 0.40 s/step

Read the graph · full legend
  • Small grey dot: not reached yet
  • Hollow circle: frontier (discovered, not yet settled)
  • Filled circle: settled (final) by the forward search
  • Hollow dashed diamond: frontier of the reverse search
  • Filled diamond: settled by the reverse search
  • Black outer ring: the node settled at this step
  • Solid green ring and letter S: source
  • Dashed red ring and letter G: goal
  • Dark thick edge: relaxed at this step
  • Thick blue line: final route (shown when the search has finished)
  • Thin dashed line: hierarchy shortcut edge
  • Heavy dashed line: route as found on shortcuts, before unpacking
Preprocessing is separate.

The comparison

Same route problem. Different work.

Final recorded results

Compare the complete searches for your selected pair, even while the replay is paused. Lower work counts describe this query; they do not establish a universal speedup.

On a narrow screen, scroll the table horizontally to see every metric.

All methods for the selected pair.
MethodRoute costHopsNodes settledEdges relaxedOracle check
Keyboard shortcuts

Focus any playback button to use these shortcuts. Tab moves between controls; Enter or Space activates the focused button. Selects and sliders retain their native arrow keys.

← →
Step back / forward
Home End
Reset / jump to end
P
Play / pause
1–5
BFS, Dijkstra, A*, bidirectional, hierarchy
C S G
Next scene / source / goal preset; add Shift for previous

Changing a preset or algorithm pauses and resets the replay. A scene change selects that scene’s default endpoints. Speed persists for this visit. Reduced-motion mode makes Play jump to the final state.

Make sense of the result

The details that change the answer.

Cost ≠ hops

A shorter path can cost more.

A hop is one edge. Route cost sums the weights on that route. BFS minimises hops; only equal edge weights make that the same problem as finding the cheapest route.

Correctness has conditions

Read the guarantees carefully.

Weighted searches require finite, non-negative real weights. This closed-set A* needs a consistent heuristic. A missing route and a source equal to its goal are valid preset cases.

Work ≠ runtime

Count the tradeoffs, too.

Settled nodes and relaxed edges count query work, not milliseconds. Two-ended searches add both directions. Hierarchy preprocessing adds shortcut edges and uses extra memory before any query.

This is an educational replay, not a production road router or a live benchmark. All graphs are synthetic. The contraction hierarchy is a simplified, undirected teaching implementation. There is no arbitrary graph editing or computation for arbitrary endpoints.

Trace evidence & reproducibility

Recorded from 150 real library runs on 3 seeded scenes (30 source/goal pairs). When this page was built, the cost and route of every run were checked against an independent Floyd-Warshall oracle, and the cost shown at each step against the recorded events that produced it. Payload sha256: 14ba9857737d3f2a710b98e432c45f56b67aad158482cd5c318e0bc05455ee9b. The data also lists the sha256 of each library source file the traces and the oracle values came from.

The oracle checks BFS hop count separately from weighted route cost. The comparison’s oracle column explains when BFS’s weighted route is more expensive. Rebuild instructions are in the repository README.