feat(routing): implement dijkstra shortest path - #6
Merged
Conversation
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 Phase 5 of the Roadrunner roadmap with a manual Dijkstra shortest-path baseline in
roadrunner-core.BinaryHeapfor the frontierHashMapCostModel, including distance and travel-time objectivesCorrectness and determinism
The implementation validates both endpoints before searching and rejects cost values whose kind differs from the model's advertised kind.
Equal-cost queue entries prefer the lower
NodeId. Outgoing edges are evaluated in(destination NodeId, EdgeId)order, so path selection does not depend onHashMapiteration or edge insertion order. Relaxation accepts only strictly lower costs, preventing equal-cost and zero-cost cycles from rewriting predecessor chains.Route reconstruction verifies that every predecessor edge still exists and reaches the expected node. Distance and route-cost accumulation revalidate floating-point results so overflow is reported rather than propagated.
Route result
RouteResultexposes:dijkstra)A source equal to its destination returns one node, zero edges, zero distance/cost, and one finalized node.
Tests
New algorithm tests cover:
The complete workspace suite contains 43 passing tests.
Benchmark
crates/roadrunner-core/benches/dijkstra.rsgenerates deterministic directed ring-lattice graphs with fan-out 3 and runs distance-cost searches from node 0 to the final node. Graph construction is outside the timed closure.Initial Apple M3 results from 20 Criterion samples per case:
The complete hardware, software, dataset, configuration, iteration counts, percentile method, and raw nanosecond summaries are recorded in
benchmarks/results/2026-09-02-apple-m3-dijkstra.json.Memory is explicitly recorded as unavailable because the repository does not yet have a controlled allocator or profiler configuration. No cross-machine performance claim is made.
Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --lockedcargo bench --workspace --no-run --lockedcargo bench -p roadrunner-core --bench dijkstra --lockedRUSTDOCFLAGS=-Dwarnings cargo doc --workspace --no-deps --lockedgit diff --check main...HEAD