# Prim’s Algorithm C Program

## C Program To Implement Prim’s Algorithm For Minimum Spanning Tree

Learn How To Create a Minimum Spanning Tree using Prim’s Algorithm in C Programming Language. Prim’s Algorithm is a Greedy Algorithm approach that works best by taking the nearest optimum solution.

In the Prim’s Algorithm, every vertex is given a status which is either Temporary or Permanent. Initially all the vertices are temporary and at every step, a temporary vertex is made permanent vertex. The algorithm stops after all the vertices are made permanent.

The temporary vertices are those that have not been included in the Tree whereas the permanent vertices are those that have been included in the tree. Every vertex is associated with a length and predecessor.

#### What is Minimum Spanning Tree?

A Spanning Tree of a graph G whose sum of the weights is minimum amongst all the spanning trees of G, is called the Minimum Spanning Tree of the graph G.

Must Read: C Program For Warshall’s Algorithm To Find Path Matrix

#### C Program To Implement Prim’s Algorithm to Find Minimum Spanning Tree

Must Read: C Program To Solve Producer Consumer Problem

#### Output

In case you get any Compilation Errors or any doubts in this Code To Make Minimum Spanning Tree using Prim’s Algorithm in C Programming, let us know about it in the Comment Section below. Check this article on GeeksforGeeks for more information on Prims Algorithm.

#### Tushar Soni

I am Tushar Soni, Co - Founder of CodingAlpha. I am a computer science student from India and passionate about Web Development and Programming. Connect with me on Facebook | LinkedIn | Google Plus

### 7 thoughts on “Prim’s Algorithm C Program”

• August 23, 2016 at 2:48 am

Awesome code. Finally I found something working.

• August 23, 2016 at 2:51 am

Is there any similarity between Kruskal’s Algorithm and Prim’s Algorithm?

• August 24, 2016 at 7:44 am

Both these algorithms can be used to find Minimum Spanning Trees. Apart from this, there are no similarities.

• September 13, 2016 at 11:24 am

Are there any other algorithms alternative to Prims algorithm to find minimum soanning trees?

• October 1, 2016 at 8:26 pm

i believe that this is a very important interview question.