Create adjacency matrix
adj = [ [ 0 for i in range ( n + 1 ) ] for i in range ( n + 1 ) ] NEW_LINE for i in range ( len ( edges ) ) : NEW_LINE INDENT adj [ edges [ i ] [ 0 ] [ 0 ] ] [ edges [ i ] [ 0 ] [ 1 ] ] = edges [ i ] [ 1 ] NEW_LINE DEDENT