betaFeedback

WorksComputer Science

Min-Plus Products and Dynamic Programming with Few Violations of the Adjacent Monge Inequalities

Abstract

Local rewards can introduce negative adjacent mixed differences into a convex transition cost. If a cost array BB has s(B)s(B) such differences, we express it as a Monge array minus s(B)s(B) weighted rectangles and sweep its columns, maintaining the lower envelope of the active rows. For explicit finite n×nn\times n matrices A,BA,B and L=⌈log⁡2(n+1)⌉L=\lceil\log_2(n+1)\rceil, we compute A⊗BA\otimes B and the smallest minimizing index for every entry in O(n2L+ns(B)L3)\mathcal{O}(n^2L+ns(B)L^3) time and O(n2)\mathcal{O}(n^2) space, giving near-quadratic time for arbitrary AA when s(B)=O(n)s(B)=\mathcal{O}(n), including right factors with Θ(n2)Θ(n^2) positive differences. For block costs given by a constant-time Monge oracle and rr signed rectangle corrections, the sweep activates each row when its prefix optimum becomes available and computes an optimal contiguous partition in O((n+r)L3)\mathcal{O}((n+r)L^3) time and O(n+r)\mathcal{O}(n+r) working space. The sweep handles convex transitions with interval rules and assigns one rectangle to each internal edge or hyperedge reward in a convex block cost, giving near-linear exact algorithms on sparse inputs for ordered graph modularity, weighted contiguous cluster editing, all-or-nothing HyperLam, and bounded-rank strict hypergraph modularity. Let cAPSPc_{\mathrm{APSP}} denote the deterministic exponent of all-pairs shortest paths with polynomially bounded integer weights. For fixed 3−cAPSP<α≤13-c_{\mathrm{APSP}}<α\le1, any deterministic O(nβ)\mathcal{O}(n^β)-time min-plus product algorithm for polynomially bounded integer matrices with s(B)≤n1+αs(B)\le n^{1+α} satisfies β≥cAPSP−1+αβ\ge c_{\mathrm{APSP}}-1+α. The reduction from general integer min-plus multiplication uses right factors obtained from (j−k)2(j-k)^2 by at most n1+αn^{1+α} interval discounts, with Θ(n2)Θ(n^2) positive differences and all remaining differences negative.

Introduction

In min-plus multiplication and sequential dynamic programming, each output is a minimum over candidate rows whose costs include a row-dependent offset. When the transition matrix is Monge, SMAWK [1] computes the product of an arbitrary n×nn \times n matrix with that transition matrix in O(n2)O(n^2) time, and the algorithms of Wilber and of Larmore and Schieber [31, 17] evaluate a triangular Monge recurrence in linear time. We study how these running times depend on the number of adjacent Monge inequalities violated by local rewards or interval adjustments to the transition costs.

For fixed row and column orders, define the adjacent mixed difference of a cost array CC by

ΔCp,q=C(p+1,q)+C(p,q+1)−C(p,q)−C(p+1,q+1).\Delta C_{p,q} = C(p + 1,q) + C(p,q + 1) - C(p,q) - C(p + 1,q + 1).

and measure its negative support by

N(C)={(p,q):ΔCp,q<0},s(C)=∣N(C)∣.\mathcal{N}(C) = \{(p,q) : \Delta C_{p,q} < 0\}, \qquad s(C) = |\mathcal{N}(C)|.

The adjacent Monge inequalities require ΔCp,q≥0\Delta C_{p,q} \ge0 at every cell, and algorithms for core-sparse Monge multiplication [25, 22, 14] use the number δ(C)\delta(C) of nonzero adjacent differences. The parameter s(C)s(C) counts the cells that violate the inequality, so an array with small s(C)s(C) can have Θ(n2)\Theta(n^2) positive differences. Adding row and column potentials ak+bja_k + b_j preserves every mixed difference and hence s(C)s(C), including when the row potentials are entries AikA_{ik} of a fixed row of the left factor or prefix optima D[k]D[k] in a recurrence.

Main results

We write L=⌈log⁡2(n+1)⌉L = \lceil\log_{2}(n + 1) \rceil and use the same tree of row minima for matrix products, where the offsets are supplied with each input row, and for sequential recurrences, where the computation supplies an offset when it reaches the corresponding state. Table 1 gives the bounds for each input representation.

Table 1. Time and working space for products and partitioning, with L=⌈log⁡2(n+1)⌉L = \lceil\log_{2}(n + 1) \rceil and constant-time entry or penalty oracles. Space for convex transitions is given per vector. For s(B)≤n1+αs(B) \le n^{1+\alpha} and fixed 3−cAPSP<α≤13 - c_{\mathrm{APSP}} < \alpha\le1, the product lower exponent is cAPSP−1+αc_{\mathrm{APSP}} - 1 + \alpha.

ProblemInputTimeSpace
Matrix product (Thm. 3.5)Explicit A,BA, B with s=s(B)s = s(B)O(n2L+nsL3)\mathcal{O}(n^{2}L + nsL^{3})O(n2)\mathcal{O}(n^{2})
Vector product (Thm. 3.4)Monge oracle and rr rectanglesO(nL+rL3)\mathcal{O}(nL + rL^{3})O(n+r)\mathcal{O}(n + r)
Partition DP (Thm. 3.6)Monge oracle and rr rectanglesO((n+r)L3)\mathcal{O}((n + r)L^{3})O(n+r)\mathcal{O}(n + r)
Partition DP (Cor. 3.7)Cost oracle and list of ss negative cellsO((n+s)L3)\mathcal{O}((n + s)L^{3})O(n+sL)\mathcal{O}(n + sL)
Convex transitions (Cor. 4.2)Coordinates, convex penalty, rr rectanglesO(nL+rL3)\mathcal{O}(nL + rL^{3}) per vector; O(n2L+nrL3)\mathcal{O}(n^{2}L + nrL^{3}) per matrixO(n+r)\mathcal{O}(n + r)
Partition with rewards (Thm. 4.4)Vertex masses and hh interactions of incidence size NNO(N+(n+h)L3)\mathcal{O}(N + (n + h)L^{3})O(n+h)\mathcal{O}(n + h)

Table 1. Time and working space for products and partitioning, with L=⌈log⁡2(n+1)⌉L = \lceil\log_{2}(n + 1) \rceil and constant-time entry or penalty oracles. Space for convex transitions is given per vector. For s(B)≤n1+αs(B) \le n^{1+\alpha} and fixed 3−cAPSP<α≤13 - c_{\mathrm{APSP}} < \alpha\le1, the product lower exponent is cAPSP−1+αc_{\mathrm{APSP}} - 1 + \alpha.

Min-plus matrix multiplication. For explicit finite n×nn \times n matrices A,BA, B with s=s(B)s = s(B), Theorem 3.5 computes A⊗BA \otimes B and the smallest minimizing index for each entry in O(n2L+nsL3)\mathcal{O}(n^{2}L + nsL^{3}) time and O(n2)\mathcal{O}(n^{2}) space, which gives O(n2L3)\mathcal{O}(n^{2}L^{3}) time when s=O(n)s = \mathcal{O}(n) and allows every other cell of ΔB\Delta B to be strictly positive.

Sequential partitioning. Given a Monge background oracle MM with query time TMT_{M} and rr rectangles Iℓ×JℓI_{\ell} \times J_{\ell} with signed weights αℓ∈R\alpha_{\ell} \in\mathbb{R}, Theorem 3.6 evaluates the recurrence

D[j]=min⁡0≤k<j{D[k]+M(k,j)+∑ℓ=1rαℓ1{k∈Iℓ}1{j∈Jℓ}}D[j] = \min_{0 \le k < j} \left\{D[k] + M(k,j) + \sum_{\ell=1}^{r} \alpha_{\ell} \mathbf{1}\{k \in I_{\ell}\}\mathbf{1}\{j \in J_{\ell}\}\right\}

and reconstructs an optimal partition in O((n+r)L2(L+TM))\mathcal{O}((n + r)L^{2}(L + T_{M})) time and O(n+r)\mathcal{O}(n + r) working space. Given constant-time access to CC and the complete list of its ss negative legal differences, a persistent segment tree evaluates MM in O(L)\mathcal{O}(L) time per query, giving O((n+s)L3)\mathcal{O}((n + s)L^{3}) total time and O(n+sL)\mathcal{O}(n + sL) additional space (Corollary 3.7). Applying the sweep to each layer of the recurrence for exactly KK blocks takes O(K(n+r)L2(L+TM))\mathcal{O}(K(n + r)L^{2}(L + T_{M})) time (Corollary 3.8).

