arXiv:2609.17353cs.CCSep 2026

Manuscript Offprint

arXiv:2609.17353

Towards Optimal Prefix-Free Graph Construction: NP-Hardness and Structural Insights

Andrej Baláž, Alexandru Popa

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Prefix-free parsing provides an efficient way to construct compressed representations of large and repetitive pangenomes and naturally induces a graph representation known as a prefix-free graph. In this work, we initiate a theoretical study of the problem of constructing prefix-free graphs of minimum size, where the size accounts for both the total length of distinct segment labels and the paths representing the input sequences.

We show that selecting an optimal set of trigger words is NP-hard, already when triggers consist of single characters. Using a synchronized-code reduction, we extend this hardness result to every fixed trigger length and further show that the problem remains NP-hard over an alphabet of size three. We then establish a structural connection between prefix-free graphs and de Bruijn graphs. In particular, we show that every compacted de Bruijn graph can be realized as a prefix-free graph and derive a hierarchy relating the sizes of minimum pangenomic graphs, minimum prefix-free graphs, compacted de Bruijn graphs, and de Bruijn graphs. Finally, we give an exact fixed-parameter algorithm running in O(2qn)O(2^{q}n) time, where q is the number of distinct candidate trigger words and n is the total pangenome length.

Our results characterize both the computational limitations and the structural properties of optimizing prefix-free graph representations and provide a theoretical foundation for the design of compact graph representations of repetitive pangenomic data.

1 Introduction

Sequence alignment is one of the fundamental operations in bioinformatics. In a typical read-mapping workflow, sequencing reads are aligned to a reference genome so that differences between the reads and the reference can be identified and, ultimately, associated with phenotypes of interest. Traditionally, the reference is represented by a single finite string over the alphabet Σ={A,C,G,T}\Sigma = \{A, C, G, T\}. A single linear reference, however, can induce reference bias: inferred sequences may be systematically pulled toward the chosen reference rather than reflecting the variation supported by the data [1]. One way to mitigate this bias is to represent and analyze multiple related genomes jointly, that is, to use a pangenome.

The term pangenome was introduced by Tettelin et al. [27] in their study of variation in Streptococcus agalactiae. The Computational Pan-Genomics Consortium defines a pangenome broadly as a set of genomic sequences intended to be analyzed jointly [1]. In practice, pangenomic collections often contain genomes from closely related organisms and are therefore both large and highly repetitive. These two properties make the choice of representation algorithmically important.

A common approach is to represent a pangenome as a graph. Similar genomic regions are shared, while variation is represented by alternative walks through the graph. Variation graphs [12][12], for example, can encode a wide range of variation, from single-nucleotide substitutions to large structural rearrangements.

Their flexibility also means that the same set of sequences can admit many non-isomorphic graph representations, with no canonical choice of the most useful one. Moreover, Equi et al. [8] showed, assuming the Strong Exponential Time Hypothesis, that general labeled graphs do not admit polynomial-size indexes supporting truly subquadratic pattern matching. This has motivated the study of more structured graph classes, including cactus graphs [25, 26], Wheeler graphs [11], elastic-degenerate strings [3, 16], founder block graphs [21], and p-sortable graphs [7]. Many such constructions, however, rely on pairwise or multiple-sequence alignment and can therefore be expensive on large pangenomes.

A complementary approach is to keep the pangenome as a collection of strings and exploit repetitiveness inside compressed string-processing algorithms. This approach builds on a mature toolkit that includes the Burrows–Wheeler transform, suffix arrays, suffix trees, and compressed variants of these structures. The central practical difficulty is to construct such data structures for very large repetitive collections using close-to-linear time and substantially less working space than the uncompressed input.

Prefix-free parsing (PFP), inspired by context-triggered piecewise hashing [18], addresses this difficulty by partitioning strings at positions selected by a rolling hash. The partition produces a dictionary of distinct phrases together with a parse over phrase identifiers. This representation has been used to construct a variety of compressed data structures efficiently, including the Burrows–Wheeler transform, compressed suffix trees, Wheeler graphs, FM-indexes, and Lempel–Ziv factorizations [10, 5, 4, 13, 2, 24, 15, 14, 9, 17, 20].

In previous work [2], we observed that the dictionary and parse produced by prefix-free parsing naturally induce a graph, which we called a prefix-free graph (PFG). Prefix-free graphs can be constructed much faster than alignment-based pangenome graphs, support the construction of several compressed string indexes, and admit a precise combinatorial description that makes their structure amenable to theoretical analysis. They are also closely related to de Bruijn graphs: choosing all trigger words of a fixed length yields the corresponding node-centric de Bruijn representation, while removing triggers merges consecutive non-branching regions.