Subset-lex: did we miss an order?
Jörg Arndt
TL;DR
This work generalizes subset-lex order to a broad class of combinatorial objects, including multisets, compositions, partitions, and restricted growth strings, enabling efficient generation in a consistent framework. It develops loopless or near-loopless algorithms for computing successors and predecessors, often using at most one extra variable, and extends these ideas to Gray codes (subset-lex Gray and SL-Gray) for binary and mixed-radix words. The paper also introduces run-length and restricted-growth representations, provides practical ranking and unranking methods (Appendix II), and demonstrates the versatility and performance of these approaches across numerous combinatorial families. Together, these results yield fast, scalable enumeration techniques with potential impact on combinatorial generation, coding, and testing workflows.
Abstract
We generalize a well-known algorithm for the generation of all subsets of a set in lexicographic order with respect to the sets as lists of elements (subset-lex order). We obtain algorithms for various combinatorial objects such as the subsets of a multiset, compositions and partitions represented as lists of parts, and for certain restricted growth strings. The algorithms are often loopless and require at most one extra variable for the computation of the next object. The performance of the algorithms is very competitive even when not loopless. A Gray code corresponding to the subset-lex order and a Gray code for compositions that was found during this work are described.
