arXiv:2608.25212cs.DSAug 2026

Manuscript Offprint

arXiv:2608.25212

Time-Optimal APSP and Matrix Multiplication in Classes of Linear Neighborhood Complexity

Édouard Bonnet, Julien Duron, Marcin Pilipczuk, Marek Sokołowski, Szymon Toruńczyk

Abstract

The notion of linear neighborhood complexity is a very general structural assumption on a graph class, covering most classes of sparse graphs such as planar graphs, graphs excluding a fixed (topological) minor, or bounded expansion graphs, as well as many structured classes of dense graphs, such as graphs of bounded clique-width, twin-width, merge-width, or flip-width.

In this work, we present O(n2)\mathcal{O}(n^{2})-time optimal algorithms for nn-vertex graphs coming from a class of linear neighborhood complexity for the following problems:

• ALL-PAIRS SHORTEST PATHS,

  • the multiplication of the adjacency matrix M of the input graph with any n×nn \times n matrix. More specifically, after a quadratic preprocessing, we can multiply M with any n-vector in O(n)\mathcal{O}(n) time.

This solves several questions raised in [Bonnet, Kim, Geniet, Moon; ICALP '26], and improves and generalizes results in several other recent papers [Bonnet, Giocanti, Ossona de Mendez, Thomassé; STACS '23], [Bannach, Marwitz, Tantau; STACS '24], [Anand, van den Brand, McCarty; NeurIPS '26], [Kozma, Opler '26], and [Cardinal, McCarty, Yuditsky '26]. We also extend our results to classes of bounded VC density.

In classes of linear neighborhood complexity, we also give a triangle-detection algorithm in randomized linear time O(n+m)\mathcal{O}(n+m) in nn-vertex mm-edge graphs, a K4K_4-detection algorithm in randomized O(nlog⁡5n+mlog⁡n)\mathcal{O}(n\log^5 n + m\log n) or deterministic O(n2)\mathcal{O}(n^2) time, and a K5K_5-detection algorithm in randomized O(nlog⁡9n+mlog⁡5n)\mathcal{O}(n\log^9 n + m\log^5 n) time.

*CNRS, ENS de Lyon, Université Claude Bernard Lyon 1, LIP UMR 5668, 69342 Lyon, France. Homepage: http://perso.ens-lyon.fr/edouard.bonnet. Email: edouard.bonnet@ens-lyon.fr.

†^{\dagger}Institute of Informatics, University of Warsaw, Poland. Email: j.duron@uw.edu.pl

‡^{\ddagger}Institute of Informatics, University of Warsaw, Poland. Homepage: https://www.mimuw.edu.pl/~malcin/. Email: m.pilipczuk@uw.edu.pl.

§^{§}Max Planck Institute for Informatics, Saarland Informatics Campus, Saarbrücken, Germany. Homepage: https://mnbvmar.github.io. Supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) grant number 559177164. Email: msokolow@mpi-inf.mpg.de.

^{¶}Institute of Informatics, University of Warsaw, Poland. Homepage: https://www.mimuw.edu.pl/~szymtor/. Email:szymtor@uw.edu.pl.

Contents

1 Introduction 1
1.1 Our results 2
2 Preliminaries 5
2.1 Neighborhood complexity 5
2.2 Symmetric difference and sd-degeneracy 5
2.3 Signed tree models and interval biclique partitions 6
2.4 Matrix multiplication 7
3 Finding an sd-degeneracy sequence deterministically 7
4 SSSP in graphs given with an interval biclique partition 9
4.1 Interval intersections data structure 11
5 Wrap-up of the algorithmic corollaries 14
6 Finding an sd-degeneracy sequence in randomized linear time 15
7 Finding Small Patterns 19
A Neighborhood complexity and versatile symmetric difference 28

References (47)