Keywords

1 Introduction

A widely used hierarchical drawing style for directed graphs is the method proposed by Sugiyama et al. [11] that involves the following steps in this order: (i) cycle removal, (ii) layering phase, (iii) crossing minimization, and (iv) coordinate assignment and arc routing. One of the consequences of this workflow is that it is hard to control the aspect ratio of the final layout. Phase (ii) requires an acyclic graph as input and the height of the produced layering inherently depends on its longest path. So if phase (i) breaks cycles inappropriately or if an acyclic graph whose longest path is much larger than its width is already given as initial input, it is impossible to construct a compact layering. However, the readability and compactness of a drawing might be considerably improved if arcs to be reversed are chosen carefully and in an integrated fashion, see Fig. 1 for an example. If it is required that all arcs point downward, then the layering will have a poor aspect ratio as shown in Fig. 1a. If we allow reversing some arcs so that they point upward, the aspect ratio can be improved drastically (see Figs. 1b and 1c).

In order to achieve this, Rüegg et al. [10] suggested to investigate the Gen- eralized Layering Problem (GLP) that combines the first two interdependent phases of the Sugiyama approach. As the problem is \(\mathcal {NP}\)-hard, they proposed an integer linear programming (ILP) formulation in which the weighted sum of the number of reversed arcs and the arcs lengths is minimized, and where also the height of the drawing can be restricted. Their approach improved the compactness of the derived layouts. However, it permits only limited control over the width since it does not take the dummy vertices into account that are caused by arcs connecting vertices on non-adjacent layers. On the other hand, Healy and Nikolov [5] have considered the layering problem with dummy vertices, but only for acyclic directed graphs (DAGs) and for the case that both the desired maximum height and the width of the drawing are given as inputs.

Fig. 1.
figure 1

(a) A graph drawn with traditional methods [2, 4] where every arc has to point downwards, resulting in a poor aspect ratio – here emphasized by scaling down the image to fit with the right ones. The methods CGL and MML, presented in this paper, are able to impose a bound on the height of the drawing, allowing some arcs to point upwards. The created drawings (b) and (c) are significantly more compact and improve readability. Reversed arcs are drawn bold and dashed.

Contributions. The purpose of this paper is to close this gap, i.e., to derive a model which is capable of computing a layering of a general digraph by minimizing a weighted sum of the number of reversed arcs, the total arc length, and the width W of the resulting drawing taking the dummy vertices into account. We call this the Compact Generalized Layering Problem (CGLP). The only input to our approach, besides the graph and the weights for the objective function, is the desired maximum height H of the drawing. We will discuss how H can be chosen such that the existence of a feasible layering is always guaranteed by our model — which is in contrast to a setting where the user has to specify both H and W. Nevertheless, an upper bound on W can still be specified.

We present two mixed integer linear programming (MIP) formulations for the CGLP. The first one (EXT) is a natural extension of the already mentioned model by Healy and Nikolov for DAGs, and based on assignment variables. The second one (CGL) is a completely new formulation based on partial orderings. Our computational experiments on two benchmark sets show that the CGL formulation can be solved much faster than EXT when using a standard commercial MIP solver (GurobiFootnote 1) for both of the models. Moreover, CGL is able to compute optimal solutions for each of the tested problem instances in less than seven minutes of computation time on a standard PC while taking only a few seconds for most of them.

While in general we try to keep edges short, we may want to emphasize reversed arcs, for example in a flow diagram with cycles, by drawing them rather long; see also Fig. 1c. For this reason, we propose a variant of CGL, called MML (Min+Max Length), for the problem of minimizing the weighted sum of reversed arcs, positive forward arc lengths, negative backward arc lengths, and the maximum number of real vertices on a layer. Within our experiments, MML is faster than both EXT and CGL without considerably increasing the average arc lengths and widths of the layouts.

As mentioned by Rüegg et al., the aspect ratio of a final drawing (i.e. in pixels) does not only depend on the layering but also on the final phases of the Sugiyama approach, i.e. coordinate assignment and arc routing. Even more, it can deviate significantly from the aspect ratio estimated after the layering phase, as described in [10]. Hence, in practice, there is a high demand for methods that can be quickly adjusted to the specific graph instance and use case. Here, the models presented in this paper provide more control over the produced layering compared to existing approaches to the GLP.

