feat: add BMSSP single-source shortest paths - #788
Open
tachsin wants to merge 1 commit into
Open
Conversation
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>
samueltardieu
force-pushed
the
feat/sssp
branch
from
September 7, 2026 11:07
e98f893 to
ec515dd
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Zero-cost edges can cause the recursive base case to loop indefinitely.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds BMSSP-based single-source shortest-path APIs alongside existing directed graph algorithms.
Changes:
- Implements
ssspandsssp_all. - Exports the APIs through the directed module and prelude.
- Adds comparisons against Dijkstra across several graph types.
File summaries
| File | Description |
|---|---|
src/directed/sssp.rs |
Implements BMSSP and path reconstruction support. |
src/directed/mod.rs |
Registers the SSSP module. |
src/lib.rs |
Documents and exports SSSP APIs. |
tests/sssp.rs |
Adds correctness tests against Dijkstra. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+332
to
+336
| let b_prime = seen.iter().filter_map(|&v| self.dist[v]).max(); | ||
| let u: Vec<usize> = seen | ||
| .into_iter() | ||
| .filter(|&v| self.dist[v].is_some_and(|dv| less_than(&dv, b_prime))) | ||
| .collect(); |
Comment on lines
+8
to
+9
| //! A linear repair pass fixes nodes left stale when many paths share a length | ||
| //! (the paper assumes unique path lengths). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 asdijkstra/dijkstra_all:sssp_all(start, successors) -> HashMap<N, (N, C)>sssp(start, successors, success) -> Option<(Vec<N>, C)>build_pathworks on thesssp_allmap.What this is not
BTreeMap, and the reachable implicit graph is materialized first.ssspcomputes all distances, then picks a cheapest successful node. Usedijkstrawhen 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 ssspdijkstra_allon the small tree, random graphs, and a gridsssppath to a goal matchesdijkstraon a finite graphCloses #730
Made with Cursor