Journal of Graph Algorithms and Applications Global K-level Crossing Reduction

Directed graphs are commonly drawn by a four phase framework introduced by Sugiyama et al. in 1981. The vertices are placed on parallel horizontal levels. The edge routing between consecutive levels is computed by solving one-sided 2-level crossing minimization problems, which are repeated in up and down sweeps over all levels. Crossing minimization problems are generally N P-hard. We introduce a global crossing reduction, which at any particular time considers all crossings between all levels. Our approach is based on the sifting technique. It yields an improvement of 5 – 10% in the number of crossings over the level-by-level one-sided 2-level crossing reduction heuristics. In addition, it avoids type 2 conflicts which are crossings between edges whose endpoints are dummy vertices. This helps straightening long edges spanning many levels. Finally, the global crossing reduction approach can directly be extended to cyclic, radial, and clustered level graphs achieving similar improvements. The running time is quadratic in the size of the input graph, whereas the common level-by-level approaches are faster but operate on larger graphs with many dummy vertices for long edges.


Introduction
The four phase framework introduced by Sugiyama et al. [43] is the standard algorithm for drawing directed graphs.It displays them in a hierarchical manner and operates in four phases: cycle removal, leveling, crossing reduction, and coordinate assignment.First, it reverses appropriate edges to eliminate cycles.Then, it assigns vertices to levels, which are their y-coordinates, and introduces dummy vertices splitting long edges at their crossings with spanned levels.This results in a proper k-level graph.In the third phase the vertices are permuted within the levels to reduce edge crossings.Finally, the x-coordinates are computed such that all vertices have integral coordinates and the drawing meets some aesthetic criteria such as few bends per edge.Typical applications for such drawings are schedules, UML diagrams, and flow charts, where temporal or causal dependencies are modeled by directed edges and are expressed by a left to right or a downward direction, see [14,31,43].
In this paper we focus on the crossing reduction phase, where the vertices on each level are rearranged to minimize the total number of crossings.The common solution to this N P-hard k-level crossing minimization problem [25] is a reduction to the one-sided 2-level crossing minimization problem, which is solved repeatedly in several up and down sweeps [31,43].In a down sweep the vertices V i−1 in the upper level are fixed and the vertices V i in the lower level are reordered reducing the local number of edge crossings between the two levels.In an up sweep the roles of the levels are switched.The one-sided 2-level crossing minimization problem is N P-hard [19], even for forests of 4-stars [36].However, there are many heuristics for this problem [31].Small instances can be solved exactly by an ILP approach [30].There are no reasonable approximations for the k-level crossing minimization problem.The ratios from the one-sided 2-level crossing minimization problem [19,37] do not translate to the general problem.
An important feature of crossing reduction algorithms is the absence of type 2 conflicts, which are crossings of two edges between dummy vertices.Among others, our favored fourth phase algorithm of Brandes and Köpf [10] assumes the absence of type 2 conflicts.It aligns long edges vertically and so meets an important aesthetic criterion [31] for nice hierarchical drawings with at most two bends per edge.
The barycenter and the median heuristic [31] are two common 2-level crossing reductions.They place each vertex v ∈ V i at the barycenter or median position of its predecessors in V i−1 .Then, V i is sorted by these values.So the edges shall be short and induce few crossings.These techniques are simple, fast, and avoid type 2 conflicts, but they often leave too many crossings.
In 2-level algorithms the number of crossings between levels V i and V i+1 and thus the total number of crossings can increase while permuting V i for the 2-level crossing reduction between V i−1 and V i .So, such heuristics push the crossings downwards or upwards until they are resolved at the extreme levels.An immediate extension is the centered 3-level crossing reduction.Here, V i is permuted while keeping the orders of V i−1 and V i+1 fixed and considering the crossings above and below level i.However, this introduces type 2 conflicts.All these approaches suffer from a general problem: They have a local view to the crossing minimization problem.So they tend to get stuck in a local optimum.Bastert and Matuszewski claim [31] that the results of a level-by-level sweep are far from optimum."One can expect better results by considering all levels simultaneously, but k-level crossing minimization is a very hard problem" [31, page 102].After empirical tests of several one-sided 2-level approaches Stallmann et al. [42, page 32] drew the conclusion that "the most pressing issue from a practical perspective is a generalization to k > 2 levels".Our approach addresses this gap.Fig. 1 shows an example, where even an optimal one-sided 2-level crossing reduction gets stuck in a local minimum.In the left component of Fig. 1(a) an optimal top-down sweep swaps vertices 8 and 9, which reduces the number of crossings by two.However, the subsequent bottom-up sweep will undo this change.Since the right component is symmetric, the graph has 12 crossings independently of the direction of the final sweep.Our algorithm solves this example with the optimal solution with 10 crossings as shown in Fig. 1

(b).
Tutte's algorithm [18] can be seen as a first approach with a global view, but it does not address crossings directly.Its quality concerning the number of crossings is open, as Eades and Sugiyama [18] state in Problem 8. Here, the positions of the vertices on the extreme levels are fixed in any order.For the vertices in the other levels the x-coordinate is chosen as the weighted average of the x-positions of all its neighbors.This is modeled by a sparse system of linear equations.
Sifting is a modification of sorting by insertion and it has been used successfully for vertex minimization in ordered binary decision diagrams [40].Later it has been adapted to the one-sided 2-level crossing reduction problem [34].The idea is to keep track of the number of crossings while in a sifting step a vertex v ∈ V i is moved along a fixed order of the vertices in V i .Finally, v is placed at its locally best position.The method is an extension of the greedy-switch heuristic [17], where v is swapped iteratively with its current successor.We call a single swap a sifting swap and the execution of a sifting step for every vertex in V i a sifting round.In general, sifting leaves fewer crossings than the simple one-sided 2-level heuristics at the expense of a higher running time and potential type 2 conflicts [31].
Matuszewski et al. [34] have extended sifting towards a more global view, which we call ordered k-level sifting to avoid confusion.There, the vertices are sorted by their degree and are first sifted in increasing order and then in decreasing order.For swapping two consecutive vertices v and w their incident edges to and from neighbors on both adjacent levels are taken into account.The heuristic does not sweep level-by-level but is still limited to a local view, since long edges are not treated as a whole.Our centered 3-level sifting does the same with the vertices ordered level-by-level.Both algorithms yield similar results.Jünger et al. [29] have developed an exact ILP approach for the N P-hard klevel crossing minimization, which can be used in practice for small graphs.Moreover, metaheuristics have been proposed in the literature, such as genetic algorithms [32,45], tabu search [33], or windows optimization [22].These general (stochastic) global search approaches usually compute good solutions with few crossings at the expense of high running times.
In this paper we propose a new and global crossing reduction technique.The algorithm yields better results than the common heuristics.It is directly extendable to more general crossing reduction problems, avoids type 2 conflicts, and runs in quadratic time in the size of the graph.This distinguishes our approach from most 2-level approaches which extensively use dummy vertices, whose number is up to O(k • |E|) ⊆ O(|V | 3 ).Note that the edge bundling technique of Eiglsperger et al. [21] groups dummy vertices horizontally in each level.This improves the running time of the sweeping barycenter and median heuristics to be independent of the number of dummy vertices.However, their approach cannot be used for more advanced heuristics like sifting.
Recently, Chimani et al. [11,12] presented an advanced approach based on upward planarization which combines the leveling and the crossing reduction phases of the hierarchical framework.Generally, from an algorithm and software engineering perspective the subdivision of a complicated problem into disjoint phases as done in the hierarchical framework makes sense.However, for obtaining global optima the phases cannot be treated independently, as is done traditionally and also in this paper.For example, the number of crossings clearly depends on the leveling.For a competitive extension of global sifting which performs leveling and crossing reduction simultaneously see [7].
The remainder of the paper is organized as follows: After introducing some notation and previous results in the next section, we present our new crossing reduction approach and analyze its complexity in Sect.3.Then, in Sect.4, we show benchmarks which empirically compare our algorithm with established strategies.Afterwards, we present some applications of the block concept on related crossing optimization and reduction methods in Sect. 5. Finally, we summarize the results and discuss some open problems in Sect.6.

