A layered directed acyclic graph (DAG) is a DAG the vertices of which are placed ... level is called a layer and a partition of the vertex set of a DAG into layers is.
Characterization of Layered Graphs with the Minimum Number of Dummy Vertices Patrick Healy and Nikola S. Nikolov CSIS Department, University of Limerick, Limerick, Republic of Ireland {patrick.healy,nikola.nikolov}@ul.ie Technical Report UL-CSIS-03-4 CSIS Department, University of Limerick June 2003
Abstract. We describe details of the structure and the dimensions of layered directed acyclic graphs (DAGs) with the minimum number of dummy vertices. The theoretical results presented in this paper can provide the necessary background for developing more efficient layering heuristics as well as for building a more complete picture of the nature of layered DAGs.
1
Introduction
A layered directed acyclic graph (DAG) is a DAG the vertices of which are placed on parallel (alt. concentric or radial) levels with all edges pointing in the same direction. In this work we assume parallel horizontal levels but our results are also valid in the case of concentric levels. The set of vertices placed on the same level is called a layer and a partition of the vertex set of a DAG into layers is known as a layering. Normally a DAG allows more than one alternative layerings and which one will be chosen for drawing depends on the specific requirements of the particular application. One of the properties that characterizes best a layering is the number of dummy (or virtual ) vertices introduced into the DAG at places where edges cross levels. A layered DAG has the minimum number of dummy vertices (MNDV) if there is no alternative layering for the same DAG with fewer dummy vertices. For brevity, we call a layered DAG with the minimum number of dummy vertices an MNDV DAG and the corresponding layering an MNDV layering. It has been empirically proven that MNDV DAGs are compact and have low edge density between neighbor layers, which makes them preferred from the aesthetic point of view [8]. Dummy vertices can be used not only as an aesthetic metric; their introduction is also required by the majority of vertex ordering algorithms (e.g., crossing minimization algorithms) which assume that all edges in a layered DAG have their endpoints in neighbor layers. To find a MNDV layering of a DAG is a relatively easy task. It is achieved by the layering algorithm proposed by Gansner et al. which has an exponential
running time in the worst case but runs very fast when applied to DAGs taken from practical applications [6, 8]. The algorithm of Gansner et al. is a network simplex algorithm adapted to partition the vertex set of a DAG into layers. Since the simplex method (in the form of network simplex method) can be applied successfully, the problem of finding an MNDV layering of a DAG is a polynomialtime problem. However, there is no known polynomial-time algorithm for solving it (except any of the polynomial-time algorithms for solving the generic linear programming problem). The study presented in this paper has been motivated by the goal to find a simple polynomial-time algorithm for finding MNDV layerings. We do not provide algorithmic solutions but we believe our theoretical study provides the necessary background that can lead to them. A better understanding of the nature of MNDV DAGs is also essential for further development of heuristic techniques for solving NP-hard layering problems such as width-constrained DAG layering with consideration of dummy vertices [1], for example. The paper is organized as follows. Section 2 introduces some terms and notation; our results are presented in Section 3, and Section 4 contains the conclusions from this work.
2
Preliminaries
Consider DAG G = (V, E), V and E are the vertex and the edge sets of G respectively. A layering L(G) of G is a partition of its vertex set into h ≥ 1 subsets, L(G) = {L1 , . . . , Lh }, such that ∀(u, v) ∈ E if u ∈ Li then v ∈ Ej with j < i. Each of the subsets Li is called a layer. Edge (u, v) with u ∈ Li is short in L(G) if v ∈ Li−1 and long otherwise. A layering is proper if all edges are short in it. A layering L(G) which is not proper can be made proper by introducing a set DL(G) of dummy (or virtual ) vertices which subdivide long edges. The height of a layering is the number layers. The width of a layer is the sum of the widths of all vertices (including the dummy vertices) in that layer, provided the vertices have nonnegative widths. The width of a layering is the maximum width of a layer. The contribution of long edges to the width of the layers is taken into account by assigning positive widths to the dummy vertices. The number of dummy vertices as well as the height and the width (i.e. the dimensions) of a layering are commonly used for describing the aesthetic quality of a layering [4]. Another not so widely used aesthetic criterion is the edge density between neighbor layers.
3
Results
Except the network simplex algorithm of Gansner et al. and the branch-andcut algorithm of Healy and Nikolov for dimension-constrained layering with the minimum number of dummy vertices [8, 7] there has been very little research on layered DAGs with relation to the number of dummy vertices. There are a few results about upper bounds on the number of dummy vertices in various classes
of layered DAGs [4, 5, 9]. A recent work has proven that it is NP-hard to find a layering with the minimum width when dummy vertices with positive width are taken into account [1]. The rest of this section describes various properties related to the structure and the dimensions of MNDV DAGs. 3.1
Bi-Connected Components and Trees
Our first observations are related to the bi-connected components (or blocks) of the underlying undirected graph of MNDV DAGs. For simplicity we use the expression block of a DAG instead the more correct block of the underlying undirected graph of a DAG. Theblock graph of DAG G is the undirected graph which has a vertex for each block B and each cutvertex v in the underlying undirected graph of G and edge {v, B} for each cutvertex v that belongs to block B. Note that the block graph of a connected graph is a tree [3]. Theorem 1. Each block in an MNDV DAG is layered with the minimum number of dummy vertices itself. Proof. We will prove this by induction. It is clearly true for DAGs which have a single block, i.e. are bi-connected. Assume it is true for all DAGs with k blocks. Consider DAG G with k + 1 blocks which is layered with the minimum number of dummy vertices. Let L(G) be the layering of G. G has at least one block B which is a leaf in the block graph of G connected to the rest of G by the cutvertex vB . Let G − B denotes the subgraph of G induced by all vertices that do not belong to B − vB , i.e. vB belongs to both G − B and B and it is their only intersection. Suppose B is not layered with the minimum number of dummy vertices. Then consider layering L∗ (G) with all the vertices in G − B layered relatively to each other as they are in L(G), and B layered with the minimum number of dummy vertices. Such a layering exists because B is connected to the rest of G by a single cutvertex, vB . Clearly, L∗ (G) will have fewer dummy vertices than L(G) which is a contradiction. Thus, with L(G) both B and G − B have the minimum number of dummy vertices. But G − B is a DAG with k blocks which means that the rest of the blocks of G are also layered with the minimum number of dummy vertices. Corollary 1. An MNDV DAG, whose underlying undirected graph is a tree, has zero dummy vertices. Proof. This is implied by Theorem 1 because each edge (with its endpoints) in a tree is a block. Theorem 1 shows that an MNDV layering of a DAG can be easily constructed once we have MNDV layerings of its blocks. In the rest of this section we take a look at the dimensions of MNDV DAGs.
3.2
Dimensions of MNDV DAGs
On average DAGs layered with the network simplex algorithm of Gansner et al. are significantly more compact than DAGs layered by some of the other commonly used layering algorithms, such as the longest-path algorithm [10] and the Coffman-Graham algorithm [2]. However, there are specific patterns which if present may cause MNDV DAGs to become several times higher than the minimum. An example of such a DAG is shown in Figures 1(a) and (b). Not only MNDV DAGs do not always have the minimum height but, as shown in Figure 1(c), they may contain dummy vertices along a longest path.
(a)
(b)
(c)
Fig. 1. Two drawings of the same DAG (a) with the minimum number of dummy vertices, and (b) with the minimum height; (c) an example of MNDV DAG with a dummy vertex along a longest path. Dummy vertices are drawn as rectangles.
Similarly, there are MNDV DAGs which are wider than the minimum, provided the dummy vertices are considered to occupy narrower space than the original vertices of the DAG. An example is shown is shown in Figures 2(a) and (b). The following theorem shows that MNDV st-DAGs have the minimum height. An st-DAG is a DAG with a single source (i.e. a vertex without incoming edges) and a single sink (i.e. a vertex without outgoing edges). Theorem 2. Each MNDV st-DAG has the minimum height equal to the number of vertices in the longest directed path. Proof. Consider an st-DAG G = (V, E). Let the term length of a path refer to the number of vertices in a path. For the proof of this theorem we use a partition P of the edge set of G into subsets, P = {Ei ⊆ E : i = 1, . . . , π}, where π is the
(a)
(b)
Fig. 2. An example of a DAG which may become too wide when layered with the minimum number of dummy vertices. Dummy vertices are drawn as rectangles.
length of the longest path in G. Edge e belongs to Ei if and only if the longest directed path that goes trough e has length i. Some of the subsets Ei could be empty. Obviously, Eπ has at least one element. Let L(G) be a layering of G and let DL(G) be the corresponding set of dummy vertices. Consider dummy vertex d∗ which divides edge e1 = (u, v) ∈ Ei into edges e11 = (u, d∗ ) and e21 = (d∗ , v). From the point of view of the partition P , to introduce d∗ means to remove e1 from Ei and to add both e11 and e21 to Ei+1 . If e1 lies on a longest path trough edge e2 ∈ Ej then the introduction of d∗ will also result in moving e2 to Ej+1 . Clearly, the introduction of a dummy vertex to edge in Ei can move up only edges which belong to any of the sets E1 , E2 , . . . , Ei . Given a DAG G with layering L(G) (not necessarily with the minimum number of dummy vertices), consider the described above edge set partition P before the introduction of dummy vertices. Introduce the dummy vertices one by one choosing at each step a dummy vertex that would subdivide an edge in Ei with i < π. Clearly, such a procedure of introducing the dummy vertices one by one will end up with all edges in Eπ and 0 or more dummy vertices to be added. To prove the theorem it is enough to prove that when all edges are in Eπ then G allows a unique proper layering without introducing the rest of the dummy vertices (if any). To show this we need to prove that all directed paths from sink to source, i.e. st-paths, in that case have the same length π. Let all edges be in Eπ . Suppose there are directed st-paths with length less than π and let e = (u, v) be an edge that lies on at least one of them. Let p1 = {s, . . . , u, v, . . . , t} be an st-path with a length k < π and let p1 be the longest path with length less than π trough e. This path is drawn with a solid line in Figure 3(a). Let the s − u part of p1 have length γ and the v − t part of p1 have length δ. Let p2 (drawn with a dashed line in Figure 3(b)) be an st-path with length π that also goes trough e. Let the s − t part of p2 have length α and the v − t part of p2 have length β. Consider the following three cases. Case 1. γ > α (alternatively δ > β). Then γ + β > α + β which is impossible because p1 is shorter than p2 . Case 2. Both γ < α and δ < β. Then γ +δ < α+δ < α+β which contradicts the fact that p1 is the longest path trough x which is shorter than π.
Case 3. γ = α (alternatively, δ = β). Then δ < β. Since p1 is shorter than p2 there must be at least one edge in the v − t part of p1 . Otherwise, v = t and δ = β = 0. Let x = (v, w) be the next edge in p1 after e and let p3 be a longest st-path (with length π) that goes trough x. The path p3 is drawn with a dotted line in Figure 3(c). Let ε be the length of the s − v part of p3 and ζ be the length of the w − t part of p3 . Clearly, ζ = β − 1. Otherwise, either ε + β > π, or α + 2 + ζ > π which is impossible. Then γ + 1 = α + 1 = ε and the w − t part of p1 must be shorter than ζ if p1 is shorter than π. But then we can repeat the same with the next edge in p1 after x. Continuing the same procedure we will end up choosing the last edge in p1 with the part of p1 above it being as long as the part of a longest directed st-path trough that edge. That is, p1 has length π, which is a contradiction.
s
s
s
u
u
u
e
e
e
v
v
v x w
t
t (a)
(b)
t (c)
Fig. 3. Illustration to the proof of Theorem 2.
4
Conclusions
We have described details of the structure and the dimensions some of MNDV DAGs. They show that in order to develop a polynomial-time algorithm for layering with the minimum number of dummy nodes it is enough to develop such an algorithm for DAGs whose underlying undirected graph is bi-connected. The picture of MNDV DAGs we have built can also play an essential role in developing efficient heuristics for solving NP-hard layering problems. Such problems are
width-constrained DAG layering with consideration of dummy nodes [1] and DAG layering with bounds on both the height and the width of the layering [2]. We also see a number of interesting open problems related to the properties of MNDV DAGs. We have shown that there are MNDV DAGs with dummy nodes along a longest path. However, it might be that each DAG (or a special class of DAGs) always allow layering with no dummy nodes along longest paths. We have given a detailed picture of MNDV st-DAGs while similar results for other classes of MNDV DAGs are an object of future work.
References 1. J. Branke, S. Leppert, M. Middendorf, and P. Eades. Width-restriced layering of acyclic digraphs with consideration of dummy nodes. Information Processing Letters, 81(2):59–63, January 2002. 2. E. G. Coffman and R. L. Graham. Optimal scheduling for two processor systems. Acta Informatica, 1:200–213, 1972. 3. R. Diestel. Graph Theory, volume 173 of Graduate Texts in Mathematics. SpringerVerlag, New York, second edition, 2000. 4. P. Eades and K. Sugiyama. How to draw a directed graph. Journal of Information Processing, 13(4):424–437, 1990. 5. A. Frick. Upper bounds on the number of hidden nodes in Sugiyama’s algorithm. In S. North, editor, Graph Drawing: Proceedings of the Symposium on Graph Drawing, GD ’96, volume 1190 of Lecture Notes in Computer Science, pages 169–183. Springer-Verlag, 1997. 6. E. R. Gansner, E. Koutsofios, S. C. North, and K.-P. Vo. A technique for drawing directed graphs. IEEE Transactions on Software Engineering, 19(3):214–230, March 1993. 7. P. Healy and N. S. Nikolov. A branch-and-cut approach to the directed acyclic graph layering problem. In M. Goodrich and S. Koburov, editors, Graph Drawing: Proceedings of 10th International Symposium, GD 2002, volume 2528 of Lecture Notes in Computer Science, pages 98–109. Springer-Verlag, 2002. 8. P. Healy and N. S. Nikolov. How to layer a directed acyclic graph. In P. Mutzel, M. J¨ unger, and S. Leipert, editors, Graph Drawing: Proceedings of 9th International Symposium, GD 2001, volume 2265 of Lecture Notes in Computer Science, pages 16–30. Springer-Verlag, 2002. 9. I. Lemke. Entwicklung und Implementierung eines Visualisierungswerkzeuges f¨ ur ¨ Anwendungen im Ubersetzerbau. Diplomarbeit, Universit¨ at des Saarlandes, FB 14 Informatik, 1994. 10. K. Mehlhorn. Data Structures and Algorithms, Volume 2: Graph Algorithms and NP-Completeness. Springer-Verlag, Heidelberg, Germany, 1984.