code: public IAtomContainer generate() throws CDKException {
          boolean structureFound = false;
          boolean bondFormed;
          double order;
          double max, cmax1, cmax2;
          int iteration = 0;
          IAtom partner;
          IAtom atom;
          do {
              iteration++;
              atomContainer.removeAllElectronContainers();
              do {
                  bondFormed = false;
                  for (int f = 0; f < atomContainer.getAtomCount(); f++) {
                      atom = atomContainer.getAtom(f);
  
                      if (!satCheck.isSaturated(atom, atomContainer)) {
                          partner = getAnotherUnsaturatedNode(atom);
                          if (partner != null) {
                              cmax1 = satCheck.getCurrentMaxBondOrder(atom, atomContainer);
  
                              cmax2 = satCheck.getCurrentMaxBondOrder(partner, atomContainer);
                              max = Math.min(cmax1, cmax2);
                              order = Math.min(Math.max(1.0, random.nextInt((int) Math.round(max))), 3.0);
                              logger.debug("Forming bond of order ", order);
                              atomContainer.addBond(atomContainer.getBuilder().newInstance(IBond.class, atom, partner,
                                      BondManipulator.createBondOrder(order)));
                              bondFormed = true;
                          }
                      }
                  }
              } while (bondFormed);
              if (ConnectivityChecker.isConnected(atomContainer) && satCheck.allSaturated(atomContainer)) {
                  structureFound = true;
              }
          } while (!structureFound && iteration < 20);
          logger.debug("Structure found after #iterations: ", iteration);
          return atomContainer.getBuilder().newInstance(IAtomContainer.class, atomContainer);
      }
docs: Generates a random structure based on the atoms in the given IAtomContainer.