Skip to content

Triun/PHP-Longest-Common-Subsequence

Repository files navigation

PHP - Longest Common Subsequence

PHP implementation of an algorithm to solve the longest common subsequence problem.

Latest Version on Packagist Build Status Coverage status Total Downloads The most recent stable version is 2.0.0 Software License

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

About

PHP implementation of an algorithm to solve the `longest common subsequence` problem.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages