code: def get_AC(mol, xyz):
      """
  
      Generate adjacent matrix from atoms and coordinates.
  
      AC is a (num_atoms, num_atoms) matrix with 1 being covalent bond and 0 is not
  
  
      covalent_factor - 1.3 is an arbitrary factor
  
      args:
          mol - rdkit molobj with 3D conformer
  
      optional
          covalent_factor - increase covalent bond length threshold with facto
  
      returns:
          AC - adjacent matrix
  
      """
  
      # Calculate distance matrix
      # dMat = rdkit.Chem.Get3DDistanceMatrix(mol)
      dMat = distance_matrix(xyz, xyz)
      num_atoms = mol.GetNumAtoms()
      AC = np.zeros((num_atoms, num_atoms), dtype=int)
  
      for i in range(1, num_atoms):
          a_i = mol.GetAtomWithIdx(i).GetAtomicNum()
          for j in range(i):
              a_j = mol.GetAtomWithIdx(j).GetAtomicNum()
              if (min(a_i, a_j), max(a_i, a_j)) in atomic_valid_bond:
                  threshold = atomic_valid_bond[
                      (min(a_i, a_j), max(a_i, a_j))
                  ]
                  if dMat[i, j] <= threshold and AC[j].sum() < max(
                      atomic_valence[a_j]
                  ):
                      AC[i, j] = 1
                      AC[j, i] = 1
  
      return AC
  
imports: from rdkit import Chem
  import numpy
  import networkx
  import collections
  from collections import defaultdict
  import itertools
  import copy
  from scipy.spatial import distance_matrix
label_desc: Use image node_id 1 for calling a global function with example usage: get_AC(mol, xyz) and returns: AC