In case the preudo-code is still unclear after Knute's tips, maybe this will help you as well.
We start with an empty edge set F. Also is given a 2D weight matrix W[][], that gives for each pair of vertices (i, j) the weight (or distance). And, not unimportant, the arrays here start with 1, instead of 0.
Pick a vertex, say vertex 1 (assumng the vertices are named 1...n).
Now, for every other vertex, set vertex 1 as its nearest neighbor. Secondly, set the distance from every vertex i (i = 2...n) to vertex 1 (or, more general, to the start vertex we are dealing in this round) to W[1][i].
This is happening in this part (and now you see the disadvantage of using an image instead of real code, I cannot copy the relevant passage, and so must type it in. Next time, please supply real text)
Main loop: We enter he loop in the preudo-code with "repeat n-1 times"...
1) find the edge with the minimum distance to vertex 'nearest[i]' (which is initially vertex 1), but only if that weight is >= 0 and less than infinity. As you can see, if two vertices are not connected, then you can set the distance safely to -1, it will then not be considered anymore
2) call the vertex that is closest to vertex 'nearest[i]' vnear.
3) all this is happening in the loop right behind the line 'min = infinity'.
3) add the edge (neares[i], vnear) to F. In the first round, as said, nearest[i] is vertex 1.
4) Now in the loop at the bottom: set for all vertices, starting with vertex 2, the distance to W[i][vnear]
and set nearest[i] to vnear. As you saw, vertices that are already in F have their distance set to -1 and are not considered anymore)
5) in fact this is the same routine as we applied before entering the main loop. There we started with vertex 1, but now we start with vertex vnear
And goto main loop again until done.
Well there are some preconditions for the graph to apply this algo. In the first place, the graph must be connected. And the W[][] must start with a suitable vertex. Can you tell us a bit about the given preconditions?
And lastly: I found some old topic about MST, where a structure called 'unionfind' was used to good effect. Maybe it is of any use.
Here is the link:
click here
Edit: I haven't looked at your code yet, but it seems rather large. Do you have any questions about your code?