Accelerated Bend Minimization

We present an O ( n 3 / 2 ) algorithm for minimizing the number of bends in an orthogonal drawing of a plane graph. It has been posed as a long standing open problem at Graph Drawing 2003 , whether the bound of O ( n 7 / 4 √ log n ) shown by Garg and Tamassia in 1996 could be improved. To answer this question


Introduction
A drawing of a planar graph is called orthogonal if all edges are non-crossing axis-parallel polylines, i.e. sequences of finitely many horizontal and vertical line segments.The intersection point of a vertical and a horizontal line segment of an edge is a bend.Examples of orthogonal drawings can be found in Fig. 1.
(a) GD Contest 2008 [13] (b) Octahedron If a graph has an orthogonal drawing such that the vertices are drawn as points then the degree of any vertex is at most four like in Fig. 1(b).We will concentrate on this case in this paper.Biedl and Kant [3] gave a linear-time algorithm for constructing an orthogonal drawing with at most two bends per edge of a graph with degree at most four (except for the octahedron -see Fig 1(b)).Bläsius et al. [4] showed that it can be decided in polynomial time whether a planar graph has an embedding (i.e. a fixed cyclic ordering of the incident edges around each vertex) that allows an orthogonal drawing with at most one bend per edge.The problem of minimizing the number of bends in an orthogonal drawing of a planar graph with maximum degree four is N Pcomplete [18] if the embedding of the graph is not fixed.Bertolazzi et al. [2] described a branch-and-bound approach for minimizing the number of bends over all embeddings.
Tamassia [30] considered the bend-minimization problem on plane graphs, i.e., on planar graphs with a fixed embedding and a fixed outer face.He showed that the problem of minimizing the total number of bends in an orthogonal drawing of a plane graph with degree at most four can be modeled by a mincost flow problem.There are also variations of the flow-based bend minimization approach which include a restricted number of bends, vertices of degree higher than four [16,23,31,2] such as in Fig. 1(a), drawing clustered graphs [8,25], or interactive and dynamic graph drawing [10,9].
Network flows are an important topic in combinatorial optimization and we refer the interested reader to [1] and [29] for a general overview.Instead, we concentrate on the special case of planar networks in this paper.To the best of the authors' knowledge, there have not been many direct contributions to com-pute planar min-cost flows in the past decades.One exception is a dedicated analysis of an interior point method [22] restricted to linear programs arising from min-cost flow problems on planar graphs by Imai and Iwano [21].In 1990, they proved a running time bound of O(n1.594 √ log n log(nγ)), where γ is an upper bound on the absolute values of costs and capacities.Much more progress has been made on important special cases such as the shortest path problem and the max flow problem, which may be used in general flow algorithms as subroutines to obtain a better running time when the input is restricted to planar graphs.This includes the famous linear-time algorithm for planar shortest path with non-negative lengths [20], near linear-time algorithms for shortest path with real lengths [14,24,28], and for max s-t-flow [33,5].The latter problem can be solved in linear time when s and t are on the same face because of its equivalence to a shortest path problem with non-negative lengths in the dual graph shown by Hassin [19].This result has been extended to multiple sources and sinks on the same face by Miller and Naor [27].
Garg and Tamassia [17] proved that a min-cost flow problem on a flow network with n nodes, m arcs, and the minimum cost χ of a flow can be solved in O(χ 3/4 m √ log n) time and concluded that the bend minimization problem of an embedded planar graph with degree at most four can be solved in O(n 7/4 √ log n) time.It was posed as an important open problem in graph drawing, whether this run time could be improved [7,Problem 14]. 1

