Function Repository Resource:

# NextSubset

Get the next subset of a given set in canonical order

Contributed by: Wolfram Staff (original content by Sriram V. Pemmaraju and Steven S. Skiena)
 ResourceFunction["NextSubset"][l,s] gives the subset of l following the subset s when the subsets are sorted in canonical order.

## Details and Options

ResourceFunction["NextSubset"] is limited to sets of unique elements.

## Examples

### Basic Examples (1)

Get the subset of {1,2,3} following the subset {1,2} in canonical order:

 In[1]:=
 Out[1]=

### Properties and Relations (2)

Get the subset following another subset in canonical ordering:

 In[2]:=
 Out[2]=

This is not the same as the next subset in lexicographic order, as can be obtained with the resource function NextLexicographicSubset:

 In[3]:=
 Out[3]=

The full list of lexicographically-ordered subsets can be obtained using the resource function LexicographicSubsets:

 In[4]:=
 Out[5]=

Subsets of {1,2,3} in canonical order generated sequentially using NextSubset:

 In[6]:=
 Out[6]=

Compare:

 In[7]:=
 Out[7]=
 In[8]:=
 Out[8]=

## Version History

• 1.0.0 – 15 July 2020