To store edges with weight '1
' NEW_LINE INDENT mp2 = [ [ ] for i in range ( n + 1 ) ] NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT for j in range ( 1 , n + 1 ) : NEW_LINE INDENT if ( i == j ) : NEW_LINE INDENT continue NEW_LINE DEDENT if ( adj [ i ] [ j ] == '0' ) : NEW_LINE INDENT mp1 [ i ] . push ( j ) NEW_LINE DEDENT else : NEW_LINE INDENT mp2 [ i ] . push ( j ) NEW_LINE DEDENT DEDENT DEDENT DEDENT