Convex transitions and contiguous partitions. For a convex transition cost ϕ(yj−xk)\phi(y_{j} - x_{k}) with rr interval surcharges or discounts, s(B)≤2rs(B) \le2r and the list of rules gives an O(nL+rL3)\mathcal{O}(nL + rL^{3})-time vector product (Corollary 4.2). For a contiguous block with convex load cost ϕ(Sj−Sk)\phi(S_{j} - S_{k}) and internal rewards ∑e⊆(k,j]we\sum_{e \subseteq(k,j]} w_{e}, each of the hh edges or hyperedges supplies one rectangle, so processing the incidence input of size NN and running the sweep takes O(N+(n+h)L3)\mathcal{O}(N + (n + h)L^{3}) time for a constant-time penalty. § 4 gives the resulting algorithms for ordered graph modularity [21], weighted contiguous cluster editing, all-or-nothing HyperLam [30], bounded-rank strict hypergraph modularity [16], and FENNEL with a fixed number of blocks [26].

Product lower bounds. For fixed 0<α≤10 < \alpha\le1, Theorem 5.1 reduces general min-plus multiplication on polynomially bounded integer entries to O(n1−α)\mathcal{O}(n^{1-\alpha}) products with s(B)≤n1+αs(B) \le n^{1+\alpha}, so a deterministic O(nβ)O(n^\beta)-time algorithm for these products gives an O(n1−α+β+n3−α)O(n^{1-\alpha+\beta}+n^{3-\alpha})-time algorithm for the general problem. For 3−cAPSP<α≤13-c_{\mathrm{APSP}}<\alpha\le1, the resulting lower exponent cAPSP−1+αc_{\mathrm{APSP}}-1+\alpha and the sweep’s upper exponent 2+α2+\alpha differ by 3−cAPSP3-c_{\mathrm{APSP}}. The right factors used in the reduction have background (j−k)2(j-k)^2, at most n1+αn^{1+\alpha} interval discounts, Θ(n2)\Theta(n^2) positive mixed differences, and a negative difference at every remaining cell (§ 5).

The column sweep

Rectangle corrections. The indicator Qp,q(k,j)=1{k≤p}1{j>q}Q_{p,q}(k,j)=1\{k\le p\}1\{j>q\} has adjacent mixed difference 11 at (p,q)(p,q) and 00 at every other cell.

