# Level Planarity Testing in Linear Time

## abstract

In a leveled directed acyclic graph *G* = (*V*, *E*) the vertex set *V* is partitioned into *k* ≤ ∣*V*∣ levels *V* _{1}, *V* _{2},...,*V* _{ k } such that for each edge (*u*,*v*) ∈ *E* with *u* ∈ *V* _{ i } and *v* ∈ *V* _{ j } we have *i* <*j*. The level planarity testing problem is to decide if *G* can be drawn in the plane such that for each level *V* _{ i }, all *v* ∈ *V* _{ i } are drawn on the line *l* _{ i } = (*x*, *k* − *i*) ∣*x* ∈ ℝ , the edges are drawn monotone with respect to the vertical direction, and no edges intersect except at their end vertices. If *G* has a single source, the test can be performed in O(∣*V*∣) time by an algorithm of Di Battista and (1988) that uses the *PQ*-tree data structure introduced by Booth and (1976). *PQ*-trees have also been proposed by Heath and (1996a,b) to test level planarity of leveled directed acyclic graphs with several sources and sinks. It has been shown in (1997) that this algorithm is not correct in the sense that it does not state correctly level planarity of every level planar graph. In this paper, we present a correct linear time level planarity testing algorithm that is based on two main new techniques that replace the incorrect crucial parts of the algorithm of Heath and (1996a,b).

## References

- [1976]K. Booth and G. Lueker. Testing for the consecutive ones property, interval graphs, and graph planarity using PQ-tree algorithms.
*Journal of Computer and System Sciences*, 13:335–379, 1976.zbMATHMathSciNetGoogle Scholar - [1985]N. Chiba, T. Nishizeki, S. Abe, and T. Ozawa. A linear algorithm for embedding planar graphs using PQ-trees.
*Journal of Computer and System Sciences*, 30:54–76, 1985.zbMATHCrossRefMathSciNetGoogle Scholar - [1988]G. Di Battista and E. Nardelli. Hierarchies and planarity theory.
*IEEE Transactions on systems, man, and cybernetics*, 18(6):1035–1046, 1988.zbMATHCrossRefGoogle Scholar - [1996a]L.S. Heath and S.V. Pemmaraju. Recognizing leveled-planar dags in linear time. In F. J. Brandenburg, editor,
*Proc. Graph Drawing’ 95*, volume 1027 of*Lecture Notes in Computer Science*, pages 300–311. Springer Verlag, 1996a.CrossRefGoogle Scholar - [1996b]L.S. Heath and S.V. Pemmaraju. Stack and queue layouts of directed acyclic graphs: Part II. Technical report, Department of Computer Science, Virginia Polytechnic Institute & State University, 1996b.Google Scholar
- [1997]M. Jünger, S. Leipert, and P. Mutzel. Pitfalls of using PQ-trees in Automatic Graph Drawing. In G. DiBattista, editor,
*Graph Drawing’ 97*, volume 1353 of*Lecture Notes in Computer Science*, pages 193–204. Springer Verlag, 1997.CrossRefGoogle Scholar