bk-tree 0.1.4
Header-only Burkhard-Keller tree library
Loading...
Searching...
No Matches
Public Member Functions | List of all members
bk_tree::metrics::LCSubseqDistance Class Referencefinal

Longest Common Subsequence distance metric. More...

#include <bktree.hpp>

Inheritance diagram for bk_tree::metrics::LCSubseqDistance:
bk_tree::metrics::Distance< LCSubseqDistance >

Public Member Functions

 LCSubseqDistance (size_t initial_size=BK_LCS_MATRIX_INITIAL_SIZE)
 
integer_type compute_distance (std::string_view s, std::string_view t) const noexcept
 
- Public Member Functions inherited from bk_tree::metrics::Distance< LCSubseqDistance >
integer_type operator() (std::string_view s, std::string_view t) const
 

Detailed Description

Longest Common Subsequence distance metric.

\(d(x, y) = |x| + |y| - 2\operatorname{LCS}(x, y),\) where \(\operatorname{LCS}(x, y)\) is the length of the longest common subsequence.

\[\begin{equation} L(i, j)= \begin{cases} 0, & \text{if } i = 0 \text{ or } j = 0 \\ L(i-1, j-1) + 1, & \text{if } x_i = y_j \\ \max\{L(i-1, j), L(i, j-1)\}, & \text{if } x_i \neq y_j \end{cases} \end{equation}\]

for any \(0\le i < m\) and \(0\le j < n.\)


The documentation for this class was generated from the following file: