Skip to content

feat(ch25): complete Johnson's algorithm — end-to-end correctness (#104) - #113

Open
TankTechnology wants to merge 2 commits into
mainfrom
feat/johnson-algorithm-issue-104
Open

feat(ch25): complete Johnson's algorithm — end-to-end correctness (#104)#113
TankTechnology wants to merge 2 commits into
mainfrom
feat/johnson-algorithm-issue-104

Conversation

@TankTechnology

Copy link
Copy Markdown
Owner

Summary

Completes Johnson's algorithm for all-pairs shortest paths (Issue #104).

New definitions

  • johnsonAugmentedGraph: augmented graph with new source none and zero-weight edges to all vertices
  • reweightedWeight / reweightedGraph: reweighting with a potential function h
  • johnsonPotential: Bellman-Ford potential h(v) = δ(none, some v)
  • johnsonAllPairsDist: end-to-end Johnson distance function

New theorems

Theorem CLRS reference
isShortestDist_edge_ineq General triangle inequality
walk_johnsonAugmented_some_projection Walk projection from augmented graph
noNegCycle_johnsonAugmentedGraph Negative-cycle preservation
reweightedWalkWeight_eq Telescoping property (Equation 25.10)
reweightedWeight_nonneg Nonnegative reweighted weights
reweighted_isShortestDist Shortest-path preservation (shift formula)
johnsonPotential_finite Potential is always finite
johnsonPotential_isShortestDist Potential satisfies IsShortestDist
johnsonPotential_triangle Lemma 25.3: h(v) ≤ h(u) + w(u,v)
johnsonReweightedNonneg Reweighted graph is nonnegative
johnsonAllPairsDist_correct Theorem 25.6: End-to-end correctness

Proof structure

  1. Add none source with 0-weight edges → augmented graph
  2. Prove no negative cycles are introduced (projection lemma + case analysis)
  3. Run Bellman-Ford from none on augmented graph → potential h
  4. Prove h satisfies triangle inequality (Lemma 25.3) via isShortestDist_edge_ineq
  5. Reweight graph with h → nonnegative weights → Dijkstra applies
  6. Run Dijkstra from each vertex → recover true distances via shift formula (Theorem 25.6)

Bookkeeping

  • docs/proof-map.md: Section 25.3 status partialproved
  • docs/clrs-proof-progress.csv: Ch25 partialmain-proof-complete, missing groups 2 → 1
  • Module doc comment updated to list all theorems

Closes #104

🤖 Generated with Claude Code

TankTechnology and others added 2 commits July 22, 2026 21:04
…sue #104)

Add the full Johnson algorithm implementation for all-pairs shortest paths:

- isShortestDist_edge_ineq: general triangle inequality for shortest-path distances
- walk_johnsonAugmented_some_projection: project walks from augmented graph to original
- noNegCycle_johnsonAugmentedGraph: negative-cycle preservation in augmented graph
- johnsonPotential: Bellman-Ford potential h(v) = δ(none, some v)
- johnsonPotential_finite: the potential is always finite
- johnsonPotential_isShortestDist: potential satisfies IsShortestDist
- johnsonPotential_triangle: h(v) ≤ h(u) + w(u,v) for every edge (CLRS Lemma 25.3)
- johnsonReweightedNonneg: reweighted graph has nonnegative weights
- johnsonAllPairsDist: end-to-end Johnson distance function
- johnsonAllPairsDist_correct: correctness theorem (CLRS Theorem 25.6)

Update proof-map.md: Section 25.3 status partial → proved.
Update clrs-proof-progress.csv: Ch25 status partial → main-proof-complete,
missing core groups 2 → 1.

Co-Authored-By: Claude <noreply@anthropic.com>
Add doc comments for johnsonPotential, johnsonPotential_eq, and
johnsonPotential_isShortestDist.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ch25.3: Johnson end-to-end — |V|×Dijkstra wrapper and O(VE log V) correctness

1 participant