Carrying out normal Kruskal Algorithm
for ( int u = 1 ; u <= n ; u ++ ) { for ( int v : g [ u ] ) { int x = find ( u ) ; int y = find ( v ) ; if ( x == y ) continue ; union ( x , y ) ; System . out . println ( u + " ▁ " + v ) ; } } }