def matrix2dictionary(matrix):
pw = {}<EOL>for line in matrix:<EOL><INDENT>line = line.strip().split('<STR_LIT:\t>')<EOL>if line[<NUM_LIT:0>].startswith('<STR_LIT:#>'):<EOL><INDENT>names = line[<NUM_LIT:1>:]<EOL>continue<EOL><DEDENT>a = line[<NUM_LIT:0>]<EOL>for i, pident in enumerate(line[<NUM_LIT:1>:]):<EOL><INDENT>b = names[i]<EOL>if a not in pw:<EOL><INDENT>pw[a] = {}<EOL><DEDENT>if b not in pw:<EOL><INDENT>pw[b] = {}<EOL><DEDENT>if pident != '<STR_LIT:->':<EOL><INDENT>pident = float(pident)<EOL><DEDENT>pw[a][b] = pident<EOL>pw[b][a] = pident<EOL><DEDENT><DEDENT>return pw<EOL>
convert matrix to dictionary of comparisons