Incremental cycle detection, topological ordering, and strong component maintenance

Bernhard Haeupler, Telikepalli Kavitha, Rogers Mathew, Siddhartha Sen, Robert E. Tarjan

Research output: Contribution to journalArticlepeer-review

58 Scopus citations


We present two online algorithms for maintaining a topological order of a directed n-vertex acyclic graph as arcs are added, and detecting a cycle when one is created. Our first algorithm handles m arc additions in O(m 3/2) time. For sparse graphs (m/n = O(1)), this bound improves the best previous bound by a logarithmic factor, and is tight to within a constant factor among algorithms satisfying a natural locality property. Our second algorithm handles an arbitrary sequence of arc additions in O(n 5/2) time. For sufficiently dense graphs, this bound improves the best previous bound by a polynomial factor. Our bound may be far from tight: we show that the algorithm can take Ω(n 22 √ 2 lgn) time by relating its performance to a generalization of the k-levels problem of combinatorial geometry. A completely different algorithm running in θ(n2 log n) time was given recently by Bender, Fineman, and Gilbert. We extend both of our algorithms to the maintenance of strong components, without affecting the asymptotic time bounds.

Original languageEnglish (US)
Article number3
JournalACM Transactions on Algorithms
Issue number1
StatePublished - Jan 2012

All Science Journal Classification (ASJC) codes

  • Mathematics (miscellaneous)


  • Arrangement
  • Cycle detection
  • Directed graphs
  • Dynamic algorithms
  • Halving intersection
  • Strong components
  • Topological order


Dive into the research topics of 'Incremental cycle detection, topological ordering, and strong component maintenance'. Together they form a unique fingerprint.

Cite this