[PR #815] [MERGED] feat: Prims algorithm #1332

Open
opened 2026-01-29 15:19:24 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/815
Author: @Sl1mb0
Created: 3/19/2021
Status: Merged
Merged: 3/31/2021
Merged by: @ayaankhan98

Base: masterHead: prims-algorithm


📝 Commits (10+)

  • 4f165ad Added prim.c
  • 887d24a Updated formatting in prim.c
  • 3775104 Docs: updated prim.c documentation
  • 8fda51d feat: Included testing in prim.c
  • 25fc9ce feat: eliminated globals & changed variable types
  • 2b2177e Docs: added documentation for minimum function
  • 323837f updating DIRECTORY.md
  • a48e6e8 Updated documentation
  • 2ad0af6 Docs: Changed function docs & made test function static
  • 88b1585 Docs: made further requested changes

📊 Changes

2 files changed (+204 additions, -0 deletions)

View changed files

📝 DIRECTORY.md (+1 -0)
greedy_approach/prim.c (+203 -0)

📄 Description

Description of Change

I implemented prim's algorithm and added prim.c to TheAlgorithms/C/greedy_approach.

Prim's algorithm finds a minimum spanning tree of a weighted, connected graph.
Using a 'greedy' approach to generate the MST, the algorithm searches for a minimally weighted, non-visited edge, and adds the vertex connected by that edge to the MST.

To test, compile and run.
Enter in adjacency matrix of a weighted, connected graph.

References

pg. 319 "Introduction to the Design and Analysis of Algorithms" - Anany Levitin

Checklist

  • [x ] Added description of change
  • [x ] Added file name matches File name guidelines
  • [ x] Added tests and example, test must pass
  • [ x] Relevant documentation/comments is changed or added
  • [ x] PR title follows semantic commit guidelines
  • [ x] Search previous suggestions before making a new one, as yours may be a duplicate.
  • [ x] I acknowledge that all my contributions will be made under the project's license.

Notes:


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/815 **Author:** [@Sl1mb0](https://github.com/Sl1mb0) **Created:** 3/19/2021 **Status:** ✅ Merged **Merged:** 3/31/2021 **Merged by:** [@ayaankhan98](https://github.com/ayaankhan98) **Base:** `master` ← **Head:** `prims-algorithm` --- ### 📝 Commits (10+) - [`4f165ad`](https://github.com/TheAlgorithms/C/commit/4f165ade57e25e8129e46ff7ffe073ae9377a60e) Added prim.c - [`887d24a`](https://github.com/TheAlgorithms/C/commit/887d24ac8b0c3719a94f6521cf4b293567f69625) Updated formatting in prim.c - [`3775104`](https://github.com/TheAlgorithms/C/commit/3775104b190d36d88f93152557fbb32d1dd49b1c) Docs: updated prim.c documentation - [`8fda51d`](https://github.com/TheAlgorithms/C/commit/8fda51df1b92be099f5dcfa9c73b3005a3888fc3) feat: Included testing in prim.c - [`25fc9ce`](https://github.com/TheAlgorithms/C/commit/25fc9cead6bf78b84ab5d98036350fb998871857) feat: eliminated globals & changed variable types - [`2b2177e`](https://github.com/TheAlgorithms/C/commit/2b2177ef020a4d860cc70c51aff63686823b53ca) Docs: added documentation for minimum function - [`323837f`](https://github.com/TheAlgorithms/C/commit/323837ffe7269648c0fceae47a00e8255fb756db) updating DIRECTORY.md - [`a48e6e8`](https://github.com/TheAlgorithms/C/commit/a48e6e83058e5ea32a9d468cfb1a7bdc03612546) Updated documentation - [`2ad0af6`](https://github.com/TheAlgorithms/C/commit/2ad0af6d6f36513ec5782122d066680f48657a06) Docs: Changed function docs & made test function static - [`88b1585`](https://github.com/TheAlgorithms/C/commit/88b1585218ba0046397ac6bdb38f83c6a0625395) Docs: made further requested changes ### 📊 Changes **2 files changed** (+204 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `DIRECTORY.md` (+1 -0) ➕ `greedy_approach/prim.c` (+203 -0) </details> ### 📄 Description #### Description of Change I implemented prim's algorithm and added `prim.c` to `TheAlgorithms/C/greedy_approach`. Prim's algorithm finds a minimum spanning tree of a weighted, connected graph. Using a 'greedy' approach to generate the MST, the algorithm searches for a minimally weighted, non-visited edge, and adds the vertex connected by that edge to the MST. To test, compile and run. Enter in adjacency matrix of a weighted, connected graph. <!-- Thank you for your Pull Request. Please provide a description above and review the requirements below. Contributors guide: https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md --> #### References <!-- Add any reference to previous pull-request or issue --> pg. 319 "Introduction to the Design and Analysis of Algorithms" - Anany Levitin #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x ] Added description of change - [x ] Added file name matches [File name guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#File-Name-guidelines) - [ x] Added tests and example, test must pass - [ x] Relevant documentation/comments is changed or added - [ x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [ x] Search previous suggestions before making a new one, as yours may be a duplicate. - [ x] I acknowledge that all my contributions will be made under the project's license. Notes: <!-- Please add a one-line description for developers or pull request viewers --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:19:24 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#1332