I need an algorithm which calculates something similar to the Levenshtein distance. It should calculate the minimal possible number of transformations to get from one sequence to another. The allowed transformations are deletion, insertion and move:
Deletion of 3: before {1, 2, 3, 4}, after {1, 2, 4}
Insertion of 5: before {1, 2, 3, 4}, after {1, 2, 5, 3, 4}
Move of 4: before {1, 2, 3, 4}, after {4, 1, 2, 3}
So the algorithm should calculate the minimal number of such transformations given the starting and ending sequence of numbers and, ideally, give the list of the transformations needed. One important trait of the sequences is that number are never duplicated.
I have an idea that I can modify the Levenshtein algorithm so it only counts the number of deletions and insertions and ignore substitutions. And the number of moves would be number of deletions plus number of insertions divided by 2. But I'm not sure if it's correct.
Does anybody know such an algorithm?
EDIT:
I probably should have said, that this algorithm will work on a sequence of sequences. For example:
{ {1, 2, 3}, {4}, {5, 6, 7} }
where the numbers are not duplicated. The total number of the inner elements in the sequence is not changed. Elements can migrate from one inner sequence to another inner sequence. The number of inner sequences is also constant. So it could be
{ {1, 2, 3, 4, 5, 6, 7}, {}, {} }
{ {}, {1, 2, 3, 4, 5, 6, 7}, {} }
{ {}, {}, {1, 2, 3, 4, 5, 6, 7} }
The idea is to calculate the distance for each corresponding inner sequence and then sum them to get a distance for the outer sequence.
So the elements can be deleted or inserted to the inner sequence, but they never disappear from the outer sequence.
The most important aspect of this algorithm is that it should find MINIMAL number of transformations. Not just some number of transofrmations.