Our contribution
In this paper, we especially exploit the fact that the flow network is planar and show how to solve the problem in O(n 3/2 ) time.Our algorithm splits the flow network using a cycle separator.To this end, the edges on the cycle are contracted, which maintains planarity.The separator thereby shrinks to a cut node that joins two components on which the min-cost flow problem can be solved independently.The recursive solutions of the two parts are combined by expanding the separator vertex by vertex and adjusting the flow between the endpoints of the corresponding edge in each step.
In particular, we show that the uncapacitated min-cost flow problem on a planar bidirected graph with bounded costs and face sizes can be solved in O(n 3/2 ) time.This result only relies on linear-time algorithms for finding cycle separators [26], and for computing max s-t-flows in (s, t)-planar graphs ( [19] combined with [20]).Note that our approach combined with a result on multiple-source multiple-sink max flow in planar graphs [6] solves the bendminimization problem in O(n 3/2 log n) time if we additionally wish to constrain the number of bends on some edges and it yields an O( √ χn log 3 n) algorithm for computing a flow of minimum-cost χ on a planar flow network with n nodes and O(n) arcs.
The paper is organized as follows.In Section 2, we define the min-cost flow problem and briefly describe the flow model of Tamassia for bend-minimization.In Section 3, we describe the primal-dual algorithm that generally solves the min-cost flow problem.Our main result, based on the divide and conquer approach, that yields the O(n 3/2 ) time algorithm is described in Section 4.

Bend Minimization and Flow Networks
Throughout this paper let G = (V, E) be a simple undirected connected plane graph with n vertices of degree at most four and let F be the set of faces of a planar embedding.We consider a directed multi-graph D G = (W G , A G ) with node set W G = V ∪ F and arcs between adjacent faces and from the vertices to their incident faces.Let D F be the subgraph of D G that is induced by the face nodes only.
A min-cost flow network N consists of a directed (multi-)graph D = (W, A), capacities u : A → Z ≥0 ∪ {∞}, node demands b : W → Z, and arc costs . We say that a flow problem is uncapacitated and with unit costs, respectively, if u(a) = ∞ and c(a) = 1, respectively, for all arcs a ∈ A.
The bend-minimization problem can be modeled by a min-cost flow network N G = (D G , u, b, c) [30] with the following properties.
1. D F is planar, bidirected with infinite capacity and unit cost.
2. The degree of a face of D F is at most four.

A cycle separator of D
4. D G is planar and triangulated.
5. The minimum cost of a flow in N G is at most 2n + 4 [3].
Readers to whom these properties sound familiar may safely skip the next subsection, which contains a brief presentation of Tamassia's approach [30].

