Algorithm::MLCS - Fast heuristic algorithm for finding Longest Common Subsequence of multiple sequences
Version 1.02
use Data::Dumper; use Algorithm::MLCS; my @seqs = ( [ qw/a b c d f g h j q z/ ], [ qw/a b c d f g h j q z/ ], [ qw/a b c x f h j q z/ ], [ qw/a b c f g j q z/ ], ); my @lcs = lcs( \@seqs ); my $lcs_length = lcs( \@seqs ); print Dumper( \@lcs );
Finding the longest common subsequence (LCS) for the general case of an arbitrary number of input sequences is an NP-hard problem. Algorithm::MLCS implements a fast heuristic algorithm that addresses the general case of multiple sequences. It is able to extract common subsequence that is close to the optimal ones.
Finds a Longest Common Subsequence of multiple sequences given by @seqs arrayref. Each element of @seqs is arrayref that represents the one of multiple sequences (e.g. [ ['a', 'b', 'c'], ['a', 'c', 'd', 'e'], ... ]). In list context it returns LCS array, in scalar - the length of LCS.
Algorithm::LCS
Slava Moiseev, <slava.moiseev at yahoo.com>
<slava.moiseev at yahoo.com>
Copyright 2012 Slava Moiseev.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Algorithm::MLCS, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::MLCS
CPAN shell
perl -MCPAN -e shell install Algorithm::MLCS
For more information on module installation, please visit the detailed CPAN module installation guide.