org.jgrapht.experimental.permutation
Class PermutationFactory

java.lang.Object
  extended by org.jgrapht.experimental.permutation.PermutationFactory

public class PermutationFactory
extends Object

Factory to create Permutations of several types and use them as Enumerations. Note that callers may use them directly if they need to use special concrete methods.

These types are:

  • All elements are different. There are N! possible permutations.

    example: source=[1,2,3] result=[1,2,3][1,3,2][2,1,3][2,3,1][3,1,2][3,2,1]

  • Some of the elements are the same.

    example: source=[1,1,2] result=[1,1,2][1,2,1][2,1,1]

  • There are separate permutations groups, which are connected to one sequence. Permutations are allowed only inside the group. Possible sequences: product of factorial of each group. see example.

    example: assume source=the groups are sizes are : 1,2,2,5 elements will be created: (1),(2,3),(4,5).

    result=[1,(2,3),(4,5)] [1,(2,3),(5,4)] [1,(3,2),(5,4)] [1,(3,2),(4,5)]. In this example the number of possiblities is 1! x 2! x 2! = 4

    Since:
    Jun 3, 2005
    Author:
    Assaf Lehr

    Constructor Summary
    PermutationFactory()
               
     
    Method Summary
    static ArrayPermutationsIter createByGroups(int[] groupSizesArray)
              For efficiency, try putting the biggest groups at the beggining of the array.
    static ArrayPermutationsIter createRegular(int[] permSourceArray)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    PermutationFactory

    public PermutationFactory()
    Method Detail

    createRegular

    public static ArrayPermutationsIter createRegular(int[] permSourceArray)

    createByGroups

    public static ArrayPermutationsIter createByGroups(int[] groupSizesArray)
    For efficiency, try putting the biggest groups at the beggining of the array.

    Parameters:
    groupSizesArray - . example [3,2] will create an array (0,1,2)(3,4)


    Copyright © 2013. All rights reserved.