Bend Minimization as Min-Cost Flow
In this section, we briefly describe the approach of Tamassia [30] for constructing an orthogonal drawing of a plane graph with the minimum total number of bends.The approach consists of two phases.In the first phase an orthogonal representation is computed, which fixes the angle at each vertex between two v4( 1) consecutive adjacent edges on one hand and the number of right and left turns on each edge on the other hand.In a second step an area efficient orthogonal grid drawing is constructed from a feasible orthogonal representation.The second step can be done in linear time using topological sorting [11, page 155].
The orthogonal representation associates four labels with each edge {v, w} ∈ E, two for each direction.The label 1 ≤ α(v, w) ≤ 4 is such that α(v, w) • π/2 denotes the angle at vertex v between {v, w} and the next incident edge of v in counter-clockwise direction.The label τ (v, w) ≥ 0 denotes the number of left-turns on {v, w} traversed from v to w. See Fig. 2(a), for an illustration.
Let the degree deg h of a face h be the number of its incident edges where bridges count twice.Elementary geometry implies that there is an orthogonal drawing that corresponds to some given labels α and τ if and only if they imply that the sum of angles around a vertex is 2π and that the sum of angles around an inner/outer face h is π • (deg h + number of bends ∓ 2).The latter can be reformulated as where E(h) denotes the arcs incident to the face h directed in counter-clockwise direction.This yields a min-cost flow formulation for finding a feasible orthogonal representation with the minimum number of bends.
The bend minimization problem on G can be solved by the following mincost flow network N G .The node set of the directed graph 3 The Primal-Dual Algorithm In this section, we briefly describe the primal-dual algorithm [15] for solving the min-cost flow problem. Let of the min-cost flow network N with respect to a pseudo-flow f : A → Z ≥0 , and a node potential π : W → Z is defined as follows.For each arc a ∈ A with tail v and head w the arc set A f contains a with c π (a The costs c π are called the reduced costs and u f are the residual capacities.The node potential is valid if c π (a) ≥ 0 for all a ∈ A f .The primal-dual algorithm solves a min-cost flow problem utilizing the reduced cost optimality condition.

Lemma 1 ([1, Theorem 9.3]) A flow has minimum cost if and only if it admits a valid node potential.
The primal-dual algorithm works as follows on a min-cost flow network N = (D = (W, A), u, b, c).First, the equivalent min-cost max flow network N st = (D st = (W ∪ {s, t}, A st ), u, c, s, t) is constructed, i.e. a super source s and a super sink t are added to W .Note that in general this construction does not preserve planarity.However, this is not relevant for the following lemmas.For each node v ∈ W with b(v) > 0 an arc (s, v) with u(s, v) = b(v) and cost zero is added to A. Further, for each node v ∈ W with b(v) < 0 an arc (v, t) with u(v, t) = −b(v) and zero costs is added to A. The value of a flow in N st is the sum of all flow values on the arcs incident to s.Note that N has a feasible flow if and only if a maximum s-t-flow of N st saturates all arcs incident to s.Further, let f be a maximum flow with minimum costs on N st .Restricting f to A yields a min-cost flow on N .
The primal-dual algorithm now basically augments as much flow as possible on shortest s-t-paths in the residual network.More precisely, the algorithm starts with the node potential π = 0 and the pseudo flow f = 0.As long as not all arcs incident to s are saturated, the algorithm adds the shortest- and augments f by an s-t-flow in (D o f , u f ).See Algorithm 1 for a pseudocode.In effect, the primal-dual algorithm augments a maximum s-t-flow in the admissible network (D o f , u f ) while the successive shortest-path algorithm augments flow only on one shortest s-t-path in each iteration, substituting Line 6 while there is an of Algorithm 1 by fixing a single s-t-path P in (D o f , u f ) and by setting f o to be min{u f (a) : a ∈ P } on P and zero otherwise.In Lemma 3, we discuss combinations of these two methods.
To analyze the number of iterations, let f i and π i , respectively, be the flow and potential, respectively, after the ith iteration of the primal-dual algorithm.Further, let f 0 = 0, π 0 = 0 be the initial flow and potential.Recall that we consider integer costs and capacities.
Lemma 2 We have the following properties. Proof: and, hence, Let now s = v 0 , . . ., v = v be the nodes on a shortest s-v-path P in (D fi−1 , c πi−1 ).This means for each arc (v j , v j+1 ) on P that

S. Cornelsen and A. Karrenbauer Accelerated Bend Minimization
Hence, it follows from the update-rule of the potentials that So we have that 2. By definition, π i+1 (t) = π i (t) + dist fi,πi (s, t).After augmenting a maximum s-t-flow on the arcs with zero reduced costs there is an s-t-cut on which all arcs with zero reduced costs are saturated.Hence, the residual network contains no s-t-path with zero reduced costs.Hence, dist fi,πi (s, t) > 0.
Lemma 3 Let i ≥ 1 be an integer.If there is a feasible flow on N of cost at most χ then a min-cost flow can be computed by performing at most i iterations of the primal-dual algorithm followed by at most χ/i iterations of the successive shortest-path algorithm.
Proof: Let i ≥ 1.The statement is trivially true if the primal-dual algorithm returns a feasible solution after at most i iterations.So assume that more than i iterations are necessary.Let r := b fi (s) be the sum of the residual capacities of the arcs leaving s after iteration i.Since in each of the following iterations at least one unit of flow is sent to t it follows that the successive shortest-path algorithm will finish within at most r iterations.On the other hand, since there is a feasible flow on N , all arcs incident to s have to be saturated at the end.Augmenting one unit of flow augments the total cost of a flow by at least the original cost of a shortest s-t-path in the residual network.Note that distance from s to t in the residual network cannot decrease after an iteration.Hence, χ ≥ r • dist fi,π0 (s, t).By Lemma 2, we have dist fi,π0 (s, t) ≥ i, hence χ ≥ r • i.Thus, at most r ≤ χ/i shortest-path computations have to be performed after the ith iteration of the primal-dual algorithm.
Note that an iteration of the primal-dual algorithm augments the flow f by at least the amount the successive shortest-path algorithm does.Hence, we can bound the number of iterations of the pure primal-dual algorithm as follows.
Corollary 1 Let i ≥ 1 be an integer.If there is a feasible flow on N of cost at most χ then the primal-dual algorithm terminates after at most i+χ/i iterations.
Corollary 2 Let there be a feasible flow on N and let χ be the minimum cost of a flow on N .Then the primal-dual algorithm terminates after at most 2• √ χ+1 iterations.
Proof: If χ = 0 then the algorithm terminates after at most 1 iteration.Otherwise, let i be such that i − 1 < √ χ ≤ i.Then the total number of iterations In a network with n vertices and O(n) arcs the shortest-path problem can be solved in O(n log n) time using the algorithm of Dijkstra [12], while the max flow problem can be solved in O(n log 3 n) time if the underlying network without s, t is planar [6].So we have the following first result.Since the number of bends in an orthogonal drawing and, hence, the cost of the flow in the corresponding min-cost flow network is in O(n) [3], it follows that the bend-minimization problem can be solved in O(n 3/2 log 3 n) time, even if the number of bends on some edges is restricted.In the next section, we give a divide and conquer approach that directly solves the uncapacitated bend minimization problem utilizing only less recent results.

A Recursive Approach
In this section, we show how to utilize a planar separator theorem to recursively solve the min-cost flow problem.To make our algorithm work, we need a connected separator and so we make use of the cycle separator.
Let an assignment of non-negative weights to the vertices, faces, and edges of a plane graph G be given that sum to one.A simple cycle C of G is a weighted cycle separator of G if both, the weight of the interior of C and the weight of the exterior of C do not exceed 2/3.
Miller [26] showed that every biconnected planar graph with n vertices and face degree at most d has a simple cycle separator with at most 2 √ d • n vertices unless there is a face with weight higher than 2/3.Moreover, such a cycle separator can be constructed in linear time.Note that the min-cost flow problem decomposes into independent subproblems for each biconnected component.
This yields the following recursive algorithm for constructing a min-cost flow on a flow network N = (D = (W, A), u, b, c) where D is a plane digraph with O(n) nodes and arcs.
First, we find a small cycle separator C : v 1 , . . ., v of D. Let W 1 be the set of nodes in the interior of C and let W 2 be the set of nodes in the exterior of C. Let A i be the set of arcs of A that are incident to at least one node of W i .See Fig. 3(a) for an illustration.Let D i = (W i ∪ { Ĉ}, A i ), i = 1, 2 be obtained from the subgraph of D induced by W i ∪ C by shrinking C to a single node Ĉ maintaining all arcs between W i and C with their respective costs and capacities.See Fig. 3(b) for an illustration.For a subset We now recursively solve the two min-cost flow problems To merge the two solutions, we first set π( Ĉ) = max{π 1 ( Ĉ), π 2 ( Ĉ)} adjusting the potential in the respective components.See Algorithm 2, Lines 4-6.Now we have a feasible flow with a valid node potential on D/C.See Fig. 3(c) for an illustration.We now expand C vertex by vertex assigning the nodes on C the current potential of Ĉ.More precisely, for 2 < i ≤ let D/C i be obtained from D by shrinking C i = {v 1 , . . ., v i } to a single node Ĉi with demand b(C i ).Assume that we have computed a flow f with a valid node potential π of D/C i .Expanding v i means extending f and π to D/C i−1 by setting the flow on the arcs between v i and C i−1 to be zero and π(v i ) = π( Ĉi−1 ) = π( Ĉi ).See Fig. 3(d) for an illustration.This yields a pseudo-flow with a valid node potential, however, the deficiencies on v i and Ĉi−1 might be different from zero.To adjust the deficiencies, we run the primal-dual algorithm on the residual network.This yields a flow on N with a valid node potential and, hence, a min-cost flow on D. The algorithm is summarized in Algorithm 2.
Note that the max flow within the primal-dual algorithm does only have to be performed between v i and Ĉi−1 .Hence, there is no need for neither a super source nor a super sink and thus planarity is preserved.Moreover, v i and Ĉi−1 lie on the same face.Such a max flow computation can be done in linear time [19,20].The same holds for the shortest path computation [20] because we maintain a valid node potential, i.e. non-negative reduced cost.Proof: Let m be the number of arcs in the flow network.We may assume that the network is connected and, hence, that m ∈ Θ(n).If the network is not biconnected, we first use the cut nodes as separators in the recursive algorithm.Since there is no expansion step, the combination of the recursive solutions of the biconnected components takes only constant time.
So assume now that the network is biconnected.Let all arcs have weight 1/m and let all faces and nodes have weight zero.Then the algorithm of Miller [26] constructs in linear time a cycle separator C with O( √ d • n) nodes such that both, the interior and the exterior of C contain at most 2/3 • m arcs.Let c max be the maximum cost of an arc.Note that when expanding v i then the only sources and sinks are v i and Ĉi−1 and there is an arc between the two of them in both directions with infinite capacity.Hence, the equivalent min-cost maxflow network remains planar and in all residual networks the length of a shortest path with respect to the original costs is at most c max .Hence, the primal-dual algorithm has to perform at most c max max flow operations (Lemma 2) before pushing the remaining deficiency directly over the arc incident to v i and Ĉi−1 .It follows that O(c max √ d • n) max flow computations between two adjacent nodes of a planar graph have to be performed.Hence, each recursive step can be performed in O(c max √ dn 3/2 ) = O(c max √ dm 3/2 ).Thus, the run time T (m) fulfills the recursion Note that Theorem 2 remains true if the arc costs are not bounded in general and Algorithm 2 chooses separators that are not necessarily cycles but induce connected bidirected subgraphs with arc costs at most c max .

Corollary 3
The bend-minimization problem on a plane graph with degree at most four and n vertices can be solved in O(n 3/2 ) time.
Proof: Let G = (V, E) be a plane graph with n vertices and with degree at most four and let Hence, each call of the primal-dual algorithm within Algorithm 2 performs one max flow operation on two adjacent nodes and pushes the remaining deficiency over the corresponding cycle arc.Hence, each recursive step and thus, the whole algorithm can be performed in O(n 3/2 ) time.
If we wish to constrain the number of bends on an edge artificially, we may sacrifice a log-factor and use the result in [6] to obtain the following.First the graph is triangulated with arcs that have zero capacity.Within the recursion, we do not expand the cycle separator node after node, but we expand it at once.Let N be the residual network at this stage of the algorithm.Observe that the nodes with deficiency other than zero are all on a path.Hence, the max flow problem within the primal-dual algorithm is solvable in O(m log 2 m) time using the efficient implementation of [6].
Assume now that we perform √ m/ log m times an ordinary iteration of the primal-dual algorithm.Let χ i , i = 1, 2 be the minimum costs of the two recursive solutions and let χ 3 = χ − χ 1 − χ 2 be the minimum cost of a flow in N .By Lemma 3, at most χ 3 /( √ m/ log m) additional shortest path computations have to be performed during the merge step, each of which can be done in linear time [32].

Corollary 4
The bend-minimization problem on a plane graph with degree at most four and n vertices can be solved in O(n 3/2 log n) time even if the number of bends per edge is bounded by some upper bounds u : A → Z ≥0 , provided that the bounds still admit an orthogonal drawing with a linear number of bends.

Figure 2 :
Figure2: Illustration of the approach of Tamassia[30] for solving the bendminimization problem.In b) the directed arcs indicate the flow network.All arcs have infinite capacity, the bidirected blue arcs have cost one and the unidirected red arcs have costs zero.The node demands are indicated in brackets.
inner face and b(h o ) = −4 − deg h o for the outer face h o .For each edge e = {v, w} ∈ E with (v, w) ∈ E(h) and (w, v) ∈ E(g) the arc set A G contains the arcs (v, h) e , (w, g) e with costs zero and (h, g) e , (g, h) e with costs one.All arcs have infinite capacities.Note that the index e is only used to distinguish possible multiple arcs.See Fig. 2(b), for an illustration.Now a min-cost flow f on N G corresponds to an orthogonal representation with the minimum number of bends as follows.For each edge e = {v, w} ∈

Algorithm 1 :
Primal-Dual Algorithm Input : min-cost flow network N = (D = (W, A), u, b, c).Output: min-cost max flow f of N st with valid node potential π, both initialized to 0 Primal-Dual(D, u, b, c)

Theorem 1
The primal-dual algorithm computes a flow with minimum cost χ on a planar min-cost flow network with n nodes and with O(n) arcs in O( √ χn log 3 n) time.

Figure 3 :
Figure 3: Illustration of Algorithm 2. a) W 1 and A 1 denote the set of black nodes and arcs inside the red cycle C, W 2 and A 2 the blue nodes and arcs outside cycle C.

Algorithm 2 :
2 has a feasible flow if N has a feasible flow: Let f be a feasible flow on N .Clearly, f induces a flow on the graph D/C obtained from D by shrinking C to a single node Ĉ with demand b(C).Note that D 1 is obtained from D/C by deleting W 2 and all its incident arcs.Let f (C, W 2 ) be the amount of flow on the arcs from C to W 2 minus the amount of flow from W 2 to C. Then f (C, W 2 ) = b(W 1 ) + b(C).So if we set b( Ĉ) = b(C) − f (C, W 2 ) = −b(W 1 ) then f induces a flow on D 1 .JGAA, 16(3) 635-650 (2012) 645 Recursive Min-Cost Flow Input : min-cost flow network N = (D = (W, A), u, b, c) admitting a flow.Output: min-cost flow f on N and valid node potential π, both init.to 0. 1 Min-Cost-Flow(D, u, b, c)

