Maintaining a Topological Order Under Edge Insertions

Abstract A topological order of the vertices of a directed acyclic graph G = ( V , E ) is any total order ord such that if ( x , y ) ϵ E , then x precedes y in ord . In this paper we consider the dynamic version of this problem, and provide simple algorithms and data structures achieving O( n ) amortized time per edge insertion starting from an empty graph, which favorably compares to the trivial O( m + n ) time bound per operation obtained applying the off-line algorithm. The additional space requirement, beside the representation of the graph itself, is O( n ). Experimental results show that our algorithm performs in practice orders of magnitude faster than the off-line algorithm.

[1]  Kurt Mehlhorn,et al.  LEDA: a platform for combinatorial and geometric computing , 1997, CACM.

[2]  R. Tarjan Amortized Computational Complexity , 1985 .

[3]  Giuseppe F. Italiano,et al.  Amortized Efficiency of a Path Retrieval Data Structure , 1986, Theor. Comput. Sci..

[4]  Kurt Mehlhorn,et al.  Data Structures and Algorithms 2: Graph Algorithms and NP-Completeness , 1984, EATCS Monographs on Theoretical Computer Science.

[5]  Robert E. Tarjan,et al.  Data structures and network algorithms , 1983, CBMS-NSF regional conference series in applied mathematics.

[6]  Giuseppe F. Italiano,et al.  Finding Paths and Deleting Edges in Directed Acyclic Graphs , 1988, Inf. Process. Lett..