-
-
Notifications
You must be signed in to change notification settings - Fork 342
Add-Prims's Algorithm for MST #248
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 PR adds a comprehensive implementation of Prim's algorithm for computing the Minimum Spanning Tree (MST) of weighted, undirected graphs in R. The implementation includes input validation, helper functions, and multiple examples demonstrating various use cases.
- Introduces
prim_mst()function with O(V²) adjacency matrix implementation - Adds utility functions for MST visualization and graph construction from edge lists
- Provides five detailed examples covering basic graphs, edge lists, disconnected graphs, and complete graphs
|
✅ Updated Prim’s MST R implementation |
|
@siriak please have a look |
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 3 comments.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.
PR: Prim's Algorithm for Minimum Spanning Tree (MST)
This PR introduces a fully documented implementation of Prim's Algorithm in R, designed to compute the Minimum Spanning Tree (MST) of a connected, weighted, undirected graph. The algorithm efficiently grows the MST by repeatedly adding the minimum-weight edge connecting the already included vertices to a new vertex.
Overview
Prim's algorithm operates as follows:
The implementation supports both adjacency matrix and edge list representations, includes input validation, and provides formatted MST output.
Features
Complexity
Applications
Demonstration
Run the included examples to see Prim's Algorithm in action: