Skip to main content
QUICK REVIEW

[Paper Review] An O(n^{2.75}) algorithm for online topological ordering

Deepak Ajwani, Tobias Friedrich|ArXiv.org|Feb 21, 2006
Constraint Satisfaction and OptimizationComputer Science12 citations
TL;DR

This paper presents a novel O(n^2.75) algorithm for online topological ordering in directed acyclic graphs (DAGs) under edge insertions, significantly improving upon prior bounds for dense DAGs. The method uses a dynamic reordering strategy based on topological order swaps and efficient data structures with bucketed adjacency lists, achieving optimal performance on hard-edge insertion sequences while remaining competitive on random inputs.

ABSTRACT

We present a simple algorithm which maintains the topological order of a directed acyclic graph with n nodes under an online edge insertion sequence in O(n^{2.75}) time, independent of the number of edges m inserted. For dense DAGs, this is an improvement over the previous best result of O(min(m^{3/2} log(n), m^{3/2} + n^2 log(n)) by Katriel and Bodlaender. We also provide an empirical comparison of our algorithm with other algorithms for online topological sorting. Our implementation outperforms them on certain hard instances while it is still competitive on random edge insertion sequences leading to complete DAGs.

Motivation & Objective

  • To address the challenge of maintaining topological order in a DAG under online edge insertions with improved time complexity.
  • To overcome the limitations of existing algorithms that scale poorly on dense DAGs or worst-case insertion sequences.
  • To design a practical algorithm that combines theoretical efficiency with strong empirical performance on both random and hard instances.
  • To bridge the gap between theoretical bounds and practical performance in online topological sorting.

Proposed method

  • The algorithm maintains a bijective topological order T and dynamically reorders nodes via swaps when edge insertions violate topological constraints.
  • It uses two key data structures: a bijective mapping T and its inverse for O(1) lookup, and bucketed adjacency lists with parameter t ≈ n^0.75 to balance update costs.
  • When inserting edge (u,v) with v < u, the algorithm collects nodes A and B that violate topological order and recursively reorders them using merged sorted sets.
  • The algorithm employs a recursive Reorder procedure that processes node pairs in topological order, ensuring correctness through invariant maintenance.
  • Space is optimized via hashing-based structures, achieving O(n^2) space with O(n^2.75) expected time or O(n^2.25) space with O(n^2.75) worst-case time.
  • The algorithm supports online cycle detection and can be used in hybrid approaches with other algorithms for sparse vs. dense graphs.

Experimental results

Research questions

  • RQ1Can a deterministic online topological ordering algorithm achieve O(n^2.75) time complexity for dense DAGs under edge insertions?
  • RQ2How does the proposed algorithm compare empirically to existing methods like AHRSZ, MNR, and PK on hard insertion sequences?
  • RQ3Can the algorithm maintain strong performance on random edge insertion sequences while outperforming others on worst-case inputs?
  • RQ4What is the trade-off between worst-case time complexity and practical efficiency in online topological sorting?

Key findings

  • The proposed algorithm achieves O(n^2.75) time complexity for online topological ordering, improving upon the previous best bound of O(min{m^1.5 log n, m^1.5 + n^2 log n}) for dense DAGs.
  • On a class of hard insertion sequences, the algorithm runs 30 times faster than AHRSZ, 3.6 times faster than PK, and 2 times faster than MNR for n = 8000.
  • For random edge sequences leading to complete DAGs, the algorithm is within a factor of 2–4 of the best-performing existing algorithms (AHRSZ, MNR, PK).
  • The algorithm's performance degrades initially during the first O(n log n) edge insertions due to frequent data structure updates, but stabilizes afterward with a slope only half that of AHRSZ.
  • The algorithm supports online cycle detection and can be used in hybrid systems, combining with PK or KB for sparse graphs and itself for dense graphs.
  • With appropriate data structure tuning, the algorithm achieves O(n^2.75) expected time with O(n^2) space, or O(n^2.75) worst-case time with O(n^2.25) space.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.