Theorem 2
The recursive min-cost flow algorithm described in Algorithm 2 computes a min-cost flow on a planar bidirected uncapacitated min-cost flow network with n nodes, O(n) arcs, arc costs at most c max , and face degrees at most d in O(c max √ dn 3/2 ) time.
u, b, c) be the min-cost flow network for the bend-minimization problem.Let m = |A G |.Note that m ∈ Θ(n).For computing the cycle separator in the recursive min-cost flow algorithm, we only consider the subgraph D F induced by the face nodes.Recall that D F is bidirected and that this is sufficient for the expansion argument.We assign each arc of D F the weight 1/m and each face h of D F the weight deg f /m while the nodes obtain zero weight.Now the cycle separator of D F constructed by the algorithm of Miller [26] is a cycle separator C of the whole graph with O( √ n) nodes such that both, the interior and the exterior of C contain at most 2/3 • m arcs.Moreover the arcs on C are bidirected uncapacitated and have unit cost.

Theorem 3 A
minimum flow on a planar min-cost flow network with n nodes and with O(n) arcs can be computed in O(n 3/2 log n) time provided that the total cost χ of the flow is in O(n).Proof: We prove more generally that a flow of minimum cost χ on a planar mincost flow network with m arcs can be computed in O(m 3/2 log m + χ √ m log m) time.