Preliminaries
We suppose that a directed graph without self-loops has passed the cycle removal and leveling phases of the four phase framework.The outcome is a k-level graph G = (V, E, φ), where φ : V → {1, 2, . . ., k} is a surjective level assignment of the vertices with φ(u) < φ(v) for each edge (u, v) ∈ E. For an edge e = (u, v) ∈ E we define its length as span(e) := φ(v) − φ(u).An edge e is short if span(e) = 1 and long otherwise.A graph is proper if all edges are short.Each level graph can be made proper by adding span(e)−1 dummy vertices for each edge e which split e in span(e) many short edges.Let G = (V , E , φ ) denote the proper version of G.As in [10] short edges are called segments of e.The first and the last segments of an edge are the outer segments and the others the inner segments.Inner segments connect two dummy vertices.
Consider the proper level graph G .For a vertex v we denote the set of neighbors from incoming and outgoing segments by .In an ordered level graph two segments are in conflict if they cross or share a vertex.Conflicts are of type 0, 1, or 2 if they are induced by 0, 1, or 2 inner segments, respectively.
Next, we define blocks, which prevent dealing with dummy vertices.Thus, the running time of our algorithm is measured in the size of the input graph and is independent of the number of dummy vertices.A block is a single vertex of V or a maximum connected subgraph of dummy vertices, i. e., the inner segments of a long edge.The blocks represent the vertices of a graph related to G , where the edges are the outer segments.We will always denote (dummy) vertices by lower case letters and blocks by upper case letters.For a block A define x = upper(A) (y = lower(A)) to be the unique vertex x in A (y in A) with no incoming (outgoing) segments in A. x and y always exist but may coincide.
Let N − (A) := N − (upper(A)), N + (A) := N + (lower(A)), deg(A) := |N − (A)| +|N + (A)|, and let levels(A) be the set of level numbers which contain (dummy) vertices of A. With block(v) we denote the block of the vertex v ∈ V .Let B be an arbitrarily ordered list of all blocks and let π : B → {0, . . ., |B| − 1} assign each block its current position in this order.We use the binary relation ≺ with A ≺ B ⇔ π(A) < π(B) for comparing blocks A, B ∈ B according to their positions π.

One-Sided 2-Level Sifting
In a sifting step the locally best position for a vertex is sought.Therefore, all positions in its level are tested sequentially, where the cost criterion is the number of crossings.For its computation we adapt the idea of Baur and Brandes [8], which was introduced for circular crossing reduction.
Consider a sifting step for a 2-level graph To determine a locally optimal position of a vertex v ∈ V 2 it is sufficient to record the change in the number of crossings while swapping v with its current consecutive successor w ∈ V 2 .For this, only edges incident to v or w must be considered.After a swap exactly those pairs of these edges cross which did not cross before.All other crossings remain unchanged.Let χ(π 2 ) be the number of crossings of an order (π 1 , π 2 ) of G and χ π2 (e, f ) ∈ {0, 1} be the number of crossings between two edges e, f ∈ E.Then, we obtain Lemma 1 by a direct adaption from [8], which formalizes the change in the number of crossings per swap.At the end of one step v is placed where the intermediary crossing counts reached their minimum.
and let (π 1 , π 2 ) be the order with their positions swapped, then

Global Sifting
A major drawback of the established crossing reduction algorithms is their local view.We present a new approach using ideas from [10] and [21], which avoids type 2 conflicts.Eiglsperger et al. [21] have used a data structure similar to our blocks and avoid type 2 conflicts.However, for crossing reduction they proceed level-by-level in the traditional fashion.This improves only the running time but not the quality of the result.We treat all dummy vertices of an edge and each original vertex as a block and find the locally best position for the whole block in one sifting step.This eliminates a problem of 2-level approaches which lack this global view on crossings of long edges.In the initialization the list of blocks B is sorted arbitrarily and each block A receives its position π(A) in B (line 1 in Algorithm 1).At any time during the execution of the algorithm we interpret π(A) as an x-coordinate of each vertex v in the block A and φ(v) as its y-coordinate.This results in a drawing respecting the current order of B. All vertices of a block get the same x-coordinate.Hence, the order is type 2 conflict free.These are important properties of Algorithm 1.
The main part of the algorithm is the sifting step (line 4).There, all positions for a block A are tested and A is moved to the position with the fewest crossings.This is done for each block A ∈ B (line 3) and repeated a certain number of times (line 2).Alternatively, one may repeat until the improvement is below a given threshold.Our experiments have shown that ten rounds suffice to reach such a situation.Finally, each vertex is set to the position of its block (line 5), the vertices in each level are sorted according to these positions (line 6).Finally, the graph is returned (line 7).
6 sort vertices in each level according to π 7 return G

Building the Block List
The graph is partitioned into blocks.Each block A gets an arbitrary but unique position π(A) in the block list B. As an example consider Fig. 2(a).The input graph with 7 vertices has 6 dummy vertices, which are drawn as black circles.
The dummy vertices are combined into 3 blocks and each original vertex forms its own block.The 10 resulting blocks are shown in Fig. 2(b) with an arbitrary order π.
If a given order (without type 2 conflicts) shall only be improved by global sifting in a postprocessing step, a straightforward initialization strategy is to topologically sort the blocks according to the order in the levels from left to right in O(|E |).Our experiments have shown that a good initial order of the blocks leads to better results.However, these can also be achieved by one or two additional sifting rounds.

