Skip to content

Conversation

@sbeitzel
Copy link
Contributor

This adds several methods to the Graph protocol to allow some optimizations for counting the number of paths between two vertices.

Copy link
Contributor

Copilot AI left a 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.

sbeitzel and others added 4 commits January 6, 2026 12:54
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>
@davecom davecom merged commit bf70e67 into davecom:master Jan 6, 2026
1 check passed
@davecom
Copy link
Owner

davecom commented Jan 6, 2026

Thanks for the contribution, @sbeitzel

@sbeitzel sbeitzel deleted the feature/exhaustive_dfs branch January 6, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants