def adjacency_matrix(parent1, parent2):
    """Return the union of parent chromosomes adjacency matrices."""
    neighbors = {}
    end = len(parent1) - 1
    for parent in [parent1, parent2]:
        for k, v in enumerate(parent):
            if v not in neighbors:
                neighbors[v] = set()
            if k > 0:
                left = k - 1
            else:
                left = end
            if k < end:
                right = k
            else:
                right = 0
            neighbors[v].add(parent[left])
            neighbors[v].add(parent[right])
    return neighbors
