docs: def recognize(mol):
      """ Detect cycle basis, biconnected and isolated components (DFS).
      This will add following attribute to the molecule instance object.
  
      mol.ring: Cycle basis
      mol.scaffold: biconnected components
      mol.isolated: isolated components other than the largest one
  
      To find minimum set of rings, additionally execute topology.minify_ring.
  
      Reference:
          networkx cycle_basis function
      """
      g = set(i for i, _ in mol.atoms_iter())
      bccs = {}  # BiConnected Components
      isoc = []  # ISOlated Components
      while g:
          start = g.pop()
          stack = [start]
          pred = {start: start}
          used = {start: set()}
          root = {start: start}
          while stack:
              tail = stack.pop()
              for nbr in mol.neighbors(tail):
                  if nbr not in used:  # New node
                      pred[nbr] = tail
                      stack.append(nbr)
                      used[nbr] = {tail}
                      root[nbr] = nbr
                  elif nbr in stack:  # Cycle found
                      pn = used[nbr]
                      cyc = [nbr, tail]
                      p = pred[tail]
                      end = pred[nbr]
                      root[nbr] = root[tail] = root[end]
                      while p not in pn:  # Backtrack
                          cyc.append(p)
                          root[p] = root[end]
                          if p in bccs:  # Append scaffold to new cycle
                              if root[end] not in bccs:
                                  bccs[root[end]] = []
                              bccs[root[end]].extend(bccs[p])
                              del bccs[p]
                          p = pred[p]
                      cyc.append(p)
                      if root[end] not in bccs:  # Append new cycle to scaffold
                          bccs[root[end]] = []
                      bccs[root[end]].append(cyc)
                      used[nbr].add(tail)
          isoc.append(list(pred.keys()))
          # print(pred)
          g -= set(pred)
      mol.rings = []
      mol.scaffolds = []
      for cycles in bccs.values():
          rcnt = len(mol.rings)
          mol.rings.extend(cycles)
          mol.scaffolds.append(list(range(rcnt, rcnt + len(cycles))))
      mol.isolated = list(sorted(isoc, key=len, reverse=True))[1:]
      mol.descriptors.add("Topology")