Initialization of a Sifting Step
To improve the performance of one sifting step [8] it is necessary to keep the adjacency lists N − (A) and N + (A) of each block A ∈ B sorted according to ascending positions of the neighboring blocks in B. We store them in arrays for random access.Additionally, we store two index arrays I −  (a) A level graph with ten blocks  ) and their positions are only known after the second traversal of a segment s.Thus, we cache the first array position j as an attribute p of s.Benchmarks [28] have shown that there is a considerable speed-up if only those adjacencies are updated that are disarranged after a sifting step instead of completely sorting all adjacency lists.The theoretical running time is not affected by this improvement, however.

Sifting Step
In a sifting step by Algorithm 3 all positions p in B are tested for a block A ∈ B (lines 5-8) and, then, A is moved to the position p * which has caused the least number of crossings.Note that it is not necessary to count the crossings for each position of A. As in [8] and in contrast to other sifting algorithms, which always maintain the absolute number of crossings, we treat the number of crossings of JGAA, 15(5) 631-659 (2011) 639 // new order B with A put to front 2 SORT-ADJACENCIES(G , B ) 3 χ ← 0; χ * ← 0 // current and best number of crossings 4 p * ← 0 // best block position

Sifting Swap
The sifting swap computes the change in the number of crossings when a block A is swapped with its right successor B in B. In contrast to one-sided crossing reduction, our global approach takes the whole neighborhood of both blocks into account when it computes the change in the number of crossings.Lemma 2 states which segments are involved.
Lemma 2 Let B be the block list in the current order.Let B ∈ B be the successor of A ∈ B. If swapping A and B changes the crossings between two segments, then one of them is an incident outer segment of A or B and the other segment is an incident outer segment of the same kind (incoming or outgoing) or an inner segment of the other block.
Proof: Note that only segments between the same levels can cross.As no type 2 conflicts occur, at least one of the segments of a crossing has to be an outer segment.Let  The following fact is easily seen and the resulting changes in the number of crossings are obvious.
Fact 1 Let B be the block list in the current order.Let B ∈ B be the successor of A ∈ B. Let i and j be the two levels framing the incoming outer segments of A (the other three cases are symmetric).If there is a segment (u, v) between i and j which is either an incoming outer segment of B or an inner segment of B, then the incoming segments of A starting at a block left of block(u) cross (u, v) only after the swap of A and B, the segments starting at block(u) never cross (u, v), and the segments starting right of block(u) cross (u, v) only before the swap.There are no other changes among the crossings due to Lemma 2.
For an illustration consider Fig. 3.The incoming segment (u, v) of block B starts at block C. Thus, all incoming segments of A starting at a block left of C, namely (1, 2) and (6, 2), cross (u, v) only after the swap of A and B. The segment connecting blocks C and A, i. e., (u, 2), never crosses (u, v) and the incoming segments of A starting right of block C, namely (7, 2), cross (u, v) only before the swap.The outgoing segment (2, 3) of A crosses the inner segment (v, 8) of B only after the swap.
Algorithm 4 shows the details of a sifting swap.First, the levels at which (significant) swaps occur and the direction of the segments changing their crossings are found (lines 2-6).For each entry (l, d) of the set L the two vertices a and b of A and B on level l are retrieved.When swapping A and B only a and b are swapped in their level and no order changes in the level of their neighbors N d (a) and N d (b).Thus, the computation of the change in the number of crossings can be done as in [8] and is described in Algorithm 5: The neighbors are traversed from left to right.If a neighbor of a is found (lines 5 and 6), its segment will cross all remaining s − j incident segments of b after the swap.If a neighbor of b is found (lines 7 and 8), its segment has crossed all remaining r − i incident segments of a before the swap.Common neighbors present both cases at the same time (line 9).

