Root demotion: eﬃcient post-processing of layered graphs to reduce dummy vertices for hierarchical graph drawing

One of the most popular hierarchical graph drawing frameworks - the Sugiyama, Tagawa


Introduction
Graphs are often the data type of choice for visualizing complex relationships.The automatic drawing of graphs, however, is a non-trivial matter, and many graph drawing sub-problems are classified as NP-hard [7].
Hierarchical Graph Drawing (HGD), a popular style to present directed graphs which represent hierarchies or processes (e.g.phylogeny or gene interaction networks), places the vertices of the graph in parallel layers with the aim that the arcs of the graph are oriented in the same direction.The methods for HGD were formalized in 1981 by Sugiyama, Tagawa, and Toda in what is now referred to as the STT framework [11,7,1,3].The STT framework, in general, can be describe by the following steps: 1. convert the input graph to a directed acyclic graph (DAG) 2. produce a layering by partitioning the vertices of the DAG into layers 3. reduce the number of edge crossings by reordering the vertices in the layers of the layering

assign vertical and horizontal coordinates to the vertices
As the layering produced in step two of the STT framework is used in the subsequent steps, it affects the run time for the remainder of the STT framework.In addition, the layering has an influence on the aesthetics of the resultant drawing (e.g. by influencing the height and width of the graph).
The layering's effect on run time can be easily identified in the step of edge crossing minimization, one of the many NP-hard sub-problems.Many of the edge crossing minimization approaches aim to reduce edge crossings locally (e.g. between two adjacent layers at a time) to approximate the optimal solution [11,7,2,12].Prior to local edge crossing minimization approaches, the STT framework introduces placeholders, known as dummy vertices, to account for the placement of long edges -edges which cross through the local layers undergoing reordering but may not start or end there.
Since dummy vertices increase the size of the graph, naturally the run time for drawing these graphs also increases; the increased run time is a deterrent for using HGD on large graphs.Thus, although necessary, it is ideal to find a layering which requires the minimum number of dummy vertices (see, e.g. Figure 1).

Related work
Given the effects of dummy vertices on HGD, several layering algorithms [5,6] have been developed which produce the minimum number of dummy vertices, such as the Network-Simplex Layering Algorithm by Gansner et al. that utilizes integer linear programming (ILP) which runs, putatively, in polynomial time [7,5,6].Despite these minimal-dummy vertex producing algorithms' existence, the Longest-Path algorithm for layering (Longest-Path layering) remains a widely popular layering technique given: 1.) its simplicity and 2.) its linear time complexity [9,7,10].Therefore it may be competitive to post-process the layering produced by the Longest-Path algorithm with the goal of achieving the minimum (or an approximation thereof) number of dummy vertices.The post-processing approach of handling dummy vertices manifested in 2006 when Nikolov and Tarassov unveiled Promote Layering [10].Promote Layering aimed to reduce the number of dummy vertices by traversing against the flow of arcs, moving the current vertex up a layer -promotion -and comparing whether or not such a move reduced the number of dummy vertices needed; however, this algorithm could increase the number of layers in the layering [10].While performing relatively well for small (≤ 100 vertices) graphs, Nikolov and Tarassov found that Promote Layering was noncompetitive on simulated graphs of larger size leading to a restriction on their repeat-until statement [10].Naturally a linear time approximation of a layout with the minimum number of dummy vertices would be ideal.Here we present Root Demotion as an easy to implement, linear post-processing algorithm, which improves the reduction of the number of dummy vertices required compared to other post-processing reduction algorithms.

Notation
Let G(V, A) be the DAG with vertex set V = {v 1 , v 2 , . . ., v |V | } and arc set A = {a 1 , a 2 , . . ., a |A| }, where an arc a = (u, v) : u, v ∈ V is defined as an ordered set representing the directed edge from u to v. Given arc (u, v) we say that the source of the arc, u, is an immediate predecessor of v and the target of the arc, v, is an immediate successor of u.Let N + (v) = {s : (v, s) ∈ A} be the set of all immediate successors of v. Similarly let the set of all immediate predecessors of v be defined as where i is the index of the layer, L i , in which v resides.Then the layered DAG, G(V, A, L ), allows the span of an arc a = (u, v) to be defined as span(a) = L (v) − L (u); a layered DAG is proper should span(a) = 1 ∀a ∈ A (hereafter referred to as proper-layered graph).
Most graph drawing algorithms following the STT framework, with the notable exception of Eiglsperger, Siebenhaller and Kaufmann [4], require the transformation of the arc set of an improper-layered DAG into a proper-layered DAG; such a transformation of an improper arc, T , often involves the injection of dummy vertices into arcs with span greater than 1.For example, if a = (u, v) and span(a) > 1 then Consequently, the set of all dummy nodes, D, must be introduced, where