Outline. The paper is organized as follows. First, we discuss related research in Sect. 2. Definitions, preliminaries and motivations for our studies and models are given in Sect. 3. Section 4 presents our newly developed MIP models which are finally evaluated experimentally in Sect. 5. We conclude with Sect. 6.

2 Related Work

Over the years several approaches have been proposed for the layering phase of the Sugiyama approach. Eades and Sugiyama proposed a method that is known as longest path layering [3]. This approach guarantees to produce a layering with a minimum number of layers, i.e. minimum height, but the width can become arbitrarily large. Gansner et al. [4] use an ILP formulation to create layerings with minimum total arc length that can be solved efficiently using a network simplex algorithm. The Coffman-Graham algorithm [1] delivers approximate solutions to the precedence-constrained multi-processor scheduling problem that can be used to calculate a layering with a maximum number of real vertices per layer. However, dummy vertices are not taken into account but can have a significant impact on the actual width of the drawing. Still, Nachmanson et al. [8] use the Coffman-Graham algorithm as part of an iterative heuristic procedure to produce drawings with a certain aspect ratio.

The layering problem with restricted width and consideration of dummy vertices has been studied in the literature as well. Healy and Nikolov found that minimizing the number of dummy vertices during layering inherently produces compact drawings [6]. Following this observation, they target dummy vertex minimization with a branch and cut algorithm that is able to incorporate bounds on both width and height [5]. Nikolov et al. discuss heuristics to find layerings with small width when considering dummy vertices [9], however, no explicit bound on the width and height can be used.

Since all of the above methods rely on the input graph to be acyclic, the minimum height of their layerings directly relates to the longest path of the graph. Rüegg et al. [10] integrate the first two phases of the Sugiyama approach to allow arbitrary graphs as input by minimizing a weighted sum of the number of reversed arcs and the number of dummy vertices. They showed that this overcomes the previously mentioned problem regarding a graph’s longest path and also allows more compact drawings in general. Still, they did not consider hard bounds on the width and height of the drawing and did not consider the contribution of dummy vertices to the width.

3 Preliminaries

As we are concerned with the layering phase of the layout method suggested by Sugiyama et al. [11], we briefly recall the definition of layerings of directed graphs at the beginning of this section. Afterwards, we state our new layering problem definition and discuss how to guarantee the existence of feasible drawings under this model.

Layerings of Directed Graphs. A layering of a digraph \(G=(V,A)\) with vertex set V and arc set A is a function \(\ell : V \rightarrow \mathbb {N}^+\) assigning a layer \(\ell (v)\) to each vertex \(v\in V\). In our context, for a feasible layering, it is necessary that no two adjacent vertices are placed on the same layer, i.e., \(\ell (u) \ne \ell (v)\) for all \((u,v) \in A\). The layering determines the height, the width, the arc lengths, and the number of reversed arcs, which will be defined in the following. The height H of a layering \(\ell \) is the maximum layer used by \(\ell \). The width \(W_k(\ell )\) of a layer k in a layering \(\ell \) is the sum of the number of vertices assigned to layer k and the number of dummy vertices caused by arcs traversing the layer k. More formally, let \({V_k = \{ v\in V \mid \ell (v) = k \}}\) and \(D_k = \{ (u,v) \in A \mid \ell (u)< k \text { and } \ell (v)> k \text { or } \ell (v) < k \text { and } \ell (u) > k \}\). Then \(W_k(\ell ) = | V_k | + | D_k |\) and the width of \(\ell \) is defined as the maximum width of all layers in \(\ell \), i.e., \(W = \max _{1 \le k \le H} W_k(\ell )\). The total arc length len\((\ell )\) is the sum of the arc lengths \(|\ell (u) - \ell (v)|\) of all arcs \((u,v) \in A\) in the layering \(\ell \). An arc \((u,v)\in A\) in a layering \(\ell \) is called a reverse arc if \(\ell (u)>\ell (v)\) and the total number of reversed arcs in \(\ell \) is denoted by rev\((\ell )\). The estimated aspect ratio of a layering with width W and height H is defined as W / H. In contrast, the aspect ratio, considers the width and height of a final layout after all of the Sugiyama phases. So far, we assumed that real as well as dummy vertices have unit width. Nevertheless, each of our MIP models presented in Sect. 4 can easily be extended to deal with varying vertex widths.

Asking the user to specify bounds on both the height H and the width W of a hierarchical drawing a priori can easily lead to infeasible problem settings or require several iterations to fit the parameters to the graph structure. We circumvent these issues in our subsequently defined variation of the problem by requiring only H as an input parameter while making W a subject of optimization. We also discuss how H can be chosen safely.

The Compact Generalized Layering Problem (CGLP). As an extension to the Generalized Layering Problem (GLP) described in [10], we define the Compact Generalized Layering Problem as follows: Given a (not necessarily acyclic) directed graph \(G=(V,A)\) and a maximum layering height H, compute a layering \(\ell \) such that the end-vertices of each arc are assigned to different layers and the following objective function is minimized: the weighted sum of the number of reversed arcs rev\((\ell )\), the total arc length len\((\ell )\), and the width \(W(\ell )\).

Lower Bounds on the Height H of Feasible Layerings. Since, in our generalized setting, the direction of the arcs can be arbitrary, we can think of undirected graphs to determine a lower bound on H. To assign layers to vertices such that no two adjacent vertices are on the same layer is an equivalent problem as to assign colors to vertices such that no two adjacent vertices have the same color. Hence, the minimum number of layers, i.e., height, necessary for a feasible layering of an undirected graph \(G=(V,E)\) is equal to its chromatic number \(\chi (G)\).

Since it is \(\mathcal {NP}\)-hard to compute \(\chi (G)\), we suggest to approximate it. A valid upper bound for \(\chi (G)\) that can be computed in linear time is the maximum vertex degree \(\max _{v \in V} \deg (v)\) of G plus one. This bound is tight if G is the complete graph or an odd cycle, otherwise \(\chi (G) \le \max _{v \in V} \deg (v)\) for any connected graph G. A better approximation can be achieved by using the largest eigenvalue \(\lambda ^*\) of the adjacency matrix of G. Wilf showed that \(\chi (G) \le 1 + \lambda ^*\) [12] and together with the Perron-Frobenius Theorem we have that \(2\frac{|E|}{|V|} \le \lambda ^* \le \max _{v \in V} \deg (v)\). Summing up, we have \(H \ge \chi (G) \le \lambda ^* + 1 \le \max _{v \in V} \deg (v) + 1\).

4 Description of the MIP Models

4.1 A Generalization of the Model by Healy and Nikolov (EXT)

As a reference, we consider a natural extension of the model by Healy and Nikolov [5] that minimizes the total arc length of layered drawings of acyclic digraphs while restricting the height as well as the width and taking dummy vertices into account. In their model, the height H and the width W are fixed input parameters. In our extension for general digraphs \(G=(V,A)\), we only require H as an input, and incorporate the width of the drawing into the optimization process. The model describes an assignment problem (AP) with variables \(x_{v,k}\) to decide whether vertex \(v \in V\) is placed on layer \(1 \le k \le H\) (\(x_{v,k} = 1\)) or not (\(x_{v,k} = 0\)). If an arc \((u,v) \in A\) is reversed, then this is expressed by a variable \(r_{u,v} = 1\), otherwise \(r_{u,v} = 0\). The variables \(z_{uv,k}\) model whether arc (uv) causes a dummy vertex on layer \(2 \le k \le H-1\), which is important to formulate a proper width constraint. To save extra arc length variables, we exploit the fact that the length of an arc is exactly the number of dummy vertices it causes plus one. The full model is:

