A Fast and Simple Subexponential Fixed Parameter Algorithm for One-Sided Crossing Minimization

We give a subexponential fixed parameter algorithm for one-sided crossing minimization. It runs in $O(k2^{\sqrt{2k}} + n)$ time, where n is the number of vertices of the given graph and parameter k is the number of crossings. The exponent of $O(\sqrt{k})$ in this bound is asymptotically optimal assuming the Exponential Time Hypothesis and the previously best known algorithm runs in $2^{O(\sqrt{k}\log k)} + n^{O(1)}$ time. We achieve this significant improvement by the use of a certain interval graph naturally associated with the problem instance and a simple dynamic program on this interval graph. The linear dependency on n is also achieved through the use of this interval graph.


Introduction
A two-layer drawing of a bipartite graph G with bipartition (X, Y ) of V (G) places vertices in X on one line and those in Y on another line parallel to the first and draws edges as straight line segments between these two lines. We call these parallel lines layers of the drawing. A crossing in a two-layer drawing is a pair of edges that intersect each other at a point not representing a vertex. Note that the set of crossings in a two-layer drawing of G is completely determined by the order of the vertices in X on one layer and the order of the vertices in Y on the other layer. We consider the following problem.
OSCM (One-Sided Crossing Minimization) Instance: (G, X, Y, <, k), where G is a bipartite graph on X ∪ Y with E(G) ⊆ X × Y , < is a total order on X, and k is a positive integer.
Question: Is there a total order < on Y such that the two-layer drawing of G in which the vertices in X are ordered by < in one layer and those in Y are ordered by < in the other layer has k or fewer crossings?
OSCM is a key subproblem in a popular approach to multi-layer graph drawing, called the "Sugiyama approach" [19], which repeatedly solves OSCM for two adjacent layers as it sweeps the layers from top to bottom and vice versa, in hope of reducing the total number of crossings in the entire drawing.
OSCM is known to be NP-complete [7], even for sparse graphs [16]. On the positive side, Dujmović and Whitesides [5] showed that OSCM is fixed parameter tractable [4], that is, it can be solved in f (k)n O (1) time for some function f . More specifically, the running time of their algorithm is O(ψ k · n 2 ), where n = |V (G)| and ψ ∼ 1.6182 is the golden ratio. This result was later improved by Dujmović, Fernau, and Kaufmann [6] who gave an algorithm with running time O(1.4656 k + kn 2 ). Fernau et al. [8] reduced this problem to weighted FAST (feedback arc sets in tournaments) and, using the algorithm of Alon, Lokshtanov, and Saurabh [2] for weighted FAST, gave a subexponential time algorithm that runs in 2 O( √ k log k) + n O (1) time. This reduction also gave a PTAS using the algorithm of Kenyon-Mathieu and Schudy [13]. Karpinski and Schudy [12] considered a different version of weighted FAST proposed in [1], which imposes certain restrictions called probability constraints on the instances, and gave a faster algorithm that runs in 2 O( √ OPT) + n O (1) time where OPT is the cost of an optimal solution. However, reducing OSCM to this version of FAST seems difficult: a straightforward reduction produces an instance that does not satisfy the required probability constraints. Nagamochi gave a polynomial time 1.4664-approximate algorithm [18] and (1.2964 + 12/(δ − 4))-approximate algorithm when the minimum degree δ of a vertex in Y is at least 5 [17].
Our main result in this paper is the following.

