14 const std::string& iTarget) {
18 const int n = iSource.length();
19 const int m = iTarget.length();
30 typedef std::vector<std::vector<int> > Matrix_T;
32 Matrix_T matrix (n+1);
37 for (
int i = 0; i <= n; i++) {
38 matrix[i].resize(m+1);
43 for (
int i = 0; i <= n; i++) {
47 for (
int j = 0; j <= m; j++) {
53 for (
int i = 1; i <= n; i++) {
55 const char s_i = iSource[i-1];
59 for (
int j = 1; j <= m; j++) {
61 const char t_j = iTarget[j-1];
75 const int above = matrix[i-1][j];
76 const int left = matrix[i][j-1];
77 const int diag = matrix[i-1][j-1];
78 int cell = std::min ( above + 1, std::min (left + 1, diag + cost));
87 int trans = matrix[i-2][j-2] + 1;
89 if (iSource[i-2] != t_j) {
93 if (s_i != iTarget[j-2]) {
static int getDistance(const std::string &iSource, const std::string &iTarget)