-
-
Notifications
You must be signed in to change notification settings - Fork 331
Implement Kruskal's Minimum Spanning Tree algorithm #197
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?
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 implements Kruskal's algorithm for finding Minimum Spanning Trees (MST) in weighted undirected graphs. The implementation uses a Disjoint Set Union data structure with path compression and union by rank optimization for efficient cycle detection.
Key changes:
- Adds complete MST algorithm with Union-Find data structure
- Includes comprehensive example demonstrating usage on a 4-vertex graph
- Follows repository standards with base R implementation and no external dependencies
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Implemented Kruskal's algorithm to find the Minimum Spanning Tree (MST) of a connected, weighted, undirected graph.
Utilizes Disjoint Set Union (Union–Find) with path compression and union by rank for efficient edge merging.
Accepts edge list input (u, v, w) and number of vertices n.
Returns both the total weight and the edges included in the MST.
Added a simple example demonstrating usage with a 4-node graph.
Written in base R, with no external dependencies, consistent with repository standards.