### 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 log n 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 log n. 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.

Original language | English (US) |
---|---|

Title of host publication | Automata, Languages and Programming - 35th International Colloquium, ICALP 2008, Proceedings |

Pages | 421-433 |

Number of pages | 13 |

Edition | PART 1 |

DOIs | |

State | Published - Aug 14 2008 |

Event | 35th International Colloquium on Automata, Languages and Programming, ICALP 2008 - Reykjavik, Iceland Duration: Jul 7 2008 → Jul 11 2008 |

### Publication series

Name | Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics) |
---|---|

Number | PART 1 |

Volume | 5125 LNCS |

ISSN (Print) | 0302-9743 |

ISSN (Electronic) | 1611-3349 |

### Other

Other | 35th International Colloquium on Automata, Languages and Programming, ICALP 2008 |
---|---|

Country | Iceland |

City | Reykjavik |

Period | 7/7/08 → 7/11/08 |

### All Science Journal Classification (ASJC) codes

- Theoretical Computer Science
- Computer Science(all)

## Fingerprint Dive into the research topics of 'Faster algorithms for incremental topological ordering'. Together they form a unique fingerprint.

## Cite this

*Automata, Languages and Programming - 35th International Colloquium, ICALP 2008, Proceedings*(PART 1 ed., pp. 421-433). (Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics); Vol. 5125 LNCS, No. PART 1). https://doi.org/10.1007/978-3-540-70575-8_35