Approach
The Longest-Path algorithm produces a layering with minimum height in linear time, but it forgoes optimal performance in regards to minimizing the number of dummy vertices, edge density and drawing area [7,10].Thus, Root Demotion aims to be a linear time algorithm which reduces the number of dummy vertices required by the Longest-Path algorithm by changing the layers to which the vertices are assigned if said layer is non-optimal.A vertex, v, is in a nonoptimal layer if for every arc incident to v the span of the arc is greater than one i.e. span(a) > 1 ∀a s.t.v ∈ a ∧ a ∈ A.
The Longest-Path algorithm layers the vertices such that a successor, s, of a given vertex, v, will be a lower layer than the source vertex i.e.L (s) > L (v).Thus if the layering is traversed layer by layer, for example from the lowest layer (L h ) to highest layer (L 1 ), then the only arcs which need to be considered are those against the flow of traversal (in this case the arcs (v, s) ∈ A∀s ∈ V ), as the predecessors of v will be handled when their layer is visited.Using such a onesided approach makes it easy to improve the layer of a vertex in a non-optimal layer: simply move the vertex down (demote) to the layer above its nearest successor's layer (L (v) = L (s) − 1).Traversing layer by layer will likely result in vertices of higher layers being "dragged" down the layering (which can include roots of the DAG if there is more than one).
When moving vertices to other layers, it is important to ensure these changes do not introduce intra-layer edges (layering-preservation), as noted by Nikolov JGAA, 21(6) 1027-1038 (2017) 1031 and Tarassov (2006), as many HGD algorithms assume these edges will not be present in the layering [10].An intra-layer edge could be introduced if a vertex is moved into the same layer as one of its predecessors or successors.Since Root Demotion ensures that when a vertex is moved the vertex is moved exclusively to be one layer away from its nearest successor, Root Demotion is layering-preserving.

Algorithm
Root Demotion visits each vertex exactly once moving layer to layer from L h to L 1 ; when a vertex, v, is found such that all of its successors are more than one layer away, span(v, s) > 1 ∀ v, s ∈ A, then v is "demoted" to the layer above its nearest successor, i.e.L (v) = L (v) + min({span(v, s) ∀(v, s) ∈ A}) − 1. Root Demotion is remarkably simple to implement as seen in algorithm 1.
To calculate the time complexity of Root Demotion, consider Root Demotion's constituent parts: 1. visit each vertex exactly once 2. check the layer for each successor of the current vertex while keeping the minimum 3. if required reassign the current vertex to another layer as described above It is clear that 1) runs in O(|V |).As the layer of every successor for every vertex will be recalled, this enumerates the number of arcs in the graph.Keeping track of the minimum layer of the successor as one recalls the current vertex's successors' layers, 2) runs in O(|A|).The reassignment of layers for a vertex, should it occur, runs in O(1).If one uses a list of lists for the layering, L , the removal of v from one sub-list and appending v to another can occur in O(2), by leveraging the traversal scheme.Thus the time complexity of Root Demotion is O(|V | + |A|).As for space complexity, Root Demotion requires two variables, a stack "vertices" of |V | and an integer "highest layer" (see alg 1).

