Add edges to the vector along with the values of the node
for i in range ( 0 , n ) : NEW_LINE INDENT g [ u [ i ] ] . append ( ( val [ v [ i ] ] , v [ i ] ) ) NEW_LINE g [ v [ i ] ] . append ( ( val [ u [ i ] ] , u [ i ] ) ) NEW_LINE DEDENT