English

Computing k-mers in Graphs

Data Structures and Algorithms 2026-02-23 v2

Abstract

We initiate the study of computational problems on kk-mers (strings of length kk) in labeled graphs. As a starting point, we consider the problem of counting the number of distinct kk-mers found on the walks of a graph. We establish that this is #\#P-hard, even on connected deterministic DAGs. However, in the class of deterministic Wheeler graphs (Gagie, Manzini, and Sir\`en, TCS 2017), we show that distinct kk-mers of such a graph W=(V,E)W=(V, E) can be counted using O(Wk)O(|W|k) or O(n4logk)O(n^4 \log k) arithmetic operations, where n=Vn=|V|, m=Em=|E| and W=n+m|W|=n+m. The latter result uses a new generalization of the technique of prefix doubling to Wheeler graphs. To generalize our results beyond Wheeler graphs, we discuss ways to transform a graph into a Wheeler graph in a manner that preserves the kk-mers. As an application of our kk-mer counting algorithms, we construct a representation of the de Bruijn graph of the kk-mers that occupies O(nk+Wklog(max1kn)+σlogm)O(n_k + |W|k \log(\max_{1 \leq \ell \leq k} n_\ell) + \sigma\log m) bits of space, where nn_\ell is the number of distinct \ell-mers in the Wheeler graph, and σ\sigma is the size of the alphabet. We show how to construct it in the same time complexity. Given that the Wheeler graph can be exponentially smaller than the de Bruijn graph, for large kk this provides a theoretical improvement over previous de Bruijn graph construction methods from graphs, which must spend Ω(k)\Omega(k) time per kk-mer in the graph.

Keywords

Cite

@article{arxiv.2509.22885,
  title  = {Computing k-mers in Graphs},
  author = {Jarno N. Alanko and Maximo Perez-Lopez},
  journal= {arXiv preprint arXiv:2509.22885},
  year   = {2026}
}
R2 v1 2026-07-01T05:59:49.868Z