[Paper Review] Finding Maximal Exact Matches in Graphs
This paper presents the first parameterized algorithms for exact string matching to labeled directed acyclic graphs (DAGs), leveraging topological structure via novel graph classes like k-funnels and STk. By generalizing the Knuth-Morris-Pratt algorithm to track only prefix-incomparable matches, the approach achieves subquadratic performance on periodic strings and provides a time complexity of O((|V| + |E|)k² + m²), where k captures the DAG's structural complexity.
The problem of String Matching to Labeled Graphs (SMLG) asks to find all the paths in a labeled graph $G = (V, E)$ whose spellings match that of an input string $S \in Σ^m$. SMLG can be solved in quadratic $O(m|E|)$ time [Amir et al., JALG], which was proven to be optimal by a recent lower bound conditioned on SETH [Equi et al., ICALP 2019]. The lower bound states that no strongly subquadratic time algorithm exists, even if restricted to directed acyclic graphs (DAGs). In this work we present the first parameterized algorithms for SMLG in DAGs. Our parameters capture the topological structure of $G$. All our results are derived from a generalization of the Knuth-Morris-Pratt algorithm [Park and Kim, CPM 1995] optimized to work in time proportional to the number of prefix-incomparable matches. To obtain the parameterization in the topological structure of $G$, we first study a special class of DAGs called funnels [Millani et al., JCO] and generalize them to $k$-funnels and the class $ST_k$. We present several novel characterizations and algorithmic contributions on both funnels and their generalizations.
Motivation & Objective
- To address the quadratic lower bound for string matching to labeled DAGs under SETH by introducing parameterized algorithms based on topological structure.
- To generalize the Knuth-Morris-Pratt algorithm for DAGs by focusing only on prefix-incomparable matches to reduce computation.
- To define and characterize new graph classes—k-funnels and STk—that capture structural parameters enabling faster string matching.
- To provide efficient recognition and partitioning algorithms for these graph classes to support the parameterized solution.
- To explore the feasibility of extending the approach to counting/reporting and to unparameterized linear-time solutions in practice.
Proposed method
- Generalizes the Knuth-Morris-Pratt (KMP) algorithm for DAGs by maintaining only prefix-incomparable matches, reducing the number of active states.
- Introduces the concept of preface-incomparable sets (PIv) for each vertex v, which capture all valid prefix matches ending at v.
- Defines k-funnels and STk classes as generalizations of funnels, where k measures the maximum number of paths sharing a common prefix or suffix.
- Uses a partitioning strategy based on k-funnel structure to split the DAG into subgraphs G[V1] ∈ Sk and G[V2] ∈ Tk with no edges from V2 to V1.
- Employs dynamic programming to precompute a boolean table PS[i,j] in O(m²) time to test match existence across edges from V1 to V2 in O(|PIu|·|SIv|) time.
- Applies exponential search to compute the minimal k such that a DAG belongs to STk in O((|V| + |E|) log k) time.
Experimental results
Research questions
- RQ1Can string matching to labeled DAGs be solved in subquadratic time when parameterized by topological structure, despite a known SETH-based quadratic lower bound?
- RQ2How can the KMP algorithm be adapted to DAGs to avoid processing redundant prefix matches and achieve parameterized linear time?
- RQ3What are the structural properties of k-funnels and STk classes that allow for efficient string matching and recognition?
- RQ4Can the minimal k for which a DAG belongs to STk be computed efficiently, and how does this impact the overall algorithmic complexity?
- RQ5Is it possible to extend the parameterized approach to support counting or reporting all matches in linear time relative to the number of occurrences?
Key findings
- The paper presents a parameterized algorithm running in O((|V| + |E|)k² + m²) time, where k = maxv∈V(min(μs(v), μt(v))), which improves on the classical O(m|E|) bound for certain DAG structures.
- The algorithm achieves subquadratic performance on periodic strings by exploiting the bounded size of prefix-incomparable sets, which is upper-bounded by the structure of the pattern string S.
- A linear-time recognition algorithm is provided for k-funnels and STk classes, enabling efficient preprocessing for the parameterized solution.
- The minimal k such that a DAG is in STk can be computed in O((|V| + |E|) log k) time using exponential search.
- A dynamic programming table PS[i,j] is precomputed in O(m²) time to test match existence across inter-partition edges in O(|PIu|·|SIv|) time, with |PIu|·|SIv| = O(k²).
- The approach generalizes the KMP algorithm to DAGs by focusing only on prefix-incomparable matches, which are sufficient to represent all valid prefix matches ending at each vertex.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.