Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between Levenshtein distance and the Wagner-Fischer algorithm

The Levenshtein distance is a string metric for measuring the difference between two sequences. The Wagner–Fischer algorithm is a dynamic programming algorithm that computes the edit distance between two strings of characters.

Both using a matrix, and I don't see the difference? Is the difference the backtracking or is there no further difference by the fact that one is the "literature" and the other one is the programming?

Also I am just writing on a thesis, and I am not sure how to divide it- should I first get into explaining the Levenshtein distance first and afterwards the Wagner-Fisher algorithm or doing both in one? I got kinda confused here.

like image 962
Haifa Warda Avatar asked Mar 10 '16 05:03

Haifa Warda


Video Answer


2 Answers

You actually answer the question yourself in the first paragraph. In the second paragraph you mix them up a bit.

Levenshtein distance is an edit distance metric named after Vladimir Levenshtein who considered this distance in 1965 and have nothing to do with the dynamic programming "matrix". And the Wagner–Fischer algorithm is a dynamic programming algorithm that computes the edit distance between two strings of characters.

However, the Levenshtein distance is normally computed using dynamic programming if what you need is a general purpose computation, that is, calculate the edit distance between two random input strings. But Levenshtein distance can also be used in a spell checker, when you compare one string with a dictionary. In cases like this its normally to slow to use a general purpose computation,and something like a Levenshtein Automaton can provide linear time to get all spelling suggestions. Btw, this is also used in the fuzzy search in Lucene since version 4.

About your thesis, well I think it depends. If its about the actual Levenshtein metric then I think thats where you should start, and if its about dynamic programming you should start with Wagner-Fischer. Anyway, thats my two cents about it. And good luck with you thesis.

like image 116
gustf Avatar answered Oct 01 '22 11:10

gustf


Indeed, they are closely related, but they are not the same thing. The Levenshtein distance is a concept that is defined by a mathematical formula. However, trying to compute the Levenshtein distance by implementing the recursive formula directly will be horrendously slow. The Wagner-Fischer is a dynamic programming algorithm to compute it efficiently.

like image 27
Aasmund Eldhuset Avatar answered Oct 01 '22 10:10

Aasmund Eldhuset