I've implemented the Levenshtein distance to do signal alignment. There are cases where Levenshtein doesn't find the solution I want, although it's optimal. For example, I have the strings:
aaabaa
abaaabaaa
The algorithm should recognize that it needs to delete the first two and the last character to match the strings:
abaaabaaa
x xx
Instead it finds:
abaaabaaa
x x x
Thus it divides the string in more substring than it needs to. Is there an extension to the Levenshtein distance, which divides the string in fewest substrings?