Traverse the matrix to create adjacency list
for i in range ( N ) : NEW_LINE INDENT for j in range ( N ) : NEW_LINE INDENT if ( mat [ i ] [ j ] == 1 ) : NEW_LINE INDENT Adj [ i ] . append ( j ) NEW_LINE DEDENT DEDENT DEDENT