def part2graph(parts):
    """Creates a graph (2d dict) that represents the partitioning

       note: items in 'parts' should not be integers,
             (usually strings or objects)
    """

    # create graph
    i = 0
    vertices = {}
    for part in parts:
        for item in part:
            vertices.setdefault(item, {})[i] = 1
            vertices.setdefault(i, {})[item] = 1
        i += 1
    return vertices