Skip to main content
QUICK REVIEW

[Paper Review] A Compact DAG for Storing and Searching Maximal Common Subsequences

Alessio Conte, Roberto Grossi|arXiv (Cornell University)|Jan 1, 2023
Algorithms and Data CompressionComputer Science3 citations
TL;DR

This paper introduces a compact directed acyclic graph (MDAG) that represents all maximal common subsequences (MCSs) of two strings in polynomial space O(n³σ) and builds it in O(n³σ log n) time. The MDAG enables constant amortized time (CAT) enumeration, lexicographic rank/select operations, and prefix-based search—all in near-optimal time—closing the complexity gap between LCS and MCS computation.

ABSTRACT

Maximal Common Subsequences (MCSs) between two strings X and Y are subsequences of both X and Y that are maximal under inclusion. MCSs relax and generalize the well known and widely used concept of Longest Common Subsequences (LCSs), which can be seen as MCSs of maximum length. While the number both LCSs and MCSs can be exponential in the length of the strings, LCSs have been long exploited for string and text analysis, as simple compact representations of all LCSs between two strings, built via dynamic programming or automata, have been known since the '70s. MCSs appear to have a more challenging structure: even listing them efficiently was an open problem open until recently, thus narrowing the complexity difference between the two problems, but the gap remained significant. In this paper we close the complexity gap: we show how to build DAG of polynomial size-in polynomial time-which allows for efficient operations on the set of all MCSs such as enumeration in Constant Amortized Time per solution (CAT), counting, and random access to the i-th element (i.e., rank and select operations). Other than improving known algorithmic results, this work paves the way for new sequence analysis methods based on MCSs.

Motivation & Objective

  • To address the challenge of efficiently storing and querying the exponentially large set of maximal common subsequences (MCSs) between two strings.
  • To close the complexity gap between LCS and MCS computation, which previously lacked efficient data structures despite MCSs being more informative in some applications.
  • To design a compact, polynomial-size data structure that supports efficient enumeration, ranking, selection, and prefix search on MCSs.
  • To enable practical use of MCSs in sequence analysis by providing near-optimal algorithmic operations on the full set of MCSs.

Proposed method

  • Constructs a labeled direct acyclic graph (MDAG) where each path from source to target spells a unique MCS.
  • Uses path compression to compact unary paths, reducing space while preserving lexicographic order and path semantics.
  • Leverages lexicographic partitioning via sorted outgoing edges at each node to support ordered enumeration and rank/select operations.
  • Employs dynamic programming and annotated node counts (p(v)) to enable efficient selection and ranking using binary search on edge partial sums.
  • Implements CAT enumeration via DFS with lexicographic traversal of children, ensuring constant amortized time per solution.
  • Supports prefix search by traversing the MDAG along the given prefix and initiating enumeration from the resulting node.

Experimental results

Research questions

  • RQ1Can a compact data structure be designed to represent all maximal common subsequences (MCSs) between two strings in polynomial space and time?
  • RQ2Is it possible to support constant amortized time (CAT) enumeration of all MCSs using a compact data structure?
  • RQ3Can efficient rank and select operations over the lexicographically ordered set of MCSs be supported in near-optimal time?
  • RQ4Can prefix-based search for MCSs be efficiently supported using the same compact structure?
  • RQ5How can the exponential size of the MCS set be overcome without explicitly storing all strings?

Key findings

  • The MDAG data structure stores all MCSs in O(n³σ) space and can be constructed in O(n³σ log n) time.
  • Enumeration of all MCSs in lexicographic order is supported in constant amortized time (CAT), requiring O(|MCS(X,Y)|) total time.
  • Prefix search for strings in MCS(X,Y) is supported in O(|P| log σ + occ) time, where occ is the number of matching MCSs.
  • The i-th MCS in lexicographic order can be selected in O(|S| log σ) time, and the rank of a given MCS S can be computed in the same time.
  • The structure supports succinct storage and enables efficient random access operations, making MCSs practical for sequence analysis.
  • The work closes the complexity gap between LCS and MCS computation by providing polynomial-time, polynomial-space algorithms for all core operations on MCSs.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.