References

  1. [1]Alok Aggarwal, Maria M. Klawe, Shlomo Moran, Peter W. Shor, and Robert E. Wilber. Geometric applications of a matrix-searching algorithm. Algorithmica, 2:195–208, 1987.
  2. [2]Willow Ahrens. Contiguous graph partitioning for optimal total or bottleneck communication. arXiv:2007.16192v4, 2021.arxiv.org/abs/2007.16192
  3. [3]Josh Alman and Virginia Vassilevska Williams. Truly subquadratic 3SUM and truly subcubic ASP via triangles in sparse lopsided graphs. arXiv:2610.06783, October 2026.
  4. [4]Thomas Bellitto, Tobias Marschall, Alexander Schönhuth, and Gunnar W. Klau. Next generation cluster editing. PeerJ Preprints, 3:e1301, 2015.
  5. [5]Cornelius Brand and Alexandra Lassota. Fast convolutions for near-convex sequences. In 34th International Symposium on Algorithms and Computation (ISAAC 2023), volume 283 of LIPIcs, pages 16:1–16:16, 2023.DOI
  6. [6]Amir Carmel, Dekel Tsur, and Michal Ziv-Ukelson. On almost Monge all scores matrices. In 27th Annual Symposium on Combinatorial Pattern Matching (CPM 2016), volume 54 of LIPIcs, pages 17:1–17:12, 2016.
  7. [7]Amir Carmel, Dekel Tsur, and Michal Ziv-Ukelson. On almost Monge all scores matrices. Algorithmica, 81:47–68, 2019.DOI
  8. [8]Panagiotis Charalampopoulos, Tomasz Kociumaka, Jakub Radoszewski, Solon P. Pissis, Wojciech Rytter, Tomasz Waleń, and Wiktor Zuba. Approximate circular pattern matching. In 30th Annual European Symposium on Algorithms (ESA 2022), volume 244 of LIPIcs, pages 35:1–35:19, 2022.arxiv.org/abs/2208.08915
  9. [12]Pedro F. Felzenszwalb and Daniel P. Huttenlocher. Distance transforms of sampled functions. Theory of Computing, 8(19):415–428, 2012.
  10. [13]Paweł Gawrychowski and Adam Karczmarz. Improved bounds for shortest paths in dense distance graphs. In 45th International Colloquium on Automata, Languages, and Programming (ICALP 2018), volume 107 of LIPIcs, pages 61:1–61:15, 2018.
  11. [14]Paweł Gawrychowski, Egor Gorbachev, and Tomasz Kociumaka. Core-sparse Monge matrix multiplication: Improved algorithm and applications. In 33rd Annual European Symposium on Algorithms (ESA 2025), volume 351 of LIPIcs, pages 74:1–74:17, 2025.arxiv.org/abs/2408.04613
  12. [15]Klaus Heeger, André Nichtenlein, and Rolf Niedermeier. Parameterized lower bounds for problems in P via fine-grained cross-compositions. In 40th International Symposium on Theoretical Aspects of Computer Science (STACS 2023), volume 254 of LIPIcs, pages 35:1–35:19, 2023.arxiv.org/abs/2301.00797
  13. [16]Bogumił Kamiński, Valérie Poulin, Pawel Pralat, Przemysław Szufel, and François Théberge. Clustering via hypergraph modularity. PLOS ONE, 14(11):e0224307, 2019.DOI
  14. [17]Lawrence L. Larmore and Baruch Schieber. On-line dynamic programming with applications to the prediction of RNA secondary structure. Journal of Algorithms, 12(3):490–515, 1991.
  15. [18]Xingquan Li, Cong Cao, and Tao Zhang. Block diagonal dominance-based dynamic programming for detecting community. The Journal of Supercomputing, 76(11):8627–8640, 2020.DOI
  16. [19]Min Chih Lin, Francisco J. Sou lignac, and Jayme L. Szwarcfiter. A faster algorithm for the cluster editing problem on proper interval graphs. Information Processing Letters, 115(11):913–916, 2015.DOI
  17. [20]M. E. J. Newman and M. Girvan. Finding and evaluating community structure in networks. Physical Review E, 69:026113, 2004.pubmed.ncbi.nlm.nih.gov/14995526
  18. [21]Alice Patania, Antoine Allard, and Jean-Gabriel Young. Exact and rapid linear clustering of networks with dynamic programming. Proceedings of the Royal Society A, 479:20230159, 2023.DOI
  19. [22]Luís M. S. Russo. Multiplication algorithms for Monge matrices. In String Processing and Information Retrieval (SPIRE 2010), volume 6393 of LNCS, pages 94–105. Springer, 2010.
  20. [23]Luís M. S. Russo. Monge properties of sequence alignment. Theoretical Computer Science, 423:30–49, 2012.
  21. [24]Barna Saha and Christopher Ye. Simple, faster (min, +) matrix multiplication and APSP. arXiv:2610.20297, October 2026.arxiv.org/abs/2610.20297
  22. [25]Alexander Tiskin. Fast distance multiplication of unit-Monge matrices. Algorithmica, 71(4):859–888, 2015.
  23. [26]Charalampos E. Tsourakakis, Christos Gkantsidis, Bozidar Radunovic, and Milan Vojnovic. FENNEL: Streaming graph partitioning for massive scale graphs. In Proceedings of the 7th ACM International Conference on Web Search and Data Mining (WSDM 2014), pages 333–342, 2014.
  24. [27]Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. Journal of the ACM, 65(5):27:1–27:38, 2018.
  25. [29]Nate Veldt, David F. Gleich, and Anthony Wirth. A correlation clustering framework for community detection. In Proceedings of the 2018 World Wide Web Conference (WWW 2018), pages 439–448, 2018.DOI
  26. [30]Nate Veldt, Anthony Wirth, and David F. Gleich. Parameterized correlation clustering in hypergraphs and bipartite graphs. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining (KDD 2020), pages 1868–1876, 2020.arxiv.org/abs/2002.09460
  27. [31]Robert E. Wilber. The concave least-weight subsequence problem revisited. Journal of Algorithms, 9(3):418–425, 1988.DOI

Paper details

vlnc:W_rg6vykg5
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 8

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents