code: private int getConnectivity(IAtom atom, IAtomContainer container) {
          int connectivity = 0;
          for (IBond bond : container.bonds()) {
              if (bond.contains(atom)) {
                  switch (bond.getOrder()) {
                      case SINGLE:
                          connectivity++;
                          break;
                      case DOUBLE:
                          connectivity += 2;
                          break;
                      case TRIPLE:
                          connectivity += 3;
                          break;
                      case QUADRUPLE:
                          connectivity += 4;
                          break;
                      default:
                          connectivity += 10;
                  }
              }
          }
          return connectivity;
      }
docs: Sums the number of bonds (counting order) an atom is hooked up with.
  @param atom an atom in the container
  @param container the container
  @return valence (bond order sum) of the atom