arXiv:2611.03594cs.DSNov 2026

Manuscript Offprint

arXiv:2611.03594

Square-Root Pass Semi-Streaming Algorithms for Digraph Problems

Prantar Ghosh, Amirhossein Janfaza

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

Abstract

We study directed graph problems in the semi-streaming model where we are restricted to O~(n):=O(n⋅polylog(n))\tilde{O}(n) := O(n \cdot \text{polylog}(n)) space for processing the edge stream of an nn-node graph and can make one or a few passes to solve the given problem. A longstanding open problem in multipass streaming is determining the number of semi-streaming passes needed to solve directed s,ts, t-reachability: there is an exponential gap—Ω(log⁡n/log⁡log⁡n)\Omega(\log n / \log \log n) vs n1/2+o(1)n^{1/2+o(1)}—between the best-known lower and upper bounds. Several related fundamental digraph problems, e.g., topological sorting, acyclicity testing, and decomposition into strongly connected components (SCCs), are known to have the same semi-streaming pass lower bound. However, no o(n/polylog(n))o(n/\text{polylog}(n))-pass upper bound was known for any of them. Our main result achieves an n1/2+o(1)n^{1/2+o(1)}-pass semi-streaming algorithm for each of these problems. As a corollary, we get algorithms with the same pass and space usage for a broad class of DAG problems that admit a certain form of dynamic program over a topological ordering. This class includes weighted single-source shortest paths, longest paths, max-outdegree+1 coloring, and constructing a lexicographically-first DFS (depth-first search) forest. Our algorithm for the last problem can be seen as a generalization of our results on topological sorting and acyclicity testing: recall that standard textbook algorithms for these problems use DFS as a subroutine.

It is easy to show that all our algorithms are optimal up to an no(1)n^{o(1)} factor in passes under the reasonable conjecture that s,ts, t-reachability requires Ω(n)\Omega(\sqrt{n}) semi-streaming passes (weaker than the conjecture that the current-best n1/2+o(1)n^{1/2+o(1)} bound is tight). However, using the fact that our algorithms can be parameterized by the number of passes taken by topological sorting or single-source reachability algorithms, we prove stronger lower bounds for some of the problems even under weaker conjectures. Along this line, we define complexity classes of digraph problems according to their semi-streaming pass complexity and explore the relationships among these classes. Overall, this presents a clearer picture of the hardness of various graph problems in the semi-streaming model.

  • (pghosh@tntech.edu) Department of Computer Science, Tennessee Tech University, USA. Funded in part by startup support provided by the Department of Computer Science and the College of Engineering at Tennessee Tech. † (amirhossein26@ru.is) Department of Computer Science, Reykjavík University, Iceland.

1 Introduction

The semi-streaming model has emerged as a natural setting for processing massive graphs arriving as a stream of edges. Semi-streaming algorithms are restricted to O~(n):=O(n⋅polylog(n))\widetilde{O}(n) := O(n \cdot \text{polylog}(n)) space for an nn-node graph, which is sublinear in the (worst-case) number of edges, while permitting small amount of information per vertex. This makes many graph problems tractable [FKM++^+05]. When a single pass is insufficient for a solution, a natural workaround is to make more passes over the stream and optimize this number.

Motivation and Background. The directed s,ts, t-reachability problem asks whether there is a directed path from a node ss to another node tt in the graph. It is one of the most basic problems in the study of graph algorithms, but surprisingly, its complexity is far from resolved in the streaming model. The seminal work of Guruswami and Onak [GO13] proved that any pp-pass streaming algorithm for the problem requires n1+Ω(1/p)/pO(1)n^{1+\Omega(1/p)}/p^{O(1)} space. This means any semi-streaming algorithm must make at least Ω(log⁡n/log⁡log⁡n)\Omega(\log n / \log \log n) passes. The lower bound holds even when the input graph is promised to be a DAG (directed acyclic graph). This lower bound extends to related directed graph problems. Chakrabarti, Ghosh, McGregor, and Vorotnikova [CGMV20] showed simple reductions from reachability on DAGs to acyclicity and topological sorting. Baweja, Jia, and Woodruff [BJW22] subsequently showed similar reductions to strong connectivity and decomposition into strongly connected components (SCCs). A couple of works made progress in improving the reachability lower bound, but only for sublogarithmic passes: Assadi and Raz [AR20] proved that almost-linear n2−o(1)n^{2-o(1)} space is required for two passes, while [CKP++^+21] extended it to hold for log⁡n\sqrt{\log n} passes. However, their general space/pass tradeoff lower bound did not improve the state of the art for semi-streaming space: the longstanding Ω(log⁡n/log⁡log⁡n)\Omega(\log n / \log \log n) pass barrier remains.

