code: static boolean isAromaticRing(int[] cycle, int[] contribution, int[] dbs, boolean[] aromatic) {
  
          int len = cycle.length - 1;
          int sum = 0;
  
          int i = 0;
          int iPrev = len - 1;
          int iNext = 1;
  
          while (i < len) {
  
              int prev = cycle[iPrev];
              int curr = cycle[i];
              int next = cycle[iNext];
  
              int pElectrons = contribution[curr];
  
              if (pElectrons < 0) return false;
  
              // single p electrons are only donated from double bonds, these are
              // only counted if the bonds are either in this ring or the bond
              // is aromatic
              if (pElectrons == 1) {
                  final int other = dbs[curr];
                  if (other < 0) return false;
                  if (other != prev && other != next && !aromatic[other]) return false;
              }
  
              iPrev = i;
              i = iNext;
              iNext = iNext + 1;
              sum += pElectrons;
          }
  
          // the sum of electrons 4n+2?
          return (sum - 2) % 4 == 0;
      }
docs: Check if a cycle/ring is aromatic. A cycle is aromatic if the sum of its p electrons is equal
  to 4n+2. Double bonds can only contribute if they are in the cycle being tested or are
  already delocalised.
  
  @param cycle        closed walk of vertices in the cycle
  @param contribution vector of p electron contributions from each vertex
  @param dbs          vector of double-bond pairs, index stored double-bonded index
  @param aromatic     binary set of aromatic atoms
  @return whether the ring is aromatic