Class BondTable

  • All Implemented Interfaces:
    Serializable, Cloneable

    @PublicAPI
    public abstract class BondTable
    extends Object
    implements Serializable, Cloneable
    Provides easy lookup of bonds between pair of atoms in a molecule graph. This class is an abstraction of the NxN square matrix for a molecule graph containing N atoms, for which matrix[i][j] and matrix[j][i] are the index of the bond between the atoms with indexes i and j, or -1 if there is no bond between the atoms.
    Since:
    Marvin 5.4
    See Also:
    Serialized Form
    • Field Detail

      • DEFAULT_VALUE

        public static final int DEFAULT_VALUE
        The default (null) value in the matrix.
        See Also:
        Constant Field Values
    • Method Detail

      • createBondTable

        public static BondTable createBondTable​(int atomCount,
                                                int bondCount)
        Creates a new bond table for a molecule graph with the specified number of atoms and bonds. Initially, all values are set to -1.
        Parameters:
        atomCount - the number of atoms (the number of rows and columns of the matrix)
        bondCount - the number of bonds (required for the selection of optimized implementations)
      • cloneBondTable

        public static BondTable cloneBondTable​(BondTable bondTable)
        Clones the bond table. Makes a deep copy.
        Parameters:
        bondTable - the matrix to copy, has to be not null.
      • getAtomCount

        public final int getAtomCount()
        Returns the number of atoms in the molecule this bond table represents. (This is the number of rows and columns of the matrix array.)
        Returns:
        the number of atoms (rows, columns).
      • getBondIndex

        public abstract int getBondIndex​(int i,
                                         int j)
        Returns the index of the bond connecting two atoms, or -1 if the two atoms are not connected.
        Parameters:
        i - the first atom index
        j - the second atom index
        Returns:
        the connecting bond index, or -1 if there is no such bond
      • setBondIndex

        public final void setBondIndex​(int i,
                                       int j,
                                       int bondIndex)
        Sets the index of the bond connecting two atoms. If the bond index is -1, the connection is removed.
        Parameters:
        i - index of the first atom
        j - index of the second atom
        bondIndex - index of the bond connecting atoms i and j