Theorem 1 OSCM can be solved in O(k2
√ 2k + n) time, assuming that G is given in the adjacency list representation and X is given in a list sorted in the total order <.
Our algorithm is faster than any of the previously known parameterized algorithms. Both the dependency O(k2 √ 2k ) on k and the dependency O(n) on n are strictly better than the algorithms cited above. In particular, the exponent √ 2k does not contain the log k factor or any hidden constant as in the exponent O( √ k log k) of [8], the only previously known subexponential algorithm for OSCM. Note that the running time of our algorithm is linear in n as long as k ≤ log 2 n 2 − 2 log log n, where the base of the logarithm is 2. The improvement is not only of theoretical but also of practical importance: the range of k for which the problem can be practically solvable is significantly extended.
Moreover, the exponent of O( √ k) in our bound is asymptotically optimal under the Exponential Time Hypothesis (ETH) [9], a well-known complexity assumption which states that, for each k ≥ 3, there is a positive constant c k such that k-SAT cannot be solved in O(2 c k n ) time where n is the number of variables. ETH has been used to derive lower bounds on parameterized and exact computation (see [15] for a survey). The proof of the following theorem is in Sect. 6. (1) time algorithm for OSCM unless ETH fails.
Another advantage of our algorithm over the previous algorithms is simplicity. The algorithm in [5] involves several reduction rules for kernelization and the improvement in [6] is obtained by introduction of additional reduction rules which entail more involved analysis. The algorithm in [8] relies on the algorithm in [2] for the more general problem of FAST. Our result suggests that OSCM is significantly easier than FAST in that it does not require any advanced algorithmic techniques or sophisticated combinatorial structures used in the algorithm of [2] for FAST, in deriving a subexponential algorithm.
Our algorithm is along the lines of earlier work [5,6]. We emphasize that our improvement does not involve any complications but rather comes with simplifications. Our algorithm does not require any kernelization. It is a straightforward dynamic programming algorithm on an interval graph associated with each OSCM instance. This interval graph is implicit in the earlier work [5,6], but is neither made explicit nor fully exploited in the previous work. Once we recognize the key role this interval graph plays in the problem, the design and analysis of an efficient algorithm becomes rather straightforward. Below we sketch how this works.
Fix an OSCM instance (G, X, Y, <, k). For each vertex y ∈ Y , let l y (r y , resp.) denote the smallest (largest, resp.) x ∈ X adjacent to y, with respect to the given total order <. We denote the half-open interval [l y , r y ) = {x ∈ X | l y ≤ x < r y } in the ordered set (X, <) by I y and denote the system of intervals {I y | y ∈ Y } by I. For simplicity, we assume here that the degree of each vertex y in Y is at least 2 so that the interval I y is non-empty. Our formal treatment in Sect. 3 does not need this assumption. A key observation in [5] (see Lemma 2 in the present paper), is that if r u ≤ l v for distinct vertices u, v ∈ Y then u precedes v in any optimal ordering of Y . Therefore, to determine the optimal ordering on Y , we only need to determine the pairwise order for each pair {u, v} such that l v < r u and l u < r v , that is, such that the intervals I u and I v intersect each other. Thus, the problem can be viewed as that of orienting edges of the interval graph defined by the interval system I. The fact exploited in earlier work [5,6] to obtain fixed parameter algorithms for OSCM is that, in our terminology, this interval graph has at most k edges in feasible instances of OSCM, as each pair of u and v such that I u and I v intersect each other contributes at least one crossing to the drawing no matter which ordering of this pair in Y is chosen. Our interval graph view tells us more: the clique size of this interval graph for a feasible instance is at most √ 2k + 1, as otherwise it has more than k edges, and hence it has a path-decomposition of width at most √ 2k (see [3], for example, for interval graphs and their path-decompositions). Our algorithm is a natural dynamic programming algorithm based on this path-decomposition and runs in time exponential in the width of the decomposition.
We remark that the interval system I also plays an important role in reducing the dependency of the running time on n to O(n). See Sect. 4 for details.
A preliminary version [14] of the present paper showed that the algorithm runs in time O(3 √ 2k + n). In this paper, we improve the running time to O(k2 √ 2k + n). The rest of this paper is organized as follows. In Sect. 2, we give preliminaries of the problem and outline our entire algorithms. In Sect. 3, we describe the construction of the interval systems used in our algorithm. In Sect. 4, we describe a preprocessing phase of our algorithm. In Sect. 5, we describe our dynamic programming algorithm. Finally, in Sect. 6, we give a proof of Theorem 2.