(1)
$$\begin{aligned}&x_{u,k} + x_{v,k}&\le \;&1&\text {for all } (u,v) \in A, 1 \le k \le H \end{aligned}$$
(2)
$$\begin{aligned}&x_{u,k} - \textstyle \sum \limits _{l=k}^{H} x_{v,l}&\le \;&r_{uv}&\text {for all } (u,v) \in A, 1 \le k \le H \end{aligned}$$
(3)
$$\begin{aligned}&\textstyle \sum \limits _{v \in V} x_{v,k}&\le \;&W&\text {for all } k \in \{1, H\} \end{aligned}$$
(4)
$$\begin{aligned}&\textstyle \sum \limits _{v \in V} x_{v,k} + \textstyle \sum \limits _{{(u,v) \in A}} z_{uv,k}&\le \;&W&\text {for all } 2 \le k \le H-1 \end{aligned}$$
(5)
$$\begin{aligned}&\textstyle \sum \limits _{l < k} x_{v,l} - \textstyle \sum \limits _{l \le k} x_{u,l}&\le \;&z_{uv,k}&\text {for all } (u,v) \in A, 2 \le k \le H-1 \end{aligned}$$
(6)
(7)

The objective function minimizes the weighted sum of the number of reversed arcs, the total arc length, and the width W of the drawing. Equations (1) ensure that exactly one layer is assigned to each \(v \in V\). Inequalities (2) enforce adjacent vertices to be placed on different layers. If an arc (uv) is reversed due to the positions of its end vertices, then inequality (3) makes sure that \(r_{u,v}\) is equal to 1 (otherwise, it will be 0 due to the objective function). The total number of vertices and dummy vertices assigned to one layer must never exceed W which is ensured by (4) and (5). Finally, inequalities (6) and (7) enforce a variable \(z_{uv,k}\) to be 1 if \(\ell (u) < k\) and \(\ell (v) > k\) or vice versa. The integrality of all continuous variables is implied by the integrality of the x-variables due to the constraints and the objective function. Model EXT has \(\mathcal {O}(|V| \cdot H + |A| \cdot H)\) variables and \(\mathcal {O}(|V| + |A| \cdot H)\) constraints.

4.2 Our New Ordering-Based MIP Model (CGL)

The CGL model is based on the observation that the layering problem is a partial ordering problem (POP) in the sense that a vertex u is smaller than v (i.e., \(u<v\)) in the partial order if \(\ell (u) < \ell (v)\).

Following this idea, we introduce, for each \(v \in V\) and for each \(1 \le k \le H\), the variables \(y_{v,k}\) that are equal to 1 if and only if \(\ell (v) < k\). Conceptually, we also have the reverse variables \(y_{k,v}\) (equal to 1 if and only if \(k < \ell (v)\)), but we will see soon that these can be discarded. However, with the reverse variables at hand, it is easy to see that \(\ell (v) = k\) if and only if \(y_{k,v} = y_{v,k} = 0\). In addition, the new model also comprises the variables \(r_{u,v}\) and \(z_{uv,k}\) as already introduced in Sect. 4.1. The interplay between the y- and the r-variables as described in the following will lead to the desired partial ordering of V. The full model is:

(8)
$$\begin{aligned}&y_{H, v}&=\;&0&\text {for all } v \in V \end{aligned}$$
(9)
$$\begin{aligned}&y_{k,v} + y_{v,k+1}&=\;&1&\text {for all } v \in V , 1 \le k \le H-1 \end{aligned}$$
(10)
$$\begin{aligned}&y_{{k+1}, v} - y_{k,v}&\le \;&0&\text {for all } v \in V , 1 \le k \le H-2 \end{aligned}$$
(11)
$$\begin{aligned}&{-y_{u,k}} - y_{k,v} - r_{u,v}&\le \;&{-1}&\text {for all } (u,v) \in A, 1 \le k \le H \end{aligned}$$
(12)
$$\begin{aligned}&{-y_{k,u}} - y_{v,k} + r_{u,v}&\le \;&0&\text {for all } (u,v) \in A, 1 \le k \le H \end{aligned}$$
(13)
$$\begin{aligned}&y_{k,u} + y_{v,k} - z_{uv,k}&\le \;&1&\text {for all } (u,v) \in A, 2 \le k \le H-1 \end{aligned}$$
(14)
$$\begin{aligned}&y_{k,v} + y_{u,k} - z_{uv,k}&\le \;&1&\text {for all } (u,v) \in A, 2 \le k \le H-1 \end{aligned}$$
(15)
$$\begin{aligned}&\textstyle \sum \limits _{{u \in V}} ( 1 - y_{u,k} - y_{k,u} )&\le \;&W&\text {for all } k \in \{1,H\} \end{aligned}$$
(16)
(17)

