code: public static void kekulize(final IAtomContainer ac) throws CDKException {
  
          // storage of pairs of atoms that have pi-bonded
          final Matching matching = Matching.withCapacity(ac.getAtomCount());
  
          // exract data structures for efficient access
          final IAtom[] atoms = AtomContainerManipulator.getAtomArray(ac);
          final EdgeToBondMap bonds = EdgeToBondMap.withSpaceFor(ac);
          final int[][] graph = GraphUtil.toAdjList(ac, bonds);
  
          // determine which atoms are available to have a pi bond placed
          final BitSet available = available(graph, atoms, bonds);
  
          // attempt to find a perfect matching such that a pi bond is placed
          // next to each available atom. if not found the solution is ambiguous
          if (!matching.perfect(graph, available))
              throw new CDKException("Cannot assign Kekulé structure without randomly creating radicals.");
  
          // propegate bond order information from the matching
          for (final IBond bond : ac.bonds()) {
              if (bond.getOrder() == UNSET && bond.isAromatic()) bond.setOrder(SINGLE);
          }
          for (int v = available.nextSetBit(0); v >= 0; v = available.nextSetBit(v + 1)) {
              final int w = matching.other(v);
              final IBond bond = bonds.get(v, w);
  
              // sanity check, something wrong if this happens
              if (bond.getOrder().numeric() > 1)
                  throw new CDKException(
                          "Cannot assign Kekulé structure, non-sigma bond order has already been assigned?");
  
              bond.setOrder(IBond.Order.DOUBLE);
              available.clear(w);
          }
      }
docs: Assign a Kekulé representation to the aromatic systems of a compound.
  
  @param ac structural representation
  @throws CDKException a Kekulé form could not be assigned