def parse_neighbors(neighbors, vars=[]):
dict = DefaultDict([])<EOL>for var in vars:<EOL><INDENT>dict[var] = []<EOL><DEDENT>specs = [spec.split('<STR_LIT::>') for spec in neighbors.split('<STR_LIT:;>')]<EOL>for (A, Aneighbors) in specs:<EOL><INDENT>A = A.strip()<EOL>dict.setdefault(A, [])<EOL>for B in Aneighbors.split():<EOL><INDENT>dict[A].append(B)<EOL>dict[B].append(A)<EOL><DEDENT><DEDENT>return dict<EOL>
Convert a string of the form 'X: Y Z; Y: Z' into a dict mapping
    regions to neighbors.  The syntax is a region name followed by a ':'
    followed by zero or more region names, followed by ';', repeated for
    each region name.  If you say 'X: Y' you don't need 'Y: X'.
    >>> parse_neighbors('X: Y Z; Y: Z')
    {'Y': ['X', 'Z'], 'X': ['Y', 'Z'], 'Z': ['X', 'Y']}