The switch from an AP to a POP requires a more involved approach to yield consistency of the model. The first four constraints enforce the graph to be embedded into the layers \(1, \dots , H\). Equations (8) and (9) make sure no vertex is assigned a layer smaller than one or larger than H. For each layer \(1 \le k \le H\), each vertex v is either assigned a layer larger than k (in which case \(y_{k,v} = 1\)) or not (in which case \(y_{v,k+1} = 1\)) as is enforced by (10). These equations can be used to eliminate one half of the y-variables (and then be eliminated themselves) as mentioned before. If \(\ell (v) > k + 1\), then this implies \(\ell (v) > k\) as well and this is expressed in the transitivity inequalities (11). It remains to show that arc directions and layer assignments will be consistent and no two adjacent vertices can be on the same layer. This is achieved by inequalities (12) and (13). Suppose that \(r_{u,v} = 0\), i.e., the arc \((u,v) \in A\) shall be a forward arc. Then the inequalities (12) enforce that, for each layer \(1 \le k \le H\), either \(\ell (u) < k\) or \(\ell (v) > k\) (or both). In this case, the inequalities (13) are inactive, but they take the equivalent role in the reversed-arc case where \(r_{u,v} = 1\) and then inequalities (12) are inactive.

As already discussed for the previous model, a dummy vertex on layer k is caused by arc \((u,v) \in A\) if either \(\ell (u) > k\) and \(\ell (v) < k\) (\(y_{k,u} + y_{v,k} - 1 = 1\)), or vice versa (\(y_{k,v} + y_{u,k} - 1 = 1\)). In the first case, inequality (14) will force \(z_{uv,k}\) to be 1, in the second case, inequality (15) will do so. In any other case, the variable will be zero due to the objective function. Finally, inequalities (16) and (17) count the vertices and dummy vertices placed on each layer k and make sure that W is a proper upper bound on the width of the layering. The CGL formulation has \(\mathcal {O}(|V| \cdot H + |A| \cdot H)\) variables and constraints.

4.3 A Min+Max Length Variant Without Dummy Vertices (MML)

We shortly describe a variant of CGL, called MML, that can produce appealing results usually faster when dummy vertices need not be taken into account in terms of the width. As opposed to W, let \(W_r\) be the width of a layering where only the real vertices are counted.

The idea is to remove the dummy vertex variables \(z_{uv,k}\) together with the constraints (14), (15) and to replace inequalities (16) and (17) simply by:

$$\begin{aligned}&\textstyle \sum \limits _{{u \in V}} ( 1 - y_{u,k} - y_{k,u})&\le \;&W_r&\text {for all } 1 \le k \le H \end{aligned}$$

We now need to count arc lengths in an ordinary fashion. The usual way to do this is to introduce length variables \(l_{u,v} \in \mathbb {R}\) and the following two inequalities per arc in order to capture the absolute length depending on the arc direction.

$$\begin{aligned}&\textstyle \sum \limits _{k=1}^{H} (y_{k,v} - y_{k,u})&\le \;&l_{u,v}&\text {for all } (u,v) \in A \end{aligned}$$
(18)
$$\begin{aligned}&\textstyle \sum \limits _{k=1}^{H} (y_{k,u} - y_{k,v})&\le \;&l_{u,v}&\text {for all } (u,v) \in A \end{aligned}$$
(19)

However, for certain use cases, e.g., when feedback should be emphasized, it can be desirable to draw forward arcs as short as possible and maximize the length of the reversed arcs. Therefore, we propose not to introduce the l-variables but to directly incorporate the terms used on the left hand side of inequalities (18) into the objective function, which results in the desired minimization of the backward arcs’ negative lengths. MML’s objective function is:

