I know Prim's algorithm and how to implement it. I am also aware of why its time complexity is O(E + V log(V)).
We add edges E times (that is in O(E)) and choose minimum V times (that is O(V*log(V)). But I don't understand a part of it: Why V times?! I know a tree has V-1 edges, but if the heaviest edge MUST be in MST, we have to choose the minimum E times, NOT V times.
For example: a complete graph with weight 1 for each edge, except one vertex that all of the edges connected to it are with weight 10^18.