Preliminaries and Outline of the Algorithm
In this section, we give some preliminaries and outline our algorithm claimed in Theorem 1. Throughout the remainder of this paper, (G, X, Y, <, k) will always be the given instance of OSCM. We assume that G does not have any parallel edges or isolated vertices. We denote the number of vertices |V (G)| by n and the number of We assume that N(v) is given as a list, together with its length d(v). We also assume that X is given as a list in which the vertices are ordered by <. For is the number of crossings between the edges incident with u and those incident with v when the position of u precedes that of v in the layer for Y . We extend this notation for sets: We represent total orderings by permutations in our algorithm. Let U be a finite set. A permutation on U , in this paper, is a sequence of length |U | in which each member of U appears exactly once. We denote the set of all permutations on U by Π(U ). Let π ∈ Π(U ). We define the total order < π on U naturally induced by π : for u, v ∈ U , u < π v if and only if u appears before v in π .
For each subset U of Y and a permutation π on U , we denote by c(π) the number of crossings among the edges incident with U when the vertices in U is ordered by π , that is, We need the following simple observation to bound the number of edges in feasible instances of OSCM.

Lemma 1 If G has a two-layer drawing with at most k crossings then
Proof The proof is by induction on k. The base case k = 0 is trivial since then G must be a forest. Note that a two-layer drawing of a cycle has at least one crossing. Suppose k > 0 and fix a two-layer drawing of G with at most k crossings. Let e be an edge that crosses some edges in the drawing. We apply the induction hypothesis to G \ {e} We also need the following lemma due to Dujmović and Whitesides [5].
Lemma 2 (Lemma 1 in [5]) Suppose u and v are distinct vertices in Y such that c(u, v) = 0. Then we have u < π v in every optimal permutation on Y , unless we also have c(v, u) = 0.

Motivated by this lemma, let us call an unordered pair
Let us note that pair {u, v} is free if u and v are false twins, i.e., N(u) = N(v), and moreover this common neighbor set is a singleton. We use the above lemma in the following form.

Corollary 1 Let π be an optimal permutation on Y and let
If {u, v} is free, then the permutation π obtained from π by swapping the positions of u and v is also optimal.
Proof The first part is a restatement of Lemma 2. Suppose pair {u, v} is free. This means that N(u) = N(v) = {x} for some x ∈ X. Clearly, u and v are indistinguishable in our problem. Therefore the second part holds.
Since each orientable pair contributes at least one crossing in any ordering of Y , the following is obvious.

Proposition 1 Assuming that the given OSCM instance is feasible, the number of orientable pairs is at most k.
The following is an outline of our algorithm.
1. If m ≥ n + k then stop with "No". 2. Construct the interval system I described in the introduction and another interval system J , which inherits the property of I that each intersecting pair of intervals contributes at least one crossing in the drawing and is designed to allow degree-1 vertices and to facilitate dynamic programming. The total running time of the algorithm is dominated by the dynamic programming part and is O(k2 √ 2k + n). It is straightforward to augment the dynamic programming tables so that, when the last step is complete, an optimal permutation on Y can be constructed. We note that this optimal solution is correct even if opt(Y ) > k, as long as the dynamic programming computation is completed.