$$\min \; \big (\omega _{rev} \textstyle \sum \limits _{(u,v) \in A} r_{u,v}\big ) + \big (\omega _{len} \textstyle \sum \limits _{(u,v) \in A} \textstyle \sum \limits _{k=1}^{H} (y_{k,v} - y_{k,u})\big ) + \omega _{wid}\; W_r$$

This model has only \(\mathcal {O}(|V| \cdot H + |A|)\) variables and \(\mathcal {O}(|V| \cdot H + |A| \cdot H)\) constraints.

5 Evaluation

Setup. The experiments were performed single-threadedly on an Intel Core i7-4790, 3.6 GHz, with 32 GB of memory and running Ubuntu Linux 14.04. For solving the MIPs, we used Gurobi 6.5. In our implementation, the CGL model has been reduced in terms of its variables as is indicated in Sect. 4.2. Further, in all the models we enforce at least one vertex to be placed on layer \(k=1\) to eliminate some symmetries. The parameters were set to \({H=\lceil 1.6*\sqrt{|V|} \rceil }\), \(w_{rev} = |E| \cdot H\), \(w_{len} = 1\), and \(w_{wid} = 1\). This choice of H delivered feasible problems for all of our instances and emphasizes our target to have a good aspect ratio and a drawing that adheres to standard forms such as flat screens following the golden ratio. Due to our choice of \(w_{rev}\), arcs are reversed only if this is unavoidable due to the specified height or because they are part of a cycle.

We are interested in answering the following questionsFootnote 2:

  1. (H1)

    Does the POP-oriented CGL model dominate the AP-based EXT model in terms of running times?

  2. (H2)

    Is MML a good alternative concerning the running times and the metrics (arc length, W, and estimated aspect ratio) of the generated layerings?

  3. (H3)

    How do CGL and MML influence the aspect ratio of the final drawings?

We used two benchmark setsFootnote 3. The first set ATTar, the same as used by Rüegg et al. [10], is an extraction of 146 acyclic AT&T graphs with at least 20 vertices having aspect ratio smaller than 0.5 when drawn with the classic Sugiyama approach. These graphs have between 20 and 99 vertices and between 20 and 168 arcs. Their arc to vertex density is about 1.5 on average but varies significantly. Especially, the density of some graphs with about 60 vertices is up to 4.7 which is why the results displayed in our figures and boxplots stand out for these instances.

The second benchmark set Random consists of 340 randomly generated, not necessarily acyclic graphs with 17 to 100 vertices, 30 to 158 arcs, and 1.5 arcs per vertex. We used these graphs in order to analyze our approach also for cyclic sparse digraphs. First, a number of vertices was created. Afterwards, for each vertex, a random number of outgoing arcs (with arbitrary target) is created such that the overall number of arcs is 1.5 times the number of vertices.

Fig. 2.
figure 2

Summary of the results of the ATTar graphs. For each of the four metrics the graphs were binned based on their vertex counts (x axis) and the y axis represents the metric’s value. For each bin the left box represents CGL’s result and the right box MML’s result.

Fig. 3.
figure 3

Summary of the results of the random graphs. For each of the four metrics, the graphs were binned based on their vertex counts (x axis) and the y axis represents the metric’s value. For each bin, the left box represents CGL’s result and the right box MML’s result. To improve presentation, we removed one outlier in (a) with 92 vertices that took CGL 388s of computation time.

(H1): Comparison of CGL and EXT. First, we look at the ATTar instances and model EXT. While small instances with up to 25 vertices can be solved within at most seven seconds, there is already one instance with 29 vertices that cannot be solved within the time limit of 10 minutes of CPU and system time. In total, eleven of 66 instances with \({25< |V| < 50}\) time out, while for the others the running times highly deviate within the full spectrum between a second and about nine minutes. However, none of the 33 instances with more than 50 vertices can be solved within the time limit. The picture for the random instances is similar. The first instance remaining unsolved within the time limit has 37 vertices and those with 50 or more vertices can be solved only sporadically (33 of 201).

