Table of Contents
Fetching ...

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.

Subset-lex: did we miss an order?

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.

Paper Structure

This paper contains 16 sections, 19 figures.

Figures (19)

  • Figure 1: Two lexicographic orders for the subsets of a 5-element set: ordering using the sets as lists of elements (left) and ordering using the characteristic words (right). Dots are used to denote zeros in the characteristic words.
  • Figure 2: Subsets of the multiset $\{0^1, 1^2, 2^2, 3^3 \}$ in subset-lex order. Dots are used to denote zeros in the (generalized) characteristic words.
  • Figure 3: Mixed radix numbers of length 4 in falling factorial base that are non-adjacent forms (NAF), in co-lexicographic order, minimal-change order (Gray code), and subset-lex order (with the sets of positions of nonzero digits).
  • Figure 4: Gray code for the length-4 non-adjacent forms in falling factorial base (left), together with the corresponding involutions in cycle form (middle) and in array form (right).
  • Figure 5: Binary non-adjacent forms of length 8 in co-lexicographic order, minimal-change order (Gray code), and subset-lex order (with the corresponding sets without consecutive elements).
  • ...and 14 more figures