Prim's algorithm

can you please write the same algo in C language and help me understand?

Why are you trying to do this problem in c. It would require heapify function of implement. Instead use priority queue in c++.