How to optimize Prims algorithm

I want to find the weight of the maximum spanning tree using prims algo. But My code is showing TLE.
How can I Optimise my code?
My solution -https://ide.codingblocks.com/s/351652