Interval Systems
We refer to the interval system I = {I y | y ∈ Y } defined in the introduction as the naive interval system. Recall I y = [l y , r y ), where l y is the smallest neighbor of y and r y is the largest neighbor of y, with respect to the total order < on X. The construction of I can be done in O(m) time: we scan X in the given total order < and, as we scan x ∈ X, we do necessary book-keeping to record l y and r y for each y ∈ N(x). We need another system J = {J y | y ∈ Y } of intervals which is slightly more complicated than the naive system. This complication comes from the need to deal with vertices in Y of degree 1 and to facilitate dynamic programming. The system J will satisfy the following conditions. Let J y = [a y , b y ] for each y ∈ Y . J1 For each y, a y and b y are integers satisfying 1 ≤ a y < b y ≤ 2|Y |. J2 For each t, Conditions J1 and J2 are for the sake of the ease of dynamic programming described in the next section, while condition J3 is the essential property that J shares with the naive interval system.
For each y ∈ Y , (y, l y , 0) and (y, r y , 1) are intended to represent the left and the right ends of the interval J y , respectively. Our strategy is to define a total order on P and let a y (b y , resp.) be the rank of (y, l y , 0) ((y, r y , 1), resp.) in this total order. For each p ∈ P , we denote by y(p), x(p), and i(p) the first, second, and the third element of p.
The total order < on P is defined as follows. This definition is based on the given total order < on X.
The order is primarily based on the second component: if x(p) < x(q) then p < q. For each x ∈ X, let P x = {p ∈ P | x(p) = x}. To describe the order < within each P x , we first partition P x into three subsets: x and q ∈ P j x with i < j. The order of elements within P 1 x and within P 3 x is arbitrary. Elements of P 2 x come in pairs: (x, y, 0) and (x, y, 1), where y ∈ N(x) with d(y) = 1. The order in P 2 x is chosen so that (x, y, 0) < (x, y, 1) for each pair and these pairs are not interleaved: we do not have y, y with (x, y, 0) < (x, y , 0) < (x, y, 1) or (x, y, 0) < (x, y , 1) < (x, y, 1). Now we list the elements of P as p 1 , . . . , p 2|Y | in the total order just defined. For each y ∈ Y , we let a y = t where t is such that p t = (y, l y , 0) and b y = t where t is such that p t = (y, r y , 1). This completes the description of the interval system J .
The construction of J can also be done in O(m) time. The set P is constructed as a list by scanning X. This list is already sorted in the primary key x. The partitioning of P x into P 1 x , P 2 x , P 3 x and the pairing in Proof From the construction of J based on the total order on P , it is obvious that J1 and J2 are satisfied. That J3 is satisfied is also obvious, as b u < a v for u, v ∈ Y implies that r u ≤ l v in X.
We restate Corollary 1 using our interval system J . We say that a permutation π on U ⊆ Y is consistent with J if b u < a v implies u < π v for every pair u, v ∈ U . Lemma 3 Let U be an arbitrary subset of Y . There is an optimal permutation π on U that is consistent with J .
Proof Let π be an optimal permutation on U . For each x ∈ X, let U x denote the set of vertices in U that are adjacent to x but no other vertices in X. For each x, each pair of distinct vertices in U x is free and therefore, applying Corollary 1 to the instance where Y is replaced by U , we may assume that π restricted on U x is consistent with J . Now, let u, v be arbitrary vertices in U and suppose b u < a v . By property J3 of J , we have c(u, v) = 0. If c(v, u) > 0 then {u, v} is forced to (u, v) and we must have u < π v. Otherwise, {u, v} is free and u, v ∈ U x for some x ∈ X. By the assumption on π above, we have u < π v in this case as well.

Computing the Crossing Numbers
Dujmović and Whitesides [5] give an algorithm for computing the crossing numbers c(u, v) for all pairs {u, v} in O(kn 2 ) time. We spend O(n + k) time for precomputing c(u, v) for all orientable pairs, ignoring forced and free pairs.
We use the naive interval system I = {I y | y ∈ Y }, where I y = [l y , r y ), in this computation.
It turns out helpful to decompose the above sum as follows.
For each x ∈ X, let Y x = {y ∈ Y | l y < x < r y } be the set of vertices in Y whose corresponding intervals strictly contain x.
In the following, we call an ordered pair (u, v) orientable if the corresponding unordered pair is orientable. We evaluate these sums simultaneously for all orientable pairs (u, v), using a counter c [u, v] for each pair. We represent these counters by a |Y | × |Y | two-dimensional array. Since we cannot afford to initialize all of its elements, we initialize c [u, v] to 0 only for orientable pairs (u, v). Our algorithm proceeds as follows.
1. Scan X in the total order <, maintaining Y x as we scan x. When we scan x ∈ X, we initialize c [u, v] to 0 for each u ∈ N(x) and each v ∈ Y x .
2. Scan X again in the total order <, maintaining Y x and d <x (y) for each y ∈ Y , as we scan x. Suppose we are scanning x ∈ X. For each u ∈ N(x) and each v ∈ Y x , we add d <x (v), the summand in (1), to c [u, v]. Moreover, for each u ∈ Y x and v ∈ N(x) such that r v = x, we add d(v) · (d(u) − d ≤x (u)), the second term in (1), to c [u, v].

