— Ok, I think I get that ugly code... you are looking for the smallest cost link to an unvisited node (that's the 2 inner loops), every time you get a link, you are basically adding one node to the solution, thus you need to repeat (n-1) times, because the initial node was already added, that's why ne goes from 1 to (n-1)
Message permanent page