Add methods for efficient counting of paths between vertices.#93
Merged
davecom merged 5 commits intodavecom:masterfrom Jan 6, 2026
Merged
Add methods for efficient counting of paths between vertices.#93davecom merged 5 commits intodavecom:masterfrom
davecom merged 5 commits intodavecom:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request adds several methods to the Graph protocol to enable efficient counting of paths between vertices in a graph. The implementation includes optimizations using reachability precomputation to avoid exploring dead-end paths.
Key Changes:
- Added methods for path counting with exhaustive search algorithms including basic and optimized versions
- Added helper methods for checking path existence and computing reachability
- Added comprehensive test coverage using an Advent of Code sample graph
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.
| File | Description |
|---|---|
| Sources/SwiftGraph/Graph.swift | Adds five new methods to the Graph extension: neighborIndicesForIndex, pathExists, two overloads of countPaths (basic and optimized with reachability), and reachabilityOf for computing vertex reachability |
| Tests/SwiftGraphTests/SwiftGraphTests.swift | Adds Foundation import, new test method testExhaustivePathCounting to exercise the path counting methods, and helper method getAoCGraph that deserializes a test graph from JSON |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update documentation as suggested. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Owner
|
Thanks for the contribution, @sbeitzel |
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.
This adds several methods to the
Graphprotocol to allow some optimizations for counting the number of paths between two vertices.