The best-known upper bounds are nowhere close. Observe that O(n)O(n) passes are trivially sufficient: one can simulate DFS (depth-first search) in these many passes (by adding a new node to the DFS forest per pass), which is the textbook approach for all the aforementioned problems in the classical model. To the best of our knowledge, among these problems, only reachability has a published strongly-sublinear-in-nn pass upper bound for semi-streaming space: [AJJ++^+22] gave an n1/2+o(1)n^{1/2+o(1)}-pass semi-streaming algorithm, building on the parallel reachability algorithm of Jambulapati, Liu, and Sidford [JLS19]. Their implementation extends to single-source reachability: one can determine all vertices reachable from a source ss, and moreover recover an explicit directed s−vs-v path for every reachable vertex vv.

There has been recent work on topological ordering in the streaming model: Chen, Lin, and Tsai [CLT25] developed parameterized streaming algorithms for the problem. They show that a DAG with independence number α\alpha can be topologically sorted in O(1/ε)O(1/\varepsilon) passes using O(αn1+ε)O(\alpha n^{1+\varepsilon}) space, and an approximate topological ordering with maximum displacement δ\delta can be leveraged to obtain an O(n)O(\sqrt{n})-pass algorithm using O(n+δ2)O(n + \delta^2) space. Indeed, these algorithms do not admit sublinear space for all DAGs (since α\alpha and δ\delta can be Θ(n)\Theta(n) in the worst case). For arbitrary DAGs, they give a tradeoff of n/kn/k-passes and O(nk)O(nk) space (previously such an algorithm was given by Janthong [Jan14]). Their framework also yields parameterized algorithms for SCC decomposition, strong connectivity, and related problems. More recently, Chen, Cheung, Lin, and Tsai [CCLT26] studied directed strong-connectivity certificates parameterized by the independence number. In the insertion-only model, for instance, they obtain pp-pass algorithms using roughly O~(αn1+1/p)\widetilde{O}(\alpha n^{1+1/p}) space for a 1-strong-connectivity certificate, from which several directed connectivity tasks can be solved. Unfortunately, none of these results give o(n/polylog n)o(n / \text{polylog } n)-pass semi-streaming algorithms in the worst case.

Our Contributions with Comparison to Prior Work. Our first contribution is to match the reachability upper bound for topological sorting and SCC-decomposition. We give n1/2+o(1)n^{1/2+o(1)}-pass semi-streaming algorithms for the problems on arbitrary digraphs. As immediate corollaries of our topological-sorting and SCC-decomposition algorithms, we obtain the same bound for cycle detection and cycle finding respectively. As mentioned above, each of these problems is known to be at least as hard as s,ts, t-reachability on DAGs. Thus, an improvement over our algorithms would, in particular, break the square-root barrier for reachability, at least for DAGs, and maybe shed light on the analogous square-root-depth barrier in parallel reachability, a more longstanding open problem.

We then establish topological sorting as a powerful tool for designing n1/2+o(1)n^{1/2+o(1)}-pass semi-streaming algorithms for problems on DAGs. Many classical algorithms on DAGs can be solved by the following approach: first obtain a topological ordering, then evaluate a dynamic program (DP) along this ordering. In the static setting, the implementation is straightforward once the DP is figured out. In a graph stream, however, even knowing the ordering does not immediately make the dynamic program implementable: a vertex may have too many incident edges to store, while its predecessors and successors are scattered arbitrarily throughout the stream. We show that a broad class of such dynamic programs can nevertheless be simulated in O(n)O(\sqrt{n}) semi-streaming passes, once a topological ordering is available. Combining this framework with our topological-sorting algorithm gives n1/2+o(1)n^{1/2+o(1)}-pass semi-streaming algorithms for several classical DAG problems, almost all of which generalize s,ts, t-reachability. These include single-source shortest paths and the global longest-path problem.

Shortest paths are among the most ubiquitous primitives in graph algorithms, while longest paths in DAGs have classical applications to precedence-constrained scheduling and critical-path analysis [KW59]. Exact-distance computation is considerably more challenging in streaming than offline computation. Hence, existing work on these problems in the streaming setting have focused on approximation [KSS16, KT25, AHS26]. There are, however, known O(n)O(\sqrt{n})-pass algorithms for exact shortest path on undirected graphs [CFHT20]. On directed graphs, Elkin [Elk11] gave n/kn/k-pass O(nk)O(nk)-space algorithms for exact shortest paths, which necessitates Ω(n/polylog(n))\Omega(n/\text{polylog}(n)) passes for semi-streaming space. To our knowledge, no o(n/polylog(n))o(n/\text{polylog}(n))-pass algorithm was previously known for directed graphs, even for unweighted DAGs. Our algorithms work for weighted DAGs, even on ones with negative edge weights: the absence of negative cycles (in fact, any cycle) removes the usual difficulty.

