code: public static boolean hasGraphRepresentation(IAtomContainer molecule) {
          for (IBond bond : molecule.bonds())
              if (bond.getAtomCount() != 2) return false;
          return true;
      }
docs: Checks whether all bonds have exactly two atoms.