Indexes for Jumbled Pattern Matching in Strings, Trees and Graphs

Ferdinando Cicalese, Travis Gagie, Emanuele Giaquinta, Eduardo Sany Laber, Zsuzsanna Lipták, Romeo Rizzi, Alexandru I. Tomescu

This paper, published in 2013, explores the algorithmic challenges of Jumbled Pattern Matching (JPM)—a variation of pattern matching where the order of characters doesn't matter, only their frequencies (often represented as a Parikh vector). While standard pattern matching is a solved problem for strings, doing this efficiently on trees and graphs, especially when you want to pre-calculate an index for fast querying, is significantly more complex.

TL;DR

The authors present new indexing techniques for finding "jumbled" matches (where only color counts matter) in strings, trees, and graphs. Their standout contribution is showing that for trees with two colors, one can build a quadratic-space index for exact matches or a linear-space index for approximate matches, both allowing for query times proportional to the match size.

What Problem Does This Paper Address?

In traditional pattern matching, you look for an exact sequence like "APPLE." In jumbled pattern matching, you look for any arrangement that has the same multiset of characters—so "APPLE" would match "ELPPA" or "PALE P." This is useful in bioinformatics (e.g., matching mass spectrometry data to protein sequences) and network analysis.

The challenge escalates when the underlying data isn't a simple string but a tree or a graph. In these structures, a "match" is a connected subgraph whose nodes have the required color counts. Because a single graph can contain an exponential number of such subgraphs, determining if a match even exists is often NP-complete. The authors aim to find specific constraints (like limiting the number of colors or the graph structure) where efficient indexing becomes possible.

Methods

The paper builds its results incrementally, starting from simple strings and moving to complex trees:

  1. Binary String Indexing: For a string with two colors (0s and 1s), the authors utilize a "continuity" property: if a window of size $m$ has $p$ ones at one position and $r$ ones at another, every integer value between $p$ and $r$ is achieved by some window of size $m$ somewhere in the string. This allows for a binary search approach using a simple $O(n)$ space index.
  2. Tree-to-Path Transformation: For trees with two colors, the authors prove a similar continuity property. They show that you can transition between two connected subgraphs of the same size by swapping nodes one by one while maintaining connectivity. This allows them to store "extreme" subgraphs (those with the minimum and maximum number of a specific color) and search the "path" between them.
  3. Heavy-Path Decomposition: To make tree queries efficient, the authors use heavy-path decomposition to support fast "rank" queries (counting colors) along any path in the tree in $O(\log n)$ time.
  4. Approximation Sampling: To reduce space from $O(n^2)$ to $O(n)$ for trees, the authors sample subgraphs at specific intervals (powers of two and points where color counts increase by a factor of $1+\epsilon$).

Datasets

Not discussed in the paper. As a theoretical computer science paper, the authors focus on proving complexity bounds and providing algorithmic proofs rather than empirical testing on specific datasets.

Key Insights and Ideas

  • The Intermediate Value Theorem for Subgraphs: The most elegant insight is that connectivity in trees behaves predictably. If you have a subgraph with 5 white nodes and another with 10 white nodes (both of size $m$), there must exist subgraphs of size $m$ for every count between 5 and 10. This turns a needle-in-a-haystack search into a range-based search.
  • Self-Reducibility: The authors leverage the fact that finding a match is "self-reducible" in certain graph classes, meaning if you can decide if a match exists, you can efficiently construct it.
  • Space-Time Trade-offs: The paper highlights a clear hierarchy:
  • Strings: Easy ($O(n)$ space).
  • Trees (2 colors): Manageable ($O(n^2)$ space for exact, $O(n)$ for approx).
  • Graphs/Many Colors: Hard (NP-complete or exponential space requirements).

Key Results

  • Binary Paths: For a path with two colors, they achieved an $O(n)$-space index with $O(\log n)$ query time.
  • Exact Tree Index: For a tree with two colors, they developed an $O(n^2)$-space index that finds a match in $O(|M|)$ time, where $|M|$ is the size of the query multiset.
  • Approximate Tree Index: By accepting a small error margin ($\epsilon$), they reduced the tree index space to $O(n)$ while maintaining $O(|M|)$ query time.
  • General Graphs: For a graph with $c$ colors, they showed an index of $O(n^{c+1})$ space can find a match in $O(|M|)$ time.

Limitations and Future Work

  • Color Constraints: Most of the efficient tree results are strictly limited to two colors. As the number of colors increases, the problem quickly becomes computationally intractable (NP-complete).
  • Graph Complexity: While the paper touches on graphs, the results are mostly limited to graphs with bounded treewidth or require exponential space relative to the number of colors.
  • Future Directions: The authors suggest extending these results to general graphs by working on spanning trees, which could provide a bridge between the rigid tree structures and more complex networks.

Summary updated

BibTeX
@inproceedings{cicalese2013indexes,
  author = {Ferdinando Cicalese and Travis Gagie and Emanuele Giaquinta and Eduardo Sany Laber and Zsuzsanna Lipták and Romeo Rizzi and Alexandru I. Tomescu},
  title = {{Indexes for Jumbled Pattern Matching in Strings, Trees and Graphs}},
  booktitle = {SPIRE},
  year = {2013},
  doi = {10.1007/978-3-319-02432-5\_10},
}
Figure