Lemma 4
Assuming that the given OSCM instance is feasible, the running time of the above algorithm is O(n + k).
Proof Assume that the given OSCM instance is feasible. In both scans, we maintain Y x as a doubly linked list with each entry for vertex y having a back-pointer from y. This allows the addition to and removal from Y x of a single vertex to be done in O(1) time. Therefore, Y x can be maintained in O(m) = O(n + k) total time for each scan.
In the first scan, the number of times the counters are initialized is at most 2k, since each pair (u, (x, v)) with u, v ∈ Y and (x, v) ∈ E(G) that leads to an initialization of c [u, v] contributes at least one crossing in any ordering of Y and with each crossing at most two such pairs are associated. Therefore the running time of the first scan is O(n + k). The second scan also consumes O(n + k) time for maintaining Y x and updating those counters. It remains to show that the maintenance of d <x (v) for each v ∈ Y can be done in O(n + k) total time. Using a simple counter for each v ∈ Y , which is incremented when each x ∈ X adjacent to v is scanned, the maintenance of To control the running time for infeasible instances, we count the number of times the initialization of a counter occurs in the first scan. As soon as the number exceeds 2k, we stop the computation and report infeasibility.

Dynamic Programming
In this section, we describe our dynamic programming algorithm for computing opt(Y ). Owing to the previous section, we assume in this section that c(u, v) and c (v, u) are available for all orientable pairs {u, v}.
We use the interval system For each t, In other words, when interval J y opens at t, y is moved from the "right set" to the "middle set"; when it closes at t, y is moved from the "middle set" to the "left set".
For each integer t, 1 ≤ t ≤ 2|Y |, we compute the following and store the results in a table: (1) c(L t , {y}), for each y ∈ M t ; (2) opt(L t ∪ S), for each S ⊆ M t .
The recurrences for (1) are straightforward. The base case is c(L 1 , {y}) = 0, where L 1 = ∅ and y is the unique element of M 1 . Let 2 ≤ t ≤ 2|Y | and suppose first that t = a y for some y ∈ Y . Note that L t = L t−1 and M t \ M t−1 = {y}. Therefore, for v ∈ M t \ {y}, we have c(L t , {v}) = c(L t−1 , {v}). Since b u < a y for each u ∈ L t = L t−1 , we have c(L t , {y}) = 0. Suppose next that t = b y for some y ∈ Y . Note that L t \ L t−1 = {y} and M t−1 \ M t = {y} in this case. For each v ∈ M t , we have c(L t , {v}) = c(L t−1 ∪ {y}, {v}) = c(L t−1 , {v}) + c(y, v). Note that pair (y, v) is orientable, as y, v ∈ M t−1 , and hence c(y, v) is available. Thus, in either case, the table entries of type (1) for t can be computed from the entries for We now turn to the recurrences for type (2) entries. The following lemma helps us to compute type (2) entries.

Lemma 5
There is an optimal permutation π on L t ∪ S whose last vertex belongs to S.
Proof By Corollary 1, we may assume that π consistent with J . Since π is consistent with J and b u < a y for all u ∈ L t , we have u < π y for all u ∈ L t . Then, there must be some v ∈ S such that either y < π v or y = v, that is, the last vertex of π is contained in S. The dynamic programming gives us the optimal solution opt(Y ) since L 2|Y | = Y . Each pair of vertices in M t contributes at least one crossing in any ordering of Y . Therefore, for the given instance to be feasible, we have h(h − 1)/2 ≤ k and hence h ≤ √ 2k + 1, where h = |M t |. Using this bound and an observation that |M t | ≥ 2 for at most k values of t, it is straightforward to derive a bound of O(k 3/2 2 √ 2k + n) on the running time of the entire dynamic programming computation. For a tighter analysis, we need the following lemma. Proof Fix h, 2 ≤ h ≤ H . Let t 1 < t 2 < · · · < t c h be the members of {t | |M t | = h}. The first set M t 1 contains h(h − 1)/2 pairs of vertices each corresponding to an intersecting pair of intervals. We claim that M t i for each 2 ≤ i ≤ c h contributes at least h − 1 new intersecting pairs of intervals. This is obvious if This is the claimed bound. and therefore we have the claimed bound.
To control the running time for infeasible instances, we compute c h for each 2 ≤ h ≤ H and, if c h exceeds the proved bound, we immediately stop the computation as we have detected infeasibility.

