A djacency list to store neighbors of each array element
for it in A : NEW_LINE INDENT mp [ it [ 0 ] ] . append ( it [ 1 ] ) NEW_LINE mp [ it [ 1 ] ] . append ( it [ 0 ] ) NEW_LINE DEDENT start = 0 NEW_LINE