enumerating all permutations of partitions

779 Views Asked by At

Given a set of $n$ items, I would like to enumerate all the permutations of all the partitions of those $n$ items. For example, in the case of $n=3$ (with Bell number 5), there are 13 permutations of interest:

{1,2,3}
{1}{2,3}
{2,3}{1}
{1,2}{3}
{3}{1,2}
{1,3}{2}
{2}{1,3}
{1}{2}{3}
{1}{3}{2}
{2}{1}{3}
{2}{3}{1}
{3}{1}{2}
{3}{2}{1}

As I understand it, this is not simply a $k$-combinations numbering problem because the size of the subsets is not constrained. Similarly, I don't think(?) this is simply a symmetric group of order $n$.

There is obviously a fairly trivial algorithm that will work here: generate all of the $B_n$ partitions, find $|P|!$ for each partition $P$, and sum. I am wondering if there is a more general solution, and if it possibly has a name or formulation I'm not aware of.