Proof of Theorem 2
Impagliazzo, Paturi, and Zane [10] have shown that, under ETH, there is no 2 o(m) time algorithm for 3-SAT where m is the number of clauses. We confirm in the lemmas below that the standard chain of reductions from 3-SAT to OSCM showing the NP-completeness of sparse OSCM is such that the number r of edges in the resulting OSCM instance is linear in the number m of clauses of the input 3-SAT instance. Theorem 2 follows, since a 2 o( √ k) n O(1) time algorithm for OSCM would imply a 2 o(m) time algorithm for 3-SAT as k ≤ r 2 = O(m 2 ) in our reduction and hence would violate ETH.
Lemma 9 [11] There is a polynomial time algorithm that, given a 3-CNF formula φ with n variables and m clauses, computes a graph G φ such that φ is satisfiable if and only if G φ has a vertex cover of size at most n + 2m. Moreover, G φ has at most 2n + 3m vertices and at most n + 6m edges.
Proof (sketch) Let X = {x 1 , x 2 , . . . , x n } be the set of variables of φ and C = {c 1 , c 2 , . . . , c m } be the set of clauses of φ. We construct the graph G φ as follows. For each variable x i ∈ X, G φ contains a pair of vertices u i ,ū i and an edge {u i ,ū i }. For each clause c i ∈ C, G φ contains a cycle If the kth literal of c j is x i for some i, then we add an edge {v k j , u i } to G φ . Otherwise, kth literal of c j isx i for some i, then we add an edge {v k j ,ū i } to G φ . G φ has 2n + 3m vertices and n + 6m edges as claimed. The correctness proof of this reduction can be found in [11].
Lemma 10 [11] There is a polynomial time algorithm that, given a graph G with n vertices and m edges, and an integer k, computes a directed graph D such that G has a vertex cover of size at most k if and only if D has a feedback arc set of size at most k. Moreover, D contains at most 2n vertices and at most n + 2m arcs.
Proof (sketch) Let V = {u 1 , u 2 , . . . , u n } be the set of vertices of G. We construct the directed graph D as follows. For each vertex u i ∈ V , D contains a pair of vertices v i , w i together with an arc (v i , w i ). For each edge {u i , u j } of G, D contains a pair of arcs (w j , v i ) and (w i , v j ). G φ has 2n vertices and n + 2m arcs as claimed. The correctness proof of this reduction can be found in [11].
Finally, we describe a reduction from the feedback arc set problem to OSCM. Eades and Wormald [7] first gave such a polynomial time reduction. But the reduced OSCM instance has Θ(nm) edges, where n is the number vertices and m is the number of arcs, of a directed feedback arc set instance. For our purposes, we need a reduction to sparse OSCM due to [16].
Lemma 11 (Sect. 4 in [16]) There is a polynomial time algorithm that, given an integer t and a directed graph with n vertices and m edges, computes an OSCM instance I = (G, X, Y, <, k) with 5(n + m) vertices and 4(n + m) edges such that D has a feedback arc set of size at most t if and only if I is feasible.
Proof (sketch) We denote the vertex set of D by V and the arc set of D by A. Let X i , 1 ≤ i ≤ 5, be disjoint sets each of cardinality |V | + |A| and let φ i be a bijection from V ∪ A to X i for 1 ≤ i ≤ 5. Let G = (X ∪ Y, E) be a bipartite graph with bipartition (X, Y ) where Clearly, |X ∪ Y | = 5(n + m) and |E| = 4(n + m). Then we construct the OSCM instance I = (G, X, Y, <, k) where the total order < and the crossing number k are appropriately defined. We omit the definition of < and k together with the correctness proof of the reduction, which can be found in [16].
To summarize these reductions, we obtain the following lemma.

Lemma 12
There is a polynomial time algorithm that, given a 3-CNF formula φ with m clauses, computes an OSCM instance I = (G, X, Y, <, k) such that φ is satisfiable if and only if I is feasible. Moreover, G contains O(m) edges.

Future Work
Fernau et al. [8] gave a PTAS for OSCM using the PTAS of Kenyon-Mathieu and Schudy [13] for weighted FAST. It would be interesting to know whether our approach can be used to develop a PTAS. Some exponential space dynamic programming algorithms can be transformed into polynomial space algorithms with additional time consumption. Our dynamic programming described in Sect. 5 uses exponential space. It is possible that this algorithm can also be turned into a polynomial space algorithm, but this does not appear straightforward and probably is another research topic. We expect that our algorithm performs well on practical instances since these instances are typically sparse and have small crossing numbers. We already have a partial implementation with positive preliminary results. For more extensive evaluation, we need to fully implement the algorithm and evaluate it on benchmark instances available in the graph drawing community.