baobab.bio.permutation
Class PermutationUtil

java.lang.Object
  extended by baobab.bio.permutation.PermutationUtil

public class PermutationUtil
extends java.lang.Object

The PermutationUtil class contains utility methods which deal with permutations as arrays of int

Version:
1.0, May 2006
Author:
Marilia D. V. Braga

Constructor Summary
PermutationUtil()
           
 
Method Summary
static int calculateSignedReversalDistance(int[] permutation)
          Calculates the reversal distance between a given signed permutation and the identity
static int calculateSignedReversalDistance(int[] permutation, boolean isLinear)
          Calculates the reversal distance between a given signed permutation and the identity
static int calculateSignedReversalDistance(int[] origin, int[] target)
          Calculates the reversal distance between the given origin and target signed permutations
static int calculateSignedReversalDistance(int[] origin, int[] target, boolean isLinear)
          Calculates the reversal distance between the given origin and target signed permutations
static boolean containsUnorientedComponent(int[] permutation, boolean isLinear)
          Tests whether the permutation contains an unoriented component (hurdle)
static int[] getIdentityPermutation(int size)
          Generates the identity permutation of a given size
static boolean isValidPermutation(int[] permutation, boolean isLinear)
          Tests whether the permutation is valid
static int[] mapPermutation(int[] origin, int[] target)
          Maps the origin permutation, respecting a direct map between the target and the identity permutation
static int[][] revertSigned(int[] permutation, int[] positions, int start, int end, boolean isLinear)
          Make a new permutation, by reverting the permutation between the specified positions
static int[] revertSigned(int[] permutation, int start, int end, boolean isLinear)
          Make a new permutation, by reverting the permutation between the specified positions
static int[] revertUnsigned(int[] permutation, int start, int end, boolean isLinear)
          Make a new permutation, by reverting the permutation between the specified positions
static int[] transpose(int[] permutation, int start, int middle, int end)
          Make a new permutation, by transposing blocks at the permutation between the specified positions
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PermutationUtil

public PermutationUtil()
Method Detail

getIdentityPermutation

public static int[] getIdentityPermutation(int size)
Generates the identity permutation of a given size

Parameters:
size - the given size
Returns:
the identity permutation as an array of int

isValidPermutation

public static boolean isValidPermutation(int[] permutation,
                                         boolean isLinear)
Tests whether the permutation is valid

Parameters:
permutation - the given permutation
Returns:
true / false

mapPermutation

public static int[] mapPermutation(int[] origin,
                                   int[] target)
Maps the origin permutation, respecting a direct map between the target and the identity permutation

Parameters:
origin - the origin permutation
target - the target permutation
Returns:
the mapped permutation

revertSigned

public static int[] revertSigned(int[] permutation,
                                 int start,
                                 int end,
                                 boolean isLinear)
Make a new permutation, by reverting the permutation between the specified positions

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting permutation, after performing the reversion

revertSigned

public static int[][] revertSigned(int[] permutation,
                                   int[] positions,
                                   int start,
                                   int end,
                                   boolean isLinear)
Make a new permutation, by reverting the permutation between the specified positions

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting permutation, after performing the reversion

revertUnsigned

public static int[] revertUnsigned(int[] permutation,
                                   int start,
                                   int end,
                                   boolean isLinear)
Make a new permutation, by reverting the permutation between the specified positions

Parameters:
start - the beginning of the reversion block
end - the end of the reversion block
Returns:
the resulting permutation, after performing the reversion

transpose

public static int[] transpose(int[] permutation,
                              int start,
                              int middle,
                              int end)
Make a new permutation, by transposing blocks at the permutation between the specified positions

Parameters:
start - the beginning of the first block
middle - the end of the first block / beginning of the second block
end - the end of the second block
Returns:
the resulting permutation, after performing the transposition

calculateSignedReversalDistance

public static int calculateSignedReversalDistance(int[] permutation)
Calculates the reversal distance between a given signed permutation and the identity

Parameters:
permutation - the origin permutation, as an array of int
Returns:
the reversal distance

calculateSignedReversalDistance

public static int calculateSignedReversalDistance(int[] permutation,
                                                  boolean isLinear)
Calculates the reversal distance between a given signed permutation and the identity

Parameters:
permutation - the origin permutation, as an array of int
isLinear - indicates whether the permutation is linear or circular
Returns:
the reversal distance

calculateSignedReversalDistance

public static int calculateSignedReversalDistance(int[] origin,
                                                  int[] target)
Calculates the reversal distance between the given origin and target signed permutations

Parameters:
origin - the origin permutation, as an array of int
target - the target permutation, as an array of int
Returns:
the reversal distance

calculateSignedReversalDistance

public static int calculateSignedReversalDistance(int[] origin,
                                                  int[] target,
                                                  boolean isLinear)
Calculates the reversal distance between the given origin and target signed permutations

Parameters:
origin - the origin permutation, as an array of int
target - the target permutation, as an array of int
isLinear - indicates whether the permutation is linear or circular
Returns:
the reversal distance

containsUnorientedComponent

public static boolean containsUnorientedComponent(int[] permutation,
                                                  boolean isLinear)
Tests whether the permutation contains an unoriented component (hurdle)

Parameters:
permutation - the origin permutation, as an array of int
isLinear - indicates whether the permutation is linear or circular
Returns:
true / false