We consider the problem of incremental cycle detection and topological ordering in a directed graph G = (V, E) with |V | = n nodes. In this setting, initially the edge-set E of the graph is empty. Subsequently, at each time-step an edge gets inserted into G. After every edge-insertion, we have to report if the current graph contains a cycle, and as long as the graph remains acyclic, we have to maintain a topological ordering of the node-set V . Let m be the total number of edges that get inserted into G. We present a randomized algorithm for this problem withÕ(m 4/3 ) total expected update time.Our result improves theÕ(m · min(m 1/2 , n 2/3 )) total update time bound of [BFGT16; HKMST08; HKMST12; CFKR13]. Furthermore, whenever m = o(n 3/2 ), our result improves upon the recently obtainedÕ(m √ n) total update time bound of [BC18]. We note that if m = Ω(n 3/2 ), then the algorithm of [BFGT16; BFG09; CFKR13], which hasÕ(n 2 ) total update time, beats the performance of theÕ(m √ n) time algorithm of [BC18]. It follows that we improve upon the total update time of the algorithm of [BC18] in the "interesting" range of sparsity where m = o(n 3/2 ).Our result also happens to be the first one that breaks the Ω(n √ m) lower bound of [HKMST08] on the total update time of any local algorithm for a nontrivial range of sparsity. Specifically, the total update time of our algorithm is o(n √ m) whenever m = o(n 6/5 ). From a technical perspective, we obtain our result by combining the algorithm of [BC18] with the balanced search framework of [HKMST12].Result (1): There is an incremental algorithm with total update time ofÕ(n 2 ). This follows from the work of [BFGT16; BFG09; CFKR13]. So the problem is well understood for dense graphs where m = Θ(n 2 ).Result (2): There is an incremental algorithm with total update time ofÕ(m · min(m 1/2 , n 2/3 )). This follows from the work of [BFGT16; HKMST08; HKMST12; CFKR13].
Result (3):There is a randomized incremental algorithm with total expected update time ofÕ(m √ n). This follows from the very recent work of [BC18].Significance of Theorem 1.1. We obtain a randomized incremental algorithm for cycle detection and topological ordering that has an expected total update time ofÕ(m 4/3 ). Prior to this, all incremental algorithms for this problem had a total update time of Ω(n 3/2 ) for sparse graphs with m = Θ(n). Our algorithm breaks this barrier by achieving a bound ofÕ(n 4/3 ) on sparse graphs. More generally, our total update time bound ofÕ(m 4/3 ) outperforms theÕ(m √ n) bound from result (3) as long as m = o(n 3/2 ). Note that if 1 Throughout this paper, we use theÕ(.) notation to hide polylog factors.2 Throughout this paper we assume that m ≥ n. This is because if m = o(n) then many nodes remain isolated (with zero degree) in the final graph, and we can ignore those isolated nodes while analyzing the total update time of the concerned algorithm.3 It is easy to combine two incremental algorithms and get the "best of both worlds". For example, suppose that we want to combine results (1...