Recall that DFS generalizes the fundamental problems of aylicity, topological sorting, and SCC decomposition: classical textbook algorithms use DFS to solve these problems [CLRS22]. It is therefore natural to ask whether our results can be generalized to perform DFS, i.e., to construct a DFS forest of the input graph, in the streaming model. Khan and Mehta [KM19] gave an n/polylog(n)n/\text{polylog}(n)-pass semi-streaming algorithm for constructing DFS trees of undirected graphs that can be improved to h/polylog(n)h/\text{polylog}(n)-pass when the DFS tree has height hh. [CFHT20] improved upon their results by designing O~(n)\widetilde{O}(\sqrt{n})-pass semi-streaming algorithms, again for undirected graphs. No bound better than the trivial O(n)O(n) was known for digraphs, even for DAGs. Moreover, an arbitrary DFS forest is not sufficient for all of the applications mentioned above: in particular, the standard DFS algorithm for topological sorting relies on the “finish times” in addition. Consider the most standard simulation of DFS: break ties in a given lexicographic order. We call the DFS forest thus obtained as the lexicographically first DFS forest (LF-DFS). It lets us recover the entire traversal, including its finishing times. We show that the LF-DFS of a DAG can be constructed in n1/2+o(1)n^{1/2+o(1)} semi-streaming passes. The key structural ingredient is a non-trivial DP on the topological order that needs care to establish and then implement in semi-streaming space. Interestingly, while DFS has been a primitive for topological sort in the classical setting, we show that in the streaming model, the reverse is a natural solution.

Our final algorithmic problem is of a slightly different flavor. It is the (Δout+1)(\Delta_{\text{out}} + 1)-coloring problem: every DAG can be properly colored with (Δout+1)(\Delta_{\text{out}} + 1) colors, where Δout\Delta_{\text{out}} is the maximum outdegree. One can show that the problem is at least as hard as (Δ+1)(\Delta + 1)-coloring (Δ\Delta is the max-degree of an undirected graph) but at least as easy as (κ+1)(\kappa + 1)-coloring (κ\kappa is the degeneracy of the graph). (Δ+1)(\Delta + 1)-coloring is known to be admit a single-pass semi-streaming algorithm [ACK19] while (κ+1)(\kappa + 1)-coloring requires Ω(n2)\Omega(n^2) space in a single pass [BCG20]. Although we are not aware of any concrete multipass lower bounds for the (κ+1)(\kappa + 1)-coloring problem when edges cannot repeat,1^1 it is known that its natural primitives like finding degeneracy value or a degeneracy ordering requires Ω(n1/3)\Omega(n^{1/3}) passes [AGL+^+24]. However, no o(n)o(n)-pass upper bound is known for any of these degeneracy-based problems. We design an n1/2+o(1)n^{1/2+o(1)}-pass (Δout+1)(\Delta_{\text{out}} + 1)-coloring algorithm. Although the problem does not admit a “stream-friendly” DP as the other ones, we combine the idea from our DP framework with other tools like ℓ0\ell_0-sampling and succeed in designing the algorithm. Complementing our algorithmic results, we show that unlike (Δ+1)(\Delta + 1)-coloring and Δ\Delta-coloring [AKM22], (Δout+1)(\Delta_{\text{out}} + 1)-coloring does not admit a single-pass semi-streaming solution and actually requires linear (i.e., Ω(n2)\Omega(n^2)) space. On the other hand, we also prove that similar to (κ+1)(\kappa + 1)-coloring, (Δout+1)(\Delta_{\text{out}} + 1)-coloring requires Ω~(n)\widetilde{\Omega}(n) passes when edges can repeat in the stream.

Finally, we explore hardness relative to the fundamental problems of reachability (single-pair and single-source)

1^1There is an Ω~(n)\widetilde{\Omega}(n)-pass lower bound for when edges can repeat in the stream [BCG20].

on DAGs and topological sorting. Under the natural conjecture that ss, tt-reachability needs Ω(n)\Omega(\sqrt{n}) passes, it is immediate that our algorithms are optimal up to no(1)n^{o(1)} passes. But since our algorithms can be parameterized by the number of passes required for topological sorting and that for single-source reachability, we show stronger lower bounds (tight up to constant or logarithmic factors) for certain problems even under weaker conjectures that topological sorting or single-source reachability require Ω(n)\Omega(\sqrt{n}) passes. Overall, our collection of results makes a significant advancement in the digraph streaming literature which has seen much slower progress than its undirected counterpart. We also present a clearer picture about the relative hardness of fundamental digraph problems whose complexity remains unresolved.

References (45)