-
-
Notifications
You must be signed in to change notification settings - Fork 342
Add Hamiltonian Path in R #245
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
base: master
Are you sure you want to change the base?
Add Hamiltonian Path in R #245
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 PR adds two new algorithm implementations to the repository: a Hamiltonian Path search using backtracking and a Fast Fourier Transform (FFT) using the Cooley-Tukey recursive approach. Both implementations include comprehensive documentation and example usage.
Key Changes:
- Adds a backtracking-based Hamiltonian Path algorithm for finding paths that visit each vertex exactly once in an undirected graph
- Adds a recursive FFT implementation with automatic zero-padding for non-power-of-two inputs
- Includes detailed documentation files explaining usage, complexity, and implementation notes for both algorithms
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| graph_algorithms/hamiltonian_path.r | Implements Hamiltonian Path search using backtracking with adjacency matrix input |
| mathematics/fast_fourier_transform.r | Implements Cooley-Tukey FFT algorithm with power-of-two padding |
| documentation/hamiltonian_path.md | Documents the Hamiltonian Path implementation including usage and complexity analysis |
| documentation/fast_fourier_transform.md | Documents the FFT implementation including usage examples and complexity notes |
| @@ -0,0 +1,29 @@ | |||
| # Fast Fourier Transform (FFT) | |||
|
|
|||
| This file documents the recursive Cooley-Tukey FFT implementation added to `R/mathematics/fast_fourier_transform.r`. | |||
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.
We don't add documentation in a separate file, please remove it
Overview
The
hamiltonianPathfunction attempts to construct a valid Hamiltonian Path by recursively adding vertices to a path while ensuring adjacency and non-repetition constraints.If the input adjacency matrix does not contain a Hamiltonian Path, the algorithm reports that no valid path was found.
This implementation provides a clear, educational example of graph backtracking and can be extended to find Hamiltonian Cycles as well.
Features
TRUEif a path exists, otherwiseFALSEComplexity