java.lang.Object
org.cicirello.permutations.distance.ScrambleDistance
- All Implemented Interfaces:
NormalizedPermutationDistanceMeasurer
,NormalizedPermutationDistanceMeasurerDouble
,PermutationDistanceMeasurer
,PermutationDistanceMeasurerDouble
Scramble Distance is the minimum number of random shufflings needed to transform one permutation
into the other. This was implemented for a very specific purpose, and unlikely to be subsequently
useful.
The scramble distance is 0 if permutation p1 is identical to p2. Otherwise, scramble distance is 1.
Runtime: O(n), where n is the permutation length.
-
Constructor Summary
ConstructorDescriptionConstructs the distance measurer as specified in the class documentation. -
Method Summary
Modifier and TypeMethodDescriptionint
distance
(Permutation p1, Permutation p2) Measures the distance between two permutations.int
max
(int length) Computes the maximum possible distance between permutations of a specified length.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.cicirello.permutations.distance.NormalizedPermutationDistanceMeasurer
maxf, normalizedDistance
Methods inherited from interface org.cicirello.permutations.distance.PermutationDistanceMeasurer
distancef
-
Constructor Details
-
ScrambleDistance
public ScrambleDistance()Constructs the distance measurer as specified in the class documentation.
-
-
Method Details
-
distance
Description copied from interface:PermutationDistanceMeasurer
Measures the distance between two permutations.- Specified by:
distance
in interfacePermutationDistanceMeasurer
- Parameters:
p1
- first permutationp2
- second permutation- Returns:
- distance between p1 and p2
-
max
public int max(int length) Description copied from interface:NormalizedPermutationDistanceMeasurer
Computes the maximum possible distance between permutations of a specified length.- Specified by:
max
in interfaceNormalizedPermutationDistanceMeasurer
- Parameters:
length
- Permutation length.- Returns:
- the maximum distance between a pair of permutations of the specified length.
-