triun / longest-common-subsequence
PHP implementation of an algorithm to solve the 'longest common subsequence' problem.
Installs: 2 502
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/phpunit: ^6.5
- squizlabs/php_codesniffer: ^3.2
- symfony/var-dumper: ^3.4
This package is auto-updated.
Last update: 2024-11-17 22:29:48 UTC
README
PHP implementation of an algorithm to solve the longest common subsequence
problem.
About
PHP-Longest-Common-Subsequence is a PHP implementation of an algorithm to solve the 'longest common subsequence' problem.
From Wikipedia - Longest common subsequence problem:
The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequences in a set of sequences (often just two sequences). It differs from the longest common substring problem: unlike substrings, subsequences are not required to occupy consecutive positions within the original sequences. The longest common subsequence problem is a classic computer science problem, the basis of data comparison programs such as the diff utility, and has applications in bioinformatics. It is also widely used by revision control systems such as Git for reconciling multiple changes made to a revision-controlled collection of files.
This PHP implementation is based on eloquent/php-lcs, adding a little more flexibility in order to handle, not only the common text, but also the differences.
Installation
Require triun/longest-common-subsequence package with composer using the following command:
composer require triun/longest-common-subsequence
Usage
use Triun\LongestCommonSubsequence\Solver; $solver = new Solver; $sequenceA = array('B', 'A', 'N', 'A', 'N', 'A'); $sequenceB = array('A', 'T', 'A', 'N', 'A'); // calculates the LCS to be array('A', 'A', 'N', 'A') $lcs = $solver->solve($sequenceA, $sequenceB);
Issues
Bug reports and feature requests can be submitted on the Github Issue Tracker.
Contributing
See CONTRIBUTING.md for information.
License
This repository is open-sourced software licensed under the MIT license