Levenshtein distance and the Triangle Inequality
richardminerich.com
richardminerich.com
The difference he's pointing out isn't that Levenshtein obeys the triangle inequality but Damerau-Levenshtein doesn't; it's that a naive algorithm to compute Levenshtein works, but a naive algorithm to compute Damerau-Levenshtein doesn't -- and that the measure it does compute does not obey the triangle inequality.
While it's clear that the author recognizes this, he should really be more explicit and avoid conflating terms like this; this sort of thing is going to confuse people.
That Damerau-Levenshtein distance obeys the triangle inequality follows trivially from the definition, since it's just distance in an appropriate graph.
http://blog.notdot.net/2007/4/Damn-Cool-Algorithms-Part-1-BK...
"rick", "irkc": remove the final character of "irkc" (insertion)
"rick", "irk": remove the final character of both strings at no cost
"ric", "ir": remove the final character of both strings at a cost of 1 (substitution)
"ri", "i": remove the final character of both strings at no cost
"r", "": base case, cost of 1.
In summary, "rick" -> "rickc" -> "ickc" -> "irkc".