def bonded(self, n1, n2, distance):
if distance > self.max_length * self.bond_tolerance:<EOL><INDENT>return None<EOL><DEDENT>deviation = <NUM_LIT:0.0><EOL>pair = frozenset([n1, n2])<EOL>result = None<EOL>for bond_type in bond_types:<EOL><INDENT>bond_length = self.lengths[bond_type].get(pair)<EOL>if (bond_length is not None) and(distance < bond_length * self.bond_tolerance):<EOL><INDENT>if result is None:<EOL><INDENT>result = bond_type<EOL>deviation = abs(bond_length - distance)<EOL><DEDENT>else:<EOL><INDENT>new_deviation = abs(bond_length - distance)<EOL>if deviation > new_deviation:<EOL><INDENT>result = bond_type<EOL>deviation = new_deviation<EOL><DEDENT><DEDENT><DEDENT><DEDENT>return result<EOL>
Return the estimated bond type

           Arguments:
            | ``n1``  --  the atom number of the first atom in the bond
            | ``n2``  --  the atom number of the second atom the bond
            | ``distance``  --  the distance between the two atoms

           This method checks whether for the given pair of atom numbers, the
           given distance corresponds to a certain bond length. The best
           matching bond type will be returned. If the distance is a factor
           ``self.bond_tolerance`` larger than a tabulated distance, the
           algorithm will not relate them.