feat(graph): add adjacency-list road network - #3
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 2 of the Roadrunner roadmap with a manually owned, directed adjacency-list graph in
roadrunner-core.NodeIdandEdgeIdtypes with stable serializationNodeand directedEdgedomain typesGraphstorage with a separate edge identity indexGraph operations
The graph now supports:
add_nodeadd_edgeremove_edgeneighborsnodeandedgelookupnode_countandedge_countcontains_nodeEdges are stored once in their source node's outgoing adjacency list. One-way roads use one directed edge; bidirectional roads use reciprocal edges. Duplicate node and edge identities are rejected, while parallel edges with distinct
EdgeIdvalues are allowed as specified in Phase 0.Phase boundary
Nodeintentionally contains only its identity in Phase 2. Validated coordinates and geographic units arrive in Phase 3, avoiding raw latitude/longitude values in the graph API. Edge distance and travel-time attributes remain deferred to the geographic and cost-model phases. No shortest-path implementation is included.Tests
The graph tests cover:
Benchmark
graph_traversalconstructs deterministic directed ring-lattice graphs with fan-out 3 and traverses them breadth-first from node 0.cargo bench -p roadrunner-core --bench graph_traversal --lockedThe benchmark was compiled and executed locally at all three sizes. This PR makes no cross-machine performance claim and does not commit generated Criterion output.
Validation
cargo fmt --all -- --checkcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test --workspace --all-features --lockedcargo bench -p roadrunner-core --bench graph_traversal --no-run --lockedcargo bench -p roadrunner-core --bench graph_traversal --lockedgit diff --check main...HEAD