code: def check_connected(AC):
      seen, queue = {0}, collections.deque([0])
      while queue:
          vertex = queue.popleft()
          for node in np.argwhere(AC[vertex] > 0).flatten():
              if node not in seen:
                  seen.add(node)
                  queue.append(node)
      # if the seen nodes do not include all nodes, there are disconnected
      #  parts and the molecule is invalid
      if seen != {*range(len(AC))}:
          return False
      return True
  
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 10 for calling a global function with example usage: check_connected(AC) and returns: True, False