Generates permutations a pair at a time.
permute(N=4,K=1,initialize=0)
Returns false when the last permutation has been generated or a failure has occurred. Returns true for success and at most K new pairs in vec.
The input parameter
The input parameter
A 2*K vector of element numbers to be exchanged -- permutations may be obtained by successively applying these pairs.
Always returns 1
The number of pairs in vec. It may be less than K for the final set.
The number of elements in the permutation vector. The elements are numbered 1:N
The number of exchange pairs to be returned at each access
Set to 1 to initialize. Set to 0 for additional pairs.
Bob Wheeler rwheeler@echip.com
On first call, set initialize to 1. On subsequent accesses, initialize should be 0. The function returns at most K exchange pairs at each access. The function should be repeatedly called until result is false.
The function returns a list.
Combinatorial Algorithms Theory and Practice. Prentice Hall, New Jersey. p170.