-
Notifications
You must be signed in to change notification settings - Fork 83
Add methods for efficient counting of paths between vertices. #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
|
Thanks for the contribution, @sbeitzel |
This adds several methods to the
Graphprotocol to allow some optimizations for counting the number of paths between two vertices.