With the CGL model, however, we were able to solve all the instances (ATTar and Random) to optimality. The running times are shown in Figs. 2a and 3a. All but ten of the ATTar instances were solved in less than 10 seconds of CPU and system time, and the highest running time observed was 30 seconds. Concerning the random instances, we observed that 314 of the 340 instances were solved within 30 seconds. However, for \(|V|\ge 80\), a higher dispersion of running times could be observed. The largest observed running time was 388 seconds for an instance with 92 vertices. Since both models solve the same problem to optimality, we can conclude that the EXT model is clearly dominated by the CGL model when a state-of-the-art commercial MIP solver is used.

(H2): Alternative MML. In Sect. 4.3 we introduced the model MML that, as opposed to the models EXT and CGL, maximizes the length of reversed arcs and does not regard the contribution of dummy vertices to a layer’s width. Our hope was that MML is much faster than CGL and EXT without sacrificing the quality of the generated layouts too much.

In Figs. 2a and 3a, one can see that the MML model could almost always (except for 14 instances in total) be solved much faster than the CGL model and hence also the EXT model. Especially, with MML all but ten instances of the ATTar benchmark set were solved within three seconds. The boxplots also show that the running times for solving the MML model are more robust for both benchmark sets.

As can be seen in Figs. 2 and 3, the average arc lengths and widths of layerings created by MML increase only moderately when compared to CGL. On average, the increase in the total arc lengths is only about 6% and the increase in the width is about 7% for each of the benchmark sets. The displayed widths of MML also include dummy vertices. Since MML is significantly faster than CGL, we can conclude that it is a good alternative to CGL whenever lower running times are required and long reversed arcs are either desired or negligible.

Fig. 4.
figure 4

Comparison of the aspect ratio of the ATTar instances when laid out with traditional methods [2, 4] (box on the left), CGL (middle), and MML (right). It can be seen that the methods presented here clearly improve the aspect ratio of the final drawing.

(H3): Aspect Ratio. Exemplary drawings of an ATTar instance as resulting from both CGL and MML can be seen in Fig. 1. Whereas the aspect ratio of the original layout of Fig. 1 is about 0.14, the ratio of the new layouts is about 0.6. This improvement of the aspect ratio has been achieved by reversing three arcs (now pointing upwards). The created drawings are significantly more compact. In Fig. 1c, generated with the MML model, the reversed arcs can be found easily, since the model tries to maximize their length.

An average of about 3.13 arcs needed to be reversed on the ATTar graphs and 3.82 on the random graphs to adhere to the selected H. Also the maximum number of reversed arcs in both benchmark sets is similar; it is 8 for the ATTar instances and 9 for the random instances. The reversed arcs changed the estimated aspect ratio of the ATTar graphs from an average of 0.51 to an average of 1.36, see Fig. 4a. As mentioned earlier, the estimated aspect ratio must not necessarily coincide with the final drawing’s aspect ratio. To further inspect this, we produced final drawings using the same strategies of the Sugiyama approach as discussed in [10]. In Fig. 4b, one can see that the average aspect ratio improves from 0.22 to about 0.61 for CGL and to about 0.63 for MML. From this we conclude that both models lead to compact layouts with improved aspect ratio.

6 Conclusion

This paper introduces the CGLP, which can be seen as an extension of the DAG Layering Problem suggested by Healy and Nikolov [5, 6], and the GLP suggested by Rüegg et al. [10]. The CGLP gives more control over the desired layering by integrating the reversal of arcs and taking the contribution of dummy vertices to a layering’s width into account.

We suggest two MIP models for CGLP, one of which is based on partial orderings and show that the model can be solved to optimality within a short computation time for typical instances with up to 100 vertices. In addition, we suggest an alternative MIP model (MML) for a slightly different problem which can be solved even faster while the widths and arc lengths of the generated layerings do not increase significantly. Our experiments have shown that using the CGLP, indeed, the aspect ratio of the generated final drawings can be influenced.