Loop through all the values of the nodes which are not yet included in MST and find the minimum valued one .
for ( int i = 0 ; i < n ; i ++ ) { if ( mstset [ i ] == false && keyval [ i ] < mini ) { mini = keyval [ i ] , mini_index = i ; } } return mini_index ; }