Note that the sets of monovalent atoms are now included in {S p } such that monovalent atoms can be assigned in the end. The penalty P IJ represents the number of bonds which have to be formed or broken to map atom f (J) from structure B onto atom I from structure A, while there is no distinction between bonds to atoms of sets that are not yet optimized. Therefore, minimizing the number of formed and broken bonds under this constraint is equivalent to minimizing the trace of the penalty matrix. In each iteration, a permutation between f (I) and f (J) is performed such that atoms I and J are then mapped to atoms f (J) and f (I), respectively. The corresponding change in the trace of the penalty matrix will be (P IJ -P II ) resulting from the change in element (II) of the penalty matrix, plus a contribution (P JI -P JJ ) from the change in element (JJ):