Faster Algorithms for Incremental Topological Ordering

  • Authors:
  • Bernhard Haeupler;Telikepalli Kavitha;Rogers Mathew;Siddhartha Sen;Robert E. Tarjan

  • Affiliations:
  • Princeton University, Princeton NJ 08544;Indian Institute of Science, Bangalore, India;Indian Institute of Science, Bangalore, India;Princeton University, Princeton NJ 08544;Princeton University, Princeton NJ 08544 and HP Laboratories, Palo Alto, CA 94304

  • Venue:
  • ICALP '08 Proceedings of the 35th international colloquium on Automata, Languages and Programming, Part I
  • Year:
  • 2008

Quantified Score

Hi-index 0.00

Visualization

Abstract

We present two online algorithms for maintaining a topological order of a directed acyclic graph as arcs are added, and detecting a cycle when one is created. Our first algorithm takes O(m 1/2) amortized time per arc and our second algorithm takes O(n 2.5/m) amortized time per arc, where n is the number of vertices and m is the total number of arcs. For sparse graphs, our O(m 1/2) bound improves the best previous bound by a factor of logn and is tight to within a constant factor for a natural class of algorithms that includes all the existing ones. Our main insight is that the two-way search method of previous algorithms does not require an ordered search, but can be more general, allowing us to avoid the use of heaps (priority queues). Instead, the deterministic version of our algorithm uses (approximate) median-finding; the randomized version of our algorithm uses uniform random sampling. For dense graphs, our O(n 2.5/m) bound improves the best previously published bound by a factor of n 1/4 and a recent bound obtained independently of our work by a factor of logn. Our main insight is that graph search is wasteful when the graph is dense and can be avoided by searching the topological order space instead. Our algorithms extend to the maintenance of strong components, in the same asymptotic time bounds.