Adjacency list of graph
adj = defaultdict ( list ) NEW_LINE for i in range ( v ) : NEW_LINE INDENT for j in range ( i + 1 , v ) : NEW_LINE INDENT if graph [ i ] [ j ] != 0 : NEW_LINE INDENT adj [ i ] . append ( [ graph [ i ] [ j ] , j ] ) NEW_LINE adj [ j ] . append ( [ graph [ i ] [ j ] , i ] ) NEW_LINE DEDENT DEDENT DEDENT