Comparison
The core distinctions between the Promote Layering technique and Root Demotion are as follows: )) [8].
layer reassignment method Root Demotion can move a vertex down multiple layers at a time if the minimum number of layers between that vertex and any of its successors is more than one, whereas Promote Layering moves each called node up one layer and reverts if the heuristic is not met [10].
heuristic Root Demotion requires no heuristic regarding whether or not to change a vertex's layer, whereas Promote Layering uses dummyDiff as an indicator for such a decision.
These differences result in an algorithm that -in linear time -does not create new layers, can move a vertex multiple layers at a time, and requires no memory of the previous layering.Root Demotion does have a trade off, however.Although Root Demotion will move a vertex if there is a valid re-positioning, it may not find the optimal way to reduce dummy nodes.This stands in contrast to Promote Layering, which for some graphs can further reduce the number of dummy nodes needed by adding new layers.A comparison between the two post-processing techniques is shown in Figure 2.

Experimental Results
For convenience, let -for the remainder of this section -the last step in layering process refer inclusively of the entire layering process, e.g.Root Demotion refers to the layering produced by the Longest-Path algorithm post-processed with Root Demotion.
To benchmark Root Demotion, we tallied the number of dummy vertices in layered graphs following the Longest-Path algorithm with no post-processing, Promote Layering, and Root Demotion.In addition we recorded the run time.We used the 1277 DAGs from the AT&T data-set as well as 11, 534 graphs in the ROME data-set; both data-sets have graphs with vertex-sets having cardinality between [10,110] vertices.Graphs were binned into representative sizes [10, 20, . . ., 100]; consequently 5 graphs with more than 100 vertices were excluded to prevent a poorly represented 110 vertex bin.
Following Nikolov and Tarassov (2006) we also use the binned medians of the normalized dummy vertices [10].The binned medians of the normalized dummy vertices show that Root Demotion consistently reduces the number of dummy vertices produced by the Longest-Path algorithm compared to Promote Layering (see, e.g. Figure 3).Root Demotion results in a binned median difference of −13 and −18 dummy vertices compared to Promote Layering and Longest-Path algorithm respectively (see, e.g. Figure 4).In the most extreme case, Root Demotion used −184 dummy vertices less than Promote Layering.In addition, Root Demotion consistently requires less run time to reduce the number of dummy vertices compared to Promote Layering (see, e.g. Figure 5).
Graphs rendered with Root Demotion require less run time for the remaining STT framework (e.g.crossing minimization, coordinate assignment) compared to both Longest-Path algorithm and Promote Layering (figure 6).For all but small graphs, the reduced run time of the STT framework makes up for Root Demotion's own run time.Peculiarly, Root Demotion used −.46307 layers less than Promote Layering.In the most extreme case, Promote Layering induced a +12 layer discrepancy (data not shown).Collectively, Root Demotion requires less time to further reduce the number of dummy vertices compared to Promote Layering resulting in a shorter run time for the STT framework.
In conclusion Root Demotion out performs Promote Layering regarding the number of dummy vertices removed and run time as a post-processing step for the Longest-Path algorithm.We find Root Demotion to be an overall simple solution with robust performance.

Figure 1 :
Figure 1: Two alternative layerings of a DAG rendered hierarchically.Long edges have been segmented by introducing dummy vertices, thereby increasing the size of the DAG.By changing the layering of the vertices the number of dummy vertices needed can alter.The layering in (a) requires three dummy vertices, while the layering in (b) requires none.Dummy vertices are represented by purple squares.

complexity
Root Demotion has a linear complexity, O(|V | + |A|), whereas, at worst, Promote Layering has a cubic complexity, O(|D|×|V |×(|A|+|V |)), where the best known upper bound on the number of dummy nodes in a layered DAG is O(min(|V | 3 , |A| 2 (a) A layered by Longest-Path algorithm and post-processed with Promote Layering.(b) A DAG layered by Longest-Path algorithm and post-processed with Root Demotion

Figure 2 :
Figure 2: Example of post-processing the layering of a DAG to reduce the number of dummy vertices.Root Demotion (b) requires 8 dummy vertices, Promote Layering requires 19 and had no improvement Longest-Path algorithm without postprocessing.

Figure 5 :
Figure 5: Median of binned run time of Root Demotion, Promote Layering, and Longest-Path algorithm (inclusive i.e.Longest-Path algorithm + postprocessing).Root Demotion is consistently faster than Promote Layering as a post-processing step.

Figure 6 :
Figure 6: Median of Binned run duration of the STT framework following either Longest-Path algorithm, Promote Layering or Root Demotion.