Experimental Results
For the sake of completeness we have extended the barycenter and median crossing reduction strategies to blocks as well.We iteratively take the π-positions of the blocks in B and compute for each block the barycenter or median of its adjacent blocks, respectively.Then, we sort B according to these values.The following benchmarks show that both are fast, however, they are not competitive with global sifting in the number of obtained crossings.One round of global barycenter or global median has a time complexity of O(|E| log |E|) or of O(|E|), respectively.
We have compared the practical performance of four level-by-level and four global crossing reduction algorithms implemented in our graph tool Gravisto [5]: iterative one-sided 2-level barycenter (B), median (M), sifting (S), iterative centered 3-level sifting (3S), global barycenter (GB), global median (GM), global sifting (GS), and ordered k-level sifting (OS).For each of the level-by-level algorithms we run ten top-down and bottom-up sweeps and for each of the global heuristics we performed ten rounds.We have tested 910 random graphs.For each graph size from 1,000 to 10,000 vertices in steps of 100 we have generated ten arbitrary graphs with an aspect ratio of the golden rectangle 1+ √ 5 2 , i. e., the maximum number of (dummy) vertices per level is about 1.6 times the number of levels.The density of the proper edges is twice the number of vertices including a proportion of 75% dummy vertices.Hence, there are five times as many (long) edges as non-dummy vertices.To aggregate random initializations we applied each algorithm twice to every concrete graph instance.All benchmarks were run on a 2.83 GHz XEON workstation under Solaris and the Java 6.0 platform of Oracle Corp.We compare the different running times in Fig. 4.Although global sifting is the slowest among them, it is feasible in practice.Clearly, its performance on real-world graphs is not as dire as the worst case O(|E| 2 ) time complexity indicates at first glance.
Fig. 5 shows the quality of the heuristics in the number of crossings of the resulting embeddings.The results of global sifting are about 5 to 10% better than the ones of the established algorithms.In addition, type 2 conflicts are avoided, which are quite high for the sifting algorithms as Fig. 6 indicates, and which have an impact on the edge routing in the final phase of the four phase framework.Both benefits justify the higher running time.
Fig. 7 depicts that the traditional approaches have a constant running time on graphs with the same size but ascending proportions of dummy vertices.For global sifting the running times become better with more dummy vertices.Then, there are more long edges whose inner segments are treated as a whole.This reflects that the time complexity O(|E| 2 ) depends only on the number of edges |E| and not on the number of segments |E | of the proper graph.
In Fig. 8 we compare the results of the heuristics with the exact solution.For a practically solvable ILP of the exact algorithm which will be described in Sect.5.1, the graphs must be small with |V | ≤ 35.Although permitted, the optimum solutions do not contain any type 2 conflicts.The graphs seem to be simply too small for that.Since we have a proportion of 30% dummy vertices, the graphs are rather sparse.This may be the reason why barycenter here outperforms two sifting algorithms.Global sifting is in parts 25% closer to the optimum as all other tested methods.Fig. 5 supports the statement in [31] that in general sifting is qualitatively the better choice.
Fig. 9 presents the influence of the number of sweeps or rounds in the number of crossings.Again, global barycenter and median perform very poorly.Interestingly, the simple barycenter, median, and sifting heuristics seem to need only one sweep.The remaining heuristics (OS, 3S, GS) improve their results We additionally have tested the algorithms on the widely used Rome graphs [16] library in Fig. 10.The set contains 11528 instances with 10-100 vertices and 9-158 edges.Although these graphs are originally undirected, we interpret them as directed by artificially directing the edges according to the vertex order given in the input files, see, e. g., [12,20].Furthermore, we have tested the AT&T graphs [38], see Fig. 11.This benchmark set consists of 1155 directed acyclic graphs with 10-96 vertices and 10-99 edges collected by Stephen North.Since these graphs are rather inhomogeneous in the number of vertices, we follow [15] and group the graphs by the number of edges to improve the readability of the diagram.For both benchmarks we have done the leveling with the Coffman/Graham algorithm [13], where we allowed a maximum number of |V | non-dummy vertices on the levels.Since the graphs are rather sparse and contain many chains, we have marked all vertices with degree 2 as dummy vertices in a preprocessing step.This helps to build reasonable blocks for global sifting.In both benchmarks global sifting gives the best results of all algorithms guaranteeing no type 2 conflicts.
In a nutshell, classic sifting is fast, leaves few type 2 conflicts, but many crossings.Centered 3-level sifting is fast, leaves few crossings, but many type 2 conflicts.Global sifting leaves even fewer crossings without any type 2 conflicts, but has the highest running time which is still feasible in practice.The measurements reflect that the running time of global sifting is independent of the number of dummy vertices.This parallels the edge bundling technique in [21].Global sifting is a good choice for the trade-off between time and quality.In several related algorithms blocks for long edges can be used to improve their performance and the quality of the resulting drawings by avoiding type 2 conflicts.

