adj is the adjacency matrix such that adj [ i ] [ j ] = 1 when there is an edge between i and j
adj = dict . fromkeys ( range ( n + 1 ) ) ; NEW_LINE for i in range ( n + 1 ) : NEW_LINE INDENT adj [ i ] = [ 0 ] * ( n + 1 ) ; NEW_LINE DEDENT