def _matrix2dict(matrix, etype=False):
n = len(matrix)<EOL>adj = {k: {} for k in range(n)}<EOL>for k in range(n):<EOL><INDENT>for j in range(n):<EOL><INDENT>if matrix[k, j] != <NUM_LIT:0>:<EOL><INDENT>adj[k][j] = {} if not etype else matrix[k, j]<EOL><DEDENT><DEDENT><DEDENT>return adj<EOL>
Takes an adjacency matrix and returns an adjacency list.