Optimal Crossing Reduction Using an ILP
Jünger et al. [29] introduced an ILP formulation for the exact crossing minimization problem of k-level graphs.There, type 2 conflicts can be excluded by adding additional constraints, which after a simplification result in a similar ILP as in our approach.However, using variables for pairs of overlapping blocks with common levels gives a more direct formulation which naturally excludes type 2 conflicts.It uses fewer variables by avoiding the use of dummy vertices for computing a solution of the ILP.However, for forming the equations the graph must be proper.
Our ILP is built as follows: We start with an arbitrary but fixed order of the list of blocks B. For any two blocks A and B with π(A) < π(B) and a common level we define a boolean variable x AB .The value x AB = 1 denotes that A is left of B and x AB = 0 that B is left of A in the final embedding.For each triple of blocks A, B, and C with π(A) < π(B) < π(C) with at least one common level, i. e., levels(A) ∩ levels(B) ∩ levels(C) = ∅, we add the condition 0 ≤ x AB + x BC − x AC ≤ 1 to exclude cyclic dependencies within a level. Let subject to According to our experiments, this approach is usable for graphs with up to forty vertices without further polyhedral studies.This is comparable with the original approach in [29].

Level Planarity Testing Using the Vertex Exchange Graph
Harrigan and Healy [27]

Clustered Crossing Reduction
In a clustered level graph the vertices are grouped into subgraphs in a hierarchical way.The crossing reduction has to ensure that all (dummy) vertices of a subgraph in the same level are consecutive and that all subgraphs spanning several levels have a matching order in each level that avoids overlaps of disjoint subgraphs, see [23,24].The treatment of directed clustered graphs is rather complicated using a 2-level crossing reduction approach.With global sifting we can address crossings directly.Instead of swapping a vertex with its right neighbor in a sifting swap we swap all blocks of a subgraph with its right neighbor, which itself is either a block or a subgraph, and determine the change in the number of crossings.The time complexity stays the same as in the ordinary global sifting algorithm.If the layout of the subgraphs themselves is not fixed, then global sifting can be applied to the subgraphs as well, e. g., performing a sifting round for every hierarchical layer.

Cyclic and Radial Level Graphs
Level graphs can be generalized to cyclic and to radial level graphs.In cyclic level graphs the set of levels is ordered in a cyclic way, i. e., the first level directly succeeds the last.This corresponds to the recurrent hierarchies of Sugiyama et al. [43].Cyclic levels are normally drawn forming a star in 2D (see Fig. 12(a)).These drawings explicitly visualize cycles in graphs [6], which is helpful, e. g., in scheduling [26,41,44] and in bioinformatics [35].In radial level graphs each level itself is ordered in a cyclic way, i. e., the first vertex in each level is the right neighbor of the last vertex.The levels are drawn as concentric rings.See Figs. 12 and 13 for example drawings.Global sifting can be extended to both concepts and is the first crossing reduction technique avoiding type 2 conflicts in each case.
For cyclic level graphs our global sifting can be used without any changes and within the same time complexity.Note that one-sided 2-level algorithms cannot be applied here, since each of them pushes most of the crossings to the next level and these form a cycle.Even the absence of type 2 conflicts cannot be guaranteed then, because the sweep has to stop at some level.There is no possibility to push the crossings and the type 2 conflicts upwards or downwards out of the drawings as it is in usual hierarchical level drawings.The conflicts move like a wave front from level to level and they recur.
For leveling and coordinate assignment of cyclic level graphs see [2,4].The ILP approach by Jünger et al. [29] can be used for exact cyclic k-level crossing minimization straightforward by including additional constraints for the edges between the last and the first level.
In a radial level graph the levels are concentric circles (see Fig. 13(a)).These drawings visualize distance or importance, and are the common drawings of social networks [9,46].They map structural centrality of the graph to geometric centrality.Crossing minimization in radial level graphs is N P-hard, even if restricted to two levels with one side fixed [1].Our global sifting approach guarantees radially aligned long edges and can be used with minor modifications: Each block of the block list B has its own angle.The order of B starts with an arbitrary block.As in [1] we define an offset ψ : E → Z for each outer segment.The absolute value |ψ(e)| counts the crossings of segment e with an imaginary ray splitting the levels by a straight halfline from the concentric center to infinity.If ψ(e) < 0 (ψ(e) > 0), e has clockwise (counter-clockwise) direction from the source to the target.When sifting a block A ∈ B, we have to update the partings, which are the two borders between the counterclockwise and clockwise segments in the levels above and below A, see Fig. 13(b).Since we can do this independently of each other and add the results of the change in crossings to ∆ in Algorithm 4, we use the same technique as in [1].We sift a block from its current position in counterclockwise direction.Thus, for few crossings the partings have to follow this direction in their levels.During the swap the test whether or not changing the orientation of some of the first of the (ordered) incident segments of A by incrementing their offsets, and thus putting them last, leads to less crossings.However, counting the difference raises the   ).The radial coordinate assignment phase in [1] relies on the obtained absence of type 2 conflicts.

