def check_perm_structure_preservation(mol, perm):
    """
    checks what percent of a permutation does not break bonds in the molecule--
    so a return value of 1 would be a perfectly preserved bond structure, of 0.5 would mean half of the molecules bonds are broken
    :param mol: the molecule being permuted
    :param perm: the permutation whose structure preservation is being measured
    :return: percent of bonds that are preserved
    """
    if len(mol.bondset) == 0:
        raise ValueError('Molecule does not have any bond information')
    broken = 0
    for origin, destination in enumerate(perm):
        for adjacent in mol.atoms[origin].adjacent:
            if (destination, perm[adjacent]) not in mol.bondset:
                broken += 1
    percent_structure = (len(mol.bondset) - broken) / len(mol.bondset)
    return percent_structure
