Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Prune non-maximal subsets from a list of subsets
| ResourceFunction["MaximalSubsets"][list] prunes non-maximal subsets from the sets in list. | 
Here is a list of sets:
| In[1]:= |  | 
Remove the non-maximal subsets {d}, {a}, and {a,b}:
| In[2]:= | ![ResourceFunction["MaximalSubsets"][list]](https://www.wolframcloud.com/obj/resourcesystem/images/88e/88e16c2a-0c9f-4571-9619-a9ecd295ae2b/7a84c6ac2c3bf39c.png) | 
| Out[2]= |  | 
MaximalSubsets can handle a large list of subsets:
| In[3]:= | ![SeedRandom[1];
list = DeleteDuplicates[
   RandomSample[Range@200, #] & /@ RandomInteger[{1, 99}, 1000]];](https://www.wolframcloud.com/obj/resourcesystem/images/88e/88e16c2a-0c9f-4571-9619-a9ecd295ae2b/03eba10a0d0a260b.png) | 
The number of maximal subsets:
| In[4]:= | ![ResourceFunction["MaximalSubsets"][list] // Length // AbsoluteTiming](https://www.wolframcloud.com/obj/resourcesystem/images/88e/88e16c2a-0c9f-4571-9619-a9ecd295ae2b/68ca641ba0665794.png) | 
| Out[4]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License