Class CyclicEdgeDistance

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

public final class CyclicEdgeDistance extends Object implements NormalizedPermutationDistanceMeasurer
Cyclic edge distance treats the permutations as if they represent sets of edges, and counts the number of edges that differ. It treats the last to the first element as an edge.

Consider the example permutation: [1, 5, 2, 4, 0, 3]. Cyclic edge distance treats this as equivalent to the set of undirected edges: {(1,5), (5,2), (2,4), (4,0), (0,3), (3,1)}.

E.g., distance between [1, 5, 2, 4, 0, 3] and [ 5, 1, 4, 0, 3, 2] is 3. Why? Well, the first permutation has the edges: {(1,5), (5,2), (2,4), (4,0), (0,3), (3,1)}. The second has three of these (5,1), which is the same as (1,5) since they are undirected edges, (4,0), and (0,3), but does not include 3 of the edges: (5,2), (2,4), (3,1)

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

Cyclic edge distance was first described in:
S. Ronald, "Distance functions for order-based encodings," in Proc. IEEE CEC. IEEE Press, 1997, pp. 49–54.

  • Constructor Details

    • CyclicEdgeDistance

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