Function Repository Resource:

FromInversionVector

Source Notebook

Construct the permutation list corresponding to the given inversion vector

Contributed by: Wolfram Staff

ResourceFunction["FromInversionVector"][vect]

constructs the permutation list corresponding to the inversion vector vect.

Details and Options

The inversion vector of a permutation of length n lists the number of times k is preceded by an entry greater than k, where k runs from 1 to n.

Examples

Basic Examples (2) 

Here is the inversion vector of a permutation:

In[1]:=
iv = ResourceFunction["ToInversionVector"]@{3, 5, 4, 1, 2}
Out[1]=

This gives back the permutation:

In[2]:=
ResourceFunction["FromInversionVector"]@iv
Out[2]=

Scope (3) 

Here are all six permutation of {1,2,3}:

In[3]:=
s3 = Permutations@{1, 2, 3}
Out[3]=

Here are the corresponding inversion vectors:

In[4]:=
ivs = ResourceFunction["ToInversionVector"] /@ s3
Out[4]=

The round trip works:

In[5]:=
s3 == ResourceFunction["FromInversionVector"] /@ ivs
Out[5]=

Publisher

George Beck

Version History

  • 2.0.0 – 08 July 2019
  • 1.0.0 – 31 May 2019

Related Resources

Author Notes

The Combinatorica` function ToInversionVector did not include the final zero.

License Information