Class LeeDistance

java.lang.Object
org.cicirello.permutations.distance.LeeDistance
All Implemented Interfaces:
NormalizedPermutationDistanceMeasurer, NormalizedPermutationDistanceMeasurerDouble, PermutationDistanceMeasurer, PermutationDistanceMeasurerDouble

public final class LeeDistance extends Object implements NormalizedPermutationDistanceMeasurer
Lee Distance is closely related to deviation distance. However, Lee Distance considers the permutation to be a cyclic structure when computing positional deviations. That is, an element's deviation between permutations is the minimum of its deviation to the right or to the left (wrapping around ends cyclicly).

Consider p1 = [0, 1, 2, 3, 4, 5] and p2 = [5, 1, 0, 2, 3, 4]. Element 0 is 2 positions displaced (as in deviation distance). Elements 2, 3, and 4 are a 1 position displaced (as in deviation distance). Element 1 is stationary. Element 5 is 1 position displaced (for Lee Distance) whereas for Deviation Distance it would be 5 positions displaced. For Lee distance, the displacement is the minimum of how far it is displaced in either of the two directions. In this case element 5 is at the right most end in p1 and left most end of p2, which as a cyclic structure are adjacent positions.

Runtime: O(n), where n is the permutation length.

Described in:
C. Lee, "Some properties of nonbinary error-correcting codes," in IRE Transactions on Information Theory, vol. 4, no. 2, pp. 77-82, June 1958.

  • Constructor Details

    • LeeDistance

      public LeeDistance()
      Constructs the distance measurer as specified in the class documentation.
  • Method Details