Generation
# Dijkstra's Algorithm
**Definition:** Dijkstra's algorithm finds the shortest path from a starting node to all other nodes in a weighted graph with non-negative edge weights. It works by repeatedly selecting the unvisited node with the smallest known distance and updating its neighbors.
## Short Worked Example
Find the shortest path from A to all other nodes:
```
Graph:
A ---2--- B
| |
1 3
| |
C ---1--- D
```
**Steps:**
| Step | Current | Distances [A, B, C, D] | Visited |
|------|---------|------------------------|---------|
| 0 | - | [0, ∞, ∞, ∞] | {} |
| 1 | A | [0, 2, 1, ∞] | {A} |
| 2 | C | [0, 2, 1, 2] | {A, C} |
| 3 | B | [0, 2, 1, 2] | {A, C, B} |
| 4 | D | [0, 2, 1, 2] | {A, C, B, D} |
**Result:**
- A→A: 0
- A→B: 2 (via A→B)
- A→C: 1 (via A→C)
- A→D: 2 (via A→C→D)
The algorithm maintains a priority queue of unvisited nodes, always processing the one with minimum distance, guaranteeing optimal paths.
21 tokens in · 378 tokens out · 6464 ms · $0.0057
Trail
03:05:57 received prompt_chars=62 verifiers=['scripture_anchors', 'theology_doctrine']
03:05:57 red_gate decision=pass reason=no disqualifying input patterns detected
03:06:03 base_llm_call model=anthropic/claude-sonnet-4-5 tokens_in=21 tokens_out=378 latency_ms=6463.6 cost_usd=0.0057
03:06:03 verifier:scripture_anchors verdict=NOT_APPLICABLE summary=0 Scripture citation(s) extracted
03:06:03 verifier:theology_doctrine verdict=NOT_APPLICABLE summary=no doctrine keyword patterns detected
03:06:03 floor_gate decision=pass reason=output above protective minimum; no mismatches
03:06:03 way_gate decision=pass reason=no declared way_path (Way check NA); no coercion language
03:06:03 execution_gate decision=deferred reason=no witnesses available (Witness Roll not yet constituted)
03:06:03 signed hash_algo=sha256 hash=sha256:d0019d7762db6c894a299415bc8e9b87b5ad46dcedb020ee07f5dcd0b9c8bc10