code: static int electronSum(final int[] cycle, final int[] contributions, final int[] subset) {
          int sum = 0;
          for (int i = 1; i < cycle.length; i++)
              sum += contributions[subset[cycle[i]]];
          return sum;
      }
docs: Count the number electrons in the {@code cycle}. The {@code
  contributions} array indicates how many π-electrons each atom can
  contribute. When the contribution of an atom is less than 0 the sum for
  the cycle is always 0.
  
  @param cycle         closed walk (last and first vertex the same) of
  vertices which form a cycle
  @param contributions π-electron contribution from each atom
  @return the total sum of π-electrons contributed by the {@code cycle}