English

An output-sensitive algorithm for all-pairs shortest paths in directed acyclic graphs

Data Structures and Algorithms 2021-08-10 v1

Abstract

A straightforward dynamic programming method for the single-source shortest paths problem (SSSP) in an edge-weighted directed acyclic graph (DAG) processes the vertices in a topologically sorted order. First, we similarly iterate this method alternatively in a breadth-first search sorted order and the reverse order on an input directed graph with both positive and negative real edge weights, nn vertices and mm edges. For a positive integer t,t, after O(t)O(t) iterations in O(tm)O(tm) time, we obtain for each vertex vv a path distance from the source to vv not exceeding that yielded by the shortest path from the source to vv among the so called {\emt+ t+light paths}. A directed path between two vertices is t+t+light if it contains at most tt more edges than the minimum edge-cardinality directed path between these vertices. After O(n)O(n) iterations, we obtain an O(nm)O(nm)-time solution to SSSP in directed graphs with real edge weights matching that of Bellman and Ford. Our main result is an output-sensitive algorithm for the all-pairs shortest paths problem (APSP) in DAGs with positive and negative real edge weights. It runs in time O(min{nω,nm+n2logn}+vVindeg(v)leaf(Tv)),O(\min \{n^{\omega}, nm+n^2\log n\}+\sum_{v\in V}\text{indeg}(v)|\text{leaf}(T_v)|), where nn is the number of vertices, mm is the number of edges, ω\omega is the exponent of fast matrix multiplication, indeg(v)\text{indeg}(v) stands for the indegree of v,v, TvT_v is a tree of lexicographically-first shortest directed paths from all ancestors of vv to vv, and leaf(Tv)\text{leaf}(T_v) is the set of leaves in Tv.T_v. Finally, we discuss an extension of hypothetical improved upper time-bounds for APSP in non-negatively edge-weighted DAGs to include directed graphs with a polynomial number of large directed cycles.

Keywords

Cite

@article{arxiv.2108.03455,
  title  = {An output-sensitive algorithm for all-pairs shortest paths in directed acyclic graphs},
  author = {Andrzej Lingas and Mia Persson and Dzmitry Sledneu},
  journal= {arXiv preprint arXiv:2108.03455},
  year   = {2021}
}

Comments

18 pages 5 figures

R2 v1 2026-06-24T04:54:42.183Z