Skip to content

feat: add BMSSP single-source shortest paths - #788

Open
tachsin wants to merge 1 commit into
evenfurther:mainfrom
tachsin:feat/sssp
Open

feat: add BMSSP single-source shortest paths#788
tachsin wants to merge 1 commit into
evenfurther:mainfrom
tachsin:feat/sssp

Conversation

@tachsin

Copy link
Copy Markdown

Summary

Implements the SSSP algorithm from Duan, Mao, Mao, Shu, Yin 2025 for #730.

The paper's BMSSP recursion (FindPivots, base-case Dijkstra, bounded multi-source calls) is wired to the same successor-function model as dijkstra / dijkstra_all:

  • sssp_all(start, successors) -> HashMap<N, (N, C)>
  • sssp(start, successors, success) -> Option<(Vec<N>, C)>

build_path works on the sssp_all map.

What this is not

  • It does not claim the paper's (O(m\log^{2/3}n)) bound. The Lemma 3.3 block queue is a BTreeMap, and the reachable implicit graph is materialized first.
  • sssp computes all distances, then picks a cheapest successful node. Use dijkstra when the successor graph is unbounded or you only need one target.

A linear repair pass at the end fixes nodes left stale when many paths share a length. The paper assumes unique path lengths; unit-cost grids do not.

Test plan

  • cargo test --test sssp
  • Costs match dijkstra_all on the small tree, random graphs, and a grid
  • sssp path to a goal matches dijkstra on a finite graph

Closes#730

Made with Cursor

Adds sssp / sssp_all following Duan et al. (arXiv:2504.17033), with
the same successor-function API as Dijkstra. Distances match Dijkstra
on finite reachable graphs.
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for freeto 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.

Implementing the SSSP algorithm

1 participant

@tachsin