code: public static boolean isSameRing(IRingSet ringSet, IAtom atom1, IAtom atom2) {
          for (IAtomContainer atomContainer : ringSet.atomContainers()) {
              IRing ring = (IRing) atomContainer;
              if (ring.contains(atom1) && ring.contains(atom2)) return true;
          }
          return false;
      }
docs: Checks if <code>atom1</code> and <code>atom2</code> share membership in the same ring or ring system.
  Membership in the same ring is checked if the RingSet contains the SSSR of a molecule; membership in
  the same ring or same ring system is checked if the RingSet contains all rings of a molecule.<BR><BR>
  
  <p><B>Important:</B> This method only returns meaningful results if <code>atom1</code> and
  <code>atom2</code> are members of the same molecule for which the RingSet was calculated!
  
  @param ringSet The collection of rings
  @param  atom1   The first atom
  @param  atom2   The second atom
  @return boolean true if <code>atom1</code> and <code>atom2</code> share membership of at least one ring or ring system, false otherwise