Initializing every node as a tree with single node .
for i in range ( n ) : NEW_LINE INDENT id [ i ] = i NEW_LINE sz [ i ] = 1 ; NEW_LINE DEDENT e = [ Edge ( 1 , 2 ) , Edge ( 1 , 3 ) , Edge ( 2 , 4 ) , Edge ( 2 , 5 ) , Edge ( 4 , 6 ) , Edge ( 6 , 7 ) ] NEW_LINE q = len ( e ) NEW_LINE UnionUtil ( e , W , q ) ; NEW_LINE