code: private static BitSet available(int[][] graph, IAtom[] atoms, EdgeToBondMap bonds) {
  
          final BitSet available = new BitSet();
  
          // for all atoms, select those that require a double-bond
          ATOMS: for (int i = 0; i < atoms.length; i++) {
  
              final IAtom atom = atoms[i];
  
              // preconditions
              if (atom.getAtomicNumber() == null)
                  throw new IllegalArgumentException("atom " + (i + 1) + " had unset atomic number");
              if (atom.getFormalCharge() == null)
                  throw new IllegalArgumentException("atom " + (i + 1) + " had unset formal charge");
              if (atom.getImplicitHydrogenCount() == null)
                  throw new IllegalArgumentException("atom " + (i + 1) + " had unset implicit hydrogen count");
  
              if (!atom.getFlag(ISAROMATIC)) continue;
  
              // count preexisting pi-bonds, a higher bond order causes a skip
              int nPiBonds = 0;
              for (final int w : graph[i]) {
                  IBond.Order order = bonds.get(i, w).getOrder();
                  if (order == DOUBLE) {
                      nPiBonds++;
                  } else if (order.numeric() > 2) {
                      continue ATOMS;
                  }
              }
  
              // check if a pi bond can be assigned
              final int element = atom.getAtomicNumber();
              final int charge = atom.getFormalCharge();
              final int valence = graph[i].length + atom.getImplicitHydrogenCount() + nPiBonds;
  
              if (available(element, charge, valence)) {
                  available.set(i);
              }
          }
  
          return available;
      }
docs: Determine the set of atoms that are available to have a double-bond.
  
  @param graph adjacent list representation
  @param atoms array of atoms
  @param bonds map of atom indices to bonds
  @return atoms that can require a double-bond