Discussion
We have presented an algorithm for the global crossing reduction problem of klevel graphs.It produces high quality results with fewer crossings than common approaches at the expense of a quadratic running time which is still feasible in practice.Global crossing reduction was an open problem since the introduction of the hierarchical framework [43] in 1981.For radial and cyclic level crossing reduction our algorithm is the first which guarantees the absence of type 2 conflicts.Our approach simplifies and improves several other algorithms concerning level planarity and crossing reduction.

Open Problems
The practical time complexity of the global sifting algorithm could be improved by testing the positions of blocks which change a relative order on a level only.Often blocks on disjoint levels are swapped which does not change any permutation on any level.The worst case situation is having a level with only one vertex v.The global sifting algorithm tests all O(|E|) positions for the block of v although each of them yields the same permutation of the level of v.Each such swap is computed in constant time.Nevertheless, avoiding unnecessary swaps is desirable, although it will not improve the theoretical worst case complexity: Consider a complete bipartite graph G = (V 1 ∪ V 2 , E) with the vertices of V 1 on level 1 and the vertices of A conceptually rather simple approach to reduce the number of unnecessary swaps is to stop a sifting step if all adjacent blocks of the current block A are left of A already.Swapping A further to the right can only increase the number of crossings then.Similarly, the first position to test for a block A can be directly left of its leftmost adjacent block.
A first approach to applying the blocks to the radial crossing reduction algorithm in [1] leads to a time complexity of O(|E| 3 ).Further research is needed to evaluate if a time complexity of O(|E| 2 ) can be achieved in the radial case as well.

Figure 1 :
Figure 1: Crossing reduction using an exact level-by-level sweep method has been stuck in a local minimum respectively.G is ordered if the vertices in each level as well as the sets N − (•) and N + (•) are ordered from left to right.Each proper level graph can be made ordered by choosing an arbitrary order for each level.This induces an order of the sets N − (•) and N + (•).Let deg − (v) := |N − (v)| and deg + (v) := |N + (v)| denote the indegree and outdegree of a vertex v and set deg(v) := deg − (v) + deg + (v) (A) = I − (upper(A)) and I + (A) = I + (lower(A)) of lengths |I − (A)| := |N − (A)| and |I + (A)| := |N + (A)|, respectively.As an inverted file I − (A) stores the indices where upper(A) is stored in each adjacent block B's adjacency array N + (B).More precisely, let b = N − (A)[i] be a neighbor of upper(A) with B = block(b).Then, I − (A)[i] Separate π-positions, ordered adjacency lists N − and N + , and index arrays I − and I + for each block

second traversal of s 9 foreachAlgorithm 3 :
s ∈ { (w, x) ∈ E | w = lower(A) } do 10 insert w at the next free position j of N − (x) 11 if π(A) < π(block(x)) then p[s] ← j // first traversal of s 12 else I − (x)[j] ← p[s]; I + (w)[p[s]] ← j // second traversal of s A as χ = 0 when A is placed to the first position.Thereafter, we only compute the change in the number of crossings when A is iteratively swapped with its right neighbor (line 6).SIFTING-STEP Input: Proper k-level graph G = (V , E , φ ), ordered list B of blocks in G , block A ∈ B to sift Output: Updated order of B 1 (a, b) and (c, d) be two segments between the same levels with a = c and b = d.If the two segments cross after swapping A and B and they did not cross before (or vice versa) either a and c or b and d were swapped.Therefore, one of the segments is adjacent to A or is a part of A and the other is adjacent to B or is a part of B. If b and d were swapped and thus a and c were not, φ(b) = φ(d) is the upper level of A or B and thus one of the crossing segments is an incoming outer segment of A or B. The other segment is either an incoming outer segment or an inner segment of the other block.Note that it cannot be an outgoing outer segment of this block because then neither a and c nor b and d would have been swapped.The other case of swapping a and c instead of b and d is symmetric.Then, the second segment is either an outgoing outer segment or an inner segment of the other block.

