Minify ring set (similar to SSSR)
    Limitation: this can not correctly recognize minimum rings
    in the case of non-outerplanar graph.
    Note: concept of SSSR is controversial. Roughly reduce the size of
    cycle basis can help some scaffold-based analysis

def minify_ring(mol, verbose=False):
    """ Minify ring set (similar to SSSR)
    Limitation: this can not correctly recognize minimum rings
    in the case of non-outerplanar graph.
    Note: concept of SSSR is controversial. Roughly reduce the size of
    cycle basis can help some scaffold-based analysis
    """
    mol.require("Topology")
    for cyc_idx in mol.scaffolds:
        rings = deque(sorted([mol.rings[c] for c in cyc_idx], key=len))
        minified = []
        cnt = 0
        while rings:
            cnt += 1
            if cnt > 100:
                mol.descriptors.add("MinifiedRing")
                raise RuntimeError("Ring minimization failed")
            r = rings.popleft()
            init_r = r
            if verbose:
                print(len(r), "Ring:{}".format(r))
            for m in minified:
                if verbose:
                    print(len(m), "Minified:{}".format(m))
                resolved = resolve_inclusion(r, m)
                if resolved:
                    if verbose:
                        print(len(resolved[0]), len(resolved[1]),
                              "Resolved:{}".format(resolved))
                    r = resolved[0]
            if verbose:
                print(len(r), "New ring:{}\n".format(r))
            if len(r) == len(init_r):  # no longer be able to minified
                minified.append(r)
            else:  # further minification required
                rings.append(r)
        for c in cyc_idx:
            mol.rings[c] = minified.pop()
    mol.descriptors.add("MinifiedRing")