code: public static int getVertexCountAtDistance(IAtomContainer atomContainer, int distance) {
          int natom = atomContainer.getAtomCount();
  
          int[][] admat = AdjacencyMatrix.getMatrix(atomContainer);
          int[][] distanceMatrix = computeFloydAPSP(admat);
  
          int matches = 0;
  
          for (int i = 0; i < natom; i++) {
              for (int j = 0; j < natom; j++) {
                  if (distanceMatrix[i][j] == distance) matches++;
              }
          }
          return matches / 2;
      }
docs: Returns the number of vertices that are a distance 'd' apart.
  
  In this method, d is the topological distance (ie edge count).
  
  @param atomContainer The molecule to consider
  @param distance      The distance to consider
  @return The number of vertices