JGAA, 15
Blocks A and B swapped

Figure 3 :
Figure 3: Changes in crossings for a swap An update of the adjacency after a swap (line 10) is necessary if a and b have common neighbors.Algorithm 6 shows how this can be done in overall O(deg(A) + deg(B)) time similarly to the crossing counting function Algorithm 5.

Lemma 3 Theorem 1
Let G = (V, E, φ) be a level graph.Then, B∈B deg(B) ≤ 4 • |E|.Proof: Every edge e ∈ E contains at most two outer segments.Every outer segment increases the degree of its two incident blocks by one each.One round of global sifting (Algorithm 1) has a time complexity of O(|E| 2 ) for a non-necessarily proper level graph G = (V, E, φ).Proof: Let B be the blocks of G. Swapping two blocks A, B ∈ B needs O(deg(A) + deg(B)) time.Initializing a sifting step takes O( B∈B deg(B)) = O(|E|) time.A sifting step of a block A needs O( B∈B\{A} (deg(A)+deg(B))) = O(|E| • deg(A)) time.Thus, a sifting round for each block A ∈ B has time complexity O( A∈B (|E| • deg(A)) = O(|E| 2 ).Since |V | ≤ k • |E| ∈ O(|E| 2 ) (no empty levels), traversing all (dummy) vertices in pre-and postprocessing has no effect on the worst case time complexity.

Algorithm 6 :
UPDATE-ADJACENCIES Input: Vertices a, b ∈ V , N d (a), I d (a), N d (b), I d (b) Output: Updated adjacencies of a and b and all common neighbors

7 else 8 z ← x i // = y j 9 swap
entries at pos.I d (a)[i] and I d (b)[j] in N −d (z) and in I −d (z) 10

Figure 5 :Figure 7 :Figure 8 :Figure 9 :
Figure 5: Benchmark: number of crossings after vs. before applying the crossing reduction

Figure 10 :Figure 11 :
Figure 10: Benchmark: number of crossings in the Rome graphs

s 1 =
(a, b) and s 2 = (c, d) be segments between the same levels such that at least one of them is an outer segment.Let A = block(a), B = block(b), C = block(c), and D = block(d).Note that A = B or C = D holds if s 1 or s 2 is an inner segment, respectively.W. l.o. g. let π(A) < π(C).We add a boolean crossing variable c ABCD which indicates whether or not s 1 and s 2 cross.If π(B) < π(D), we add the constraint −c ABCD ≤ x BD −x AC ≤ c ABCD , otherwise we add 1 − c ABCD ≤ x DB − x AC ≤ 1 + c ABCD .The objective function is to minimize the sum of the values of all crossing variables.See (1) for the complete ILP formulation for a proper k-level graph G = (V , E , φ ) of G with I ⊂ E denoting the set of inner segments.Informally speaking, each element of the set C denotes the up to four incident blocks of each pair of edges which may cross.χ opt = min (A,B,C,D)∈C c ABCD C = { (A, B, C, D) ∈ B 4 | ∃(a, b), (c, d) ∈ E : (a, b) ∈ I ∨ (c, d) ∈ I, φ(b) = φ(d), A = block(a), B = block(b), C = block(c), D = block(d), π(A) < π(C) }

Figure 12 :
Figure 12: Global crossing reduction for a cyclic drawing

Figure 12 :
Figure 12: Global crossing reduction for a cyclic drawing (cont.) V 2 on level 3.Then, level 2 contains O(|E|) = O(|V | 2 ) dummy vertices.For each block representing a dummy vertex, O(|E|) positions on level 2 have to be tested.Hence, having a time complexity of O(|E| 2 ) when avoiding unnecessary swaps is possible as well, even if O(|E|) = O(|V | 2 ).

Figure 13 :
Figure 13: Global crossing reduction for a radial drawing introduced vertex exchange graphs as a data structure for a simple level planarity test in O(|V | 2 ) time, where V ⊇ V is the set of all vertices including dummy vertices.Using our blocks, it is straightforward to improve the running time of the test from O(|V | 2 ), i. e., O((|V | • k) 2 ) worst case, to O(|V | 2 ) similarly to the ILP above: Each pair of overlapping blocks builds one vertex in the vertex exchange graph.Similar techniques can be used to reduce the number of 2-SAT clauses for testing level planarity or to minimize crossings without type 2 conflicts [39].