biotite.structure.find_connected(bond_list, root, as_mask=False)[source]

Get indices to all atoms that are directly or inderectly connected to the root atom indicated by the given index.

An atom is connected to the root atom, if that atom is reachable by traversing an arbitrary number of bonds, starting from the root. Effectively, this means that all atoms are connected to root, that are in the same molecule as root. Per definition root is also connected to itself.


The reference bond list.


The index of the root atom.

as_maskbool, optional

If true, the connected atom indices are returned as boolean mask. By default, the connected atom indices are returned as integer array.

connectedndarray, dtype=int or ndarray, dtype=bool

Either a boolean mask or an integer array, representing the connected atoms. In case of a boolean mask: connected[i] == True, if the atom with index i is connected.


Consider a system with 4 atoms, where only the last atom is not bonded with the other ones (0-1-2 3):

>>> bonds = BondList(4)
>>> bonds.add_bond(0, 1)
>>> bonds.add_bond(1, 2)
>>> print(find_connected(bonds, 0))
[0 1 2]
>>> print(find_connected(bonds, 1))
[0 1 2]
>>> print(find_connected(bonds, 2))
[0 1 2]
>>> print(find_connected(bonds, 3))