# Efficient Algorithms for Bend-minimum Orthogonal Drawings of Planar 3-Graphs

Let G be a planar 3-graph (i.e., a planar graph with vertex degree at most three) with n vertices. We prove that a planar orthogonal drawing of G with the minimum number of bends can be computed in O(n^2) time. The minimum is taken over all planar embeddings of G. The most efficient known algorithm to solve this problem has complexity Õ(n^17/7), as proved by Chang and Yen for biconnected planar 3-graphs [SoCG Proc., 2017]. If either a distinguished edge or a distinguished vertex of G is constrained to be on the external face, a bend-minimum orthogonal drawing of G that respects the given constraint can be computed in O(n) time. An additional feature of our algorithms is that they compute drawings with at most two bends per edge, which is worst-case optimal.

## Authors

• 14 publications
• 24 publications
• 15 publications
• ### Optimal Orthogonal Drawings of Planar 3-Graphs in Linear Time

A planar orthogonal drawing Γ of a planar graph G is a geometric represe...
10/25/2019 ∙ by Walter Didimo, et al. ∙ 0

• ### Universal Slope Sets for Upward Planar Drawings

We prove that every set S of Δ slopes containing the horizontal slope i...
03/27/2018 ∙ by Michael A. Bekos, et al. ∙ 0

• ### Extremal solutions to some art gallery and terminal-pairability problems

The chosen tool of this thesis is an extremal type approach. The lesson ...
08/29/2017 ∙ by Tamás Róbert Mezei, et al. ∙ 0

• ### Orthogonal and Smooth Orthogonal Layouts of 1-Planar Graphs with Low Edge Complexity

While orthogonal drawings have a long history, smooth orthogonal drawing...
08/30/2018 ∙ by Evmorfia Argyriou, et al. ∙ 0

• ### A linear time algorithm for constructing orthogonal floor plans with minimum number of bends

Let G = (V, E) be a planar triangulated graph (PTG) having every face tr...
06/25/2020 ∙ by Pinki, et al. ∙ 0

• ### On Turn-Regular Orthogonal Representations

An interesting class of orthogonal representations consists of the so-ca...
08/20/2020 ∙ by Michael A. Bekos, et al. ∙ 0

• ### Colored Point-set Embeddings of Acyclic Graphs

We show that any planar drawing of a forest of three stars whose vertice...
08/30/2017 ∙ by Emilio Di Giacomo, et al. ∙ 0

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

A pioneering paper by Storer [21] asks whether a crossing-free orthogonal drawing with the minimum number of bends can be computed in polynomial time. The question posed by Storer is in the fixed embedding setting, i.e., the input is a plane 4-graph (an embedded planar graph with vertex degree at most four) and the wanted output is an embedding-preserving orthogonal drawing with the minimum number of bends. Tamassia [22] answers Storer’s question in the affirmative by describing an -time algorithm. The key idea of Tamassia’s result is the equivalence between the bend minimization problem and the problem of computing a min-cost flow on a suitable network. To date, the most efficient known solution of the bend-minimization problem for orthogonal drawings in the fixed embedding setting is due to Cornelsen and Karrenbauer [6], who show a novel technique to compute a min-cost flow on an uncapacitated network and apply this technique to Tamassia’s model achieving -time complexity.

A different level of complexity for the bend minimization problem is encountered in the variable embedding setting, that is when the algorithm is asked to find a bend-minimum solution over all planar embeddings of the graph. For example, the orthogonal drawing of Fig. 1 has a different planar embedding than the graph of Fig. 1 and it has no bends, while the drawing of Fig. 1 preserves the embedding but it is suboptimal in terms of bends.

Garg and Tamassia [12] prove that the bend-minimization problem for orthogonal drawings is NP-complete for planar 4-graphs, while Di Battista et al. [8] show that it can be solved in time for planar 3-graphs. Generalizations of the problem in the variable embedding setting where edges have some flexibility (i.e., they can bend a few times without cost for the optimization function) have also been the subject of recent studies by Bläsius et al. [2].

Improving the time complexity of the algorithm by Di Battista et al. [8] has been an elusive open problem for more than a decade (see, e.g., [3]), until a paper by Chang and Yen [4] has shown how to compute a bend-minimum orthogonal drawing of a planar 3-graph in the variable embedding setting in time, which can be read as time for a positive constant .

Similar to [8], the approach in [4] uses an SPQR-tree to explore all planar embeddings of a planar 3-graph and combines partial solutions associated with the nodes of this tree to compute a bend-minimum drawing. Both in [8] and in [4], the computationally most expensive task is computing min-cost flows on suitable variants of Tamassia’s network. However, Chang and Yen elegantly prove that a simplified flow network where all edges have unit capacity can be adopted to execute this task. This, combined with a recent result [5] about min-cost flows on unit-capacity networks, yields the improved time complexity.

Contribution and outline. This paper provides new algorithms to compute bend-minimum orthogonal drawings of planar 3-graphs, which improve the time complexity of the state-of-the-art solution. We prove the following.

###### Theorem 1.1 ()

Let be an -vertex planar 3-graph. A bend-minimum orthogonal drawing of can be computed in time. If either a distinguished edge or a distinguished vertex of is constrained to be on the external face, a bend-minimum orthogonal drawing of that respects the given constraint can be computed in time. Furthermore, the computed drawings have at most two bends per edge, which is worst-case optimal.

As in [8] and in [4], the algorithmic approach of Theorem 1.1 computes a bend-minimum orthogonal drawing by visiting an SPQR-tree of the input graph. However, it does not need to compute min-cost flows at any steps of the visit, which is the fundamental difference with the previous techniques. This makes it possible to design the first quadratic-time algorithm to compute bend-minimum orthogonal drawings of planar 3-graphs in the variable embedding setting.

The second part of the statement of Theorem 1.1 extends previous studies by Nishizeki and Zhou [26], who give a first example of a linear-time algorithm in the variable embedding setting for planar 3-graphs that are partial two-trees. The bend-minimum drawings of Theorem 1.1 have at most two bends per edge, which is a desirable property for an orthogonal representation. We recall that every planar 4-graph (except the octahedron) has an orthogonal drawing with at most two bends per edge [1, 16], but minimizing the number of bends may require some edges with a bends [8, 23]. It is also proven that every planar 3-graph (except ) has an orthogonal drawing with at most one bend per edge [15], but the drawings of the algorithm in [15] are not bend-minimum. Finally, a non-flow based algorithm having some similarities with ours is given in [11]; it neither computes bend-minimum drawings nor guarantees at most two bends per edge.

The paper is organized as follows. Preliminary definitions and results are in Sec. 2. In Sec. 3 we prove key properties of bend-minimum orthogonal drawings of planar 3-graphs used in our approach. Sec. 4 describes our drawing algorithms. Open problems are in Sec. 5. Some (full) proofs are moved to the appendix.

## 2 Preliminaries

We assume familiarity with basic definitions on graph connectivity and planarity (see Appendix 0.A). If is a graph, and denote the sets of vertices and edges of . We consider simple graphs, i.e., graphs with neither self-loops nor multiple edges. The degree of a vertex , denoted as , is the number of its neighbors. denotes the maximum degree of a vertex of ; if (), is an -graph. A graph is rectilinear planar if it admits a planar drawing where each edge is either a horizontal or a vertical segment (i.e., it has no bend). Rectilinear planarity testing is NP-complete for planar -graphs [12], but it is polynomially solvable for planar -graphs [4, 8] and linear-time solvable for subdivisions of planar triconnected cubic graphs [17]. By extending a result of Thomassen [24] on those -graphs that have a rectilinear drawing with all rectangular faces, Rahman et al. [20] characterize rectilinear plane -graphs. For a plane graph , let be its external cycle ( is simple if is biconnected). Also, if is a simple cycle of , is the plane subgraph of that consists of and of the vertices and edges inside . An edge is a leg of if exactly one of the vertices and belongs to ; such a vertex is a leg-vertex of . If has exactly legs and no edge embedded outside joins two of its vertices, is a k-legged cycle of .

###### Theorem 2.1

[20] Let be a biconnected plane -graph. admits an orthogonal drawing without bends if and only if: contains at least four vertices of degree 2; each -legged cycle contains at least two vertices of degree 2; each -legged cycle contains at least one vertex of degree 2.

As in [20], we call bad any -legged and any -legged cycle that does not satisfy Condition and of Theorem 2.1, respectively.

SPQR-trees of Planar 3-Graphs. Let be a biconnected graph. An SPQR-tree of represents the decomposition of into its triconnected components and can be computed in linear time [7, 13, 14]. Each triconnected component corresponds to a node of ; the triconnected component itself is called the skeleton of and denoted as . A node of can be of one of the following types: R-node, if is a triconnected graph; S-node, if is a simple cycle of length at least three; P-node, if is a bundle of at least three parallel edges; Q-nodes, if it is a leaf of ; in this case the node represents a single edge of the graph and its skeleton consists of two parallel edges. Note that, neither two - nor two -nodes are adjacent in . A virtual edge in corresponds to a tree node adjacent to in . If is rooted at one of its Q-nodes , every skeleton (except the one of ) contains exactly one virtual edge that has a counterpart in the skeleton of its parent: This virtual edge is the reference edge of and of , and its endpoints are the poles of and of . The edge of corresponding to the root of is the reference edge of , and is the SPQR-tree of with respect to . For every node of , the subtree rooted at induces a subgraph of called the pertinent graph of , which is described by in the decomposition: The edges of correspond to the Q-nodes (leaves) of . Graph is also called a component of with respect to the reference edge , namely is a P-, an R-, or an S-component depending on whether is a P-, an R-, or an S-component, respectively.

The SPQR-tree rooted at a Q-node implicitly describes all planar embeddings of with the reference edge of on the external face. All such embeddings are obtained by combining the different planar embeddings of the skeletons of P- and R-nodes: For a P-node , the different embeddings of are the different permutations of its non-reference edges. If is an R-node, has two possible planar embeddings, obtained by flipping minus its reference edge at its poles. See Fig.2 for an illustration. The child node of and its pertinent graph are called the root child of and the root child component of , respectively. An inner node of is neither the root nor the root child of . The pertinent graph of an inner node is an inner component of . The next lemma gives basic properties of when .

###### Lemma 1 ()

Let be a biconnected planar -graph and let be the SPQR-tree of with respect to a reference edge . The following properties hold:

T1 Each P-node has exactly two children, one being an S-node and the other being an S- or a Q-node; if is the root child, both its children are S-nodes.

T2 Each child of an R-node is either an S-node or a Q-node.

T3 For each inner S-node , the edges of incident to the poles of are (real) edges of . Also, there cannot be two incident virtual edges in .

## 3 Properties of Bend-Minimum Orthogonal Representations of Planar 3-Graphs

We prove relevant properties of bend-minimum orthogonal drawings of planar -graphs that are independent of vertex and bend coordinates, but only depend on the vertex angles and edge bends. To this aim, we recall the concept of orthogonal representation [22] and define some types of “shapes” that we use to construct bend-minimum orthogonal representations.

Orthogonal Representations. Let be a plane -graph. If and if and are two (possibly coincident) edges incident to that are consecutive in the clockwise order around , we say that is an angle at of or simply an angle of . Let and be two embedding-preserving orthogonal drawings of . We say that and are equivalent if: For any angle of , the geometric angle corresponding to is the same in and , and for any edge of , the sequence of left and right bends along moving from to is the same in and in . An orthogonal representation of is a class of equivalent orthogonal drawings of ; can be described by the embedding of together with the geometric value of each angle of (, , degrees)111Angles of degrees only occur at 1-degree vertices; we can avoid to specify them. and with the sequence of left and right bends along each edge. Figure 3 shows a bend-minimum orthogonal representation of the graph in Fig. 2.

Let be a path between two vertices and in . The turn number of is the absolute value of the difference between the number of right and the number of left turns encountered along moving from to (or vice versa). The turn number of is denoted by . A turn along is caused either by a bend on an edge of or by an angle of degrees at a vertex of . For example, for the path in the orthogonal representation of Fig. 3. We remark that if is a bend-minimum orthogonal representation, the bends along an edge, going from an end-vertex to the other, are all left or all right turns [22].

Shapes of Orthogonal Representations. Let be a biconnected planar -graph, be the SPQR-tree of with respect to a reference edge , and be an orthogonal representation of with on the external face. For a node of , denote by the restriction of to a component . We also call a component of . In particular, is a P-, an R-, or an S-component depending on whether is a P-, an R-, or an S-component, respectively. If is the root child of , then is the root child component of . Denote by and the two poles of and let and be the two paths from to on the external boundary of , one walking clockwise and the other walking counterclockwise. These paths are the contour paths of . If is an S-node, and share some edges (they coincide if is just a sequence of edges). If is either a P- or an R-node, and are edge disjoint; in this case, we define the following shapes for , depending on and and where the poles are external corners:

is C-shaped, or -shaped, if and , or vice versa;

is D-shaped, or  -shaped, if and , or vice versa;

is L-shaped, or -shaped, if and , or vice versa;

is X-shaped, or -shaped, if .

For example, in Fig. 3 is -shaped, while in Fig. 3 is  -shaped. Concerning S-components, the following lemma rephrases a result in [8, Lemma 4.1], and it is also an easy consequence of Property T3 in Lemma 1.

###### Lemma 2

Let be an inner S-component with poles and and let and be any two paths connecting and in . Then .

Based on Lemma 2, we describe the shape of an inner S-component in terms of the turn number of any path between its two poles: We say that is -spiral and has spirality if . The notion of spirality of an orthogonal component was introduced in [8]. Differently from [8], we restrict the definition of spirality to inner S-components and we always consider absolute values, instead of both positive and negative values depending on whether the left turns are more or fewer than the right turns. For instance, in the representation of Fig. 3 the two series with poles (the two filled S-nodes in Fig. 2) have spirality three and one, respectively; the series with poles (child of the R-node) has spirality zero, while the series with poles has spirality two.

We now give a key result that claims the existence of a bend-minimum orthogonal representation with specific properties for any biconnected planar -graph. This result will be used to design our drawing algorithm. Given an orthogonal representation , we denote by the orthogonal representation obtained from by replacing each bend with a dummy vertex: is the rectilinear image of ; a dummy vertex in is a bend vertex. Also, if is a degree- vertex with neighbors and , smoothing is the reverse operation of an edge subdivision, i.e., it replaces the two edges and with the single edge .

###### Lemma 3 ()

A biconnected planar -graph with a distinguished edge has a bend-minimum orthogonal representation with on the external face such that:

O1 Every edge of has at most two bends, which is worst-case optimal.

O2 Every inner P-component or R-component of is either - or  -shaped.

O3 Every inner S-component of has spirality at most four.

###### Proof (sketch)

We prove in three steps the existence of a bend-minimum orthogonal representation that satisfies O1-O3. We start by a bend-minimum orthogonal representation of with on the external face, and in the first step we prove that it either satisfies O1 or it can be locally modified, without changing its planar embedding, so to satisfy O1. In the second step, we prove that from the orthogonal representation obtained in the first step we can derive a new orthogonal representation (still with same embedding) that satisfies O2 in addition to O1. Finally, we prove that this last representation also satisfies O3.

Step 1: Property O1. Suppose that is a bend-minimum orthogonal representation of with on the external face and having an edge (possibly ) with at least three bends. Let be the rectilinear image of , and let be the plane graph underlying . Since has no bend, satisfies Conditions  of Theorem 2.1. Let , , be three bend vertices in that correspond to three bends of in . Assume first that is an internal edge of and let be the plane graph obtained from by smoothing . We claim that still satisfies Conditions  of Theorem 2.1. Indeed, if this is not the case, there must be a bad cycle in that contains both and . This is a contradiction, because no bad cycle can contain two vertices of degree two. Hence, there exists an (embedding-preserving) representation of without bends, which is the rectilinear image of an orthogonal representation of with fewer bends than , a contradiction. Assume now that is on the external cycle of . If contains more than four vertices of degree two, we can smooth and apply the same argument as above to contradict the optimality of (note that, such a smoothing does not violate Condition of Theorem 2.1). Suppose vice versa that contains exactly four vertices of degree two (three of them being , , and ). In this case, just smoothing violates Condition  of Theorem 2.1. However, we can smooth and subdivide an edge of (such an edge exists since has at least three edges and, by hypothesis and a simple counting argument, at least one of its edges has no bend in ). The resulting plane graph still satisfies the three conditions of Theorem 2.1 and admits a representation without bends; the representation of which is the rectilinear image is a bend-minimum orthogonal representation of with at most two bends per edge. To see that two bends per edge is worst-case optimal, just consider a bend-minimum representation of the complete graph .

Step 2: Property O2. Let be a bend-minimum orthogonal representation of that satisfies O1 and let be its rectilinear image. The plane underlying graph of satisfies the three conditions of Theorem 2.1. Rhaman, Nishizeki, and Naznin [20, Lemma 3] prove that, in this case, has an embedding-preserving orthogonal representation without bends in which every -legged cycle is either -shaped or  -shaped, where the two poles of the shape are the two leg-vertices of . On the other hand, if is an inner P- or R-component, the external cycle is a -legged cycle of , where the two leg-vertices of are the poles of . Hence, the representation of whose rectilinear image is satisfies O2, as is either -shaped or  -shaped. Also, the bends of are the same as in , because the bend vertices of coincide with those of . Hence, still satisfies O1 and has the minimum number of bends.

Step 3: Property O3. Suppose now that is a bend-minimum orthogonal representation of (with on the external face) that satisfies both O1 and O2. More precisely, assume that is the orthogonal representation obtained in the previous step, where its rectilinear image is computed by the algorithm of Rhaman et al. [20]. By a careful analysis of how this algorithm works, we prove that each series gets spirality at most four in (see Appendix 0.B).

## 4 Drawing Algorithm

Let be a biconnected 3-planar graph with a distinguished edge and let be the SPQR-tree of with respect to . Sec. 4.1 gives a linear-time algorithm to compute bend-minimum orthogonal representations of the inner components of . Sec. 4.2 handles the root child of to complete a bend-minimum representation with on the external face and it proves Theorem 1.1. Lemma 3 allows us to restrict our algorithm to search for a representation satisfying Properties O1-O3.

### 4.1 Computing Orthogonal Representations for Inner Components

Let be the SPQR-tree of with respect to reference edge  and let  be an inner node of . A key ingredient of our algorithm is the concept of ‘equivalent’ orthogonal representations of . Intuitively, two representations of are equivalent if one can replace the other in any orthogonal representation of . Similar equivalence concepts have have been used for orthogonal drawings [8, 10]. As we shall prove (see Theorem 4.1), for planar -graphs a simpler definition of equivalent representations suffices. If is a P- or an R-node, two representations and are equivalent if they are both  -shaped or both -shaped. If is an inner S-node, and are equivalent if they have the same spirality.

###### Lemma 4 ()

If and are two equivalent orthogonal representations of , the two contour paths of have the same turn number as those of .

Suppose that is an inner component of with poles and , and let and be the contour paths of . Replacing in with an equivalent representation means to insert in in place of , in such a way that: if and are  -shaped, the contour path of for which is traversed clockwise from to on the external boundary of (as for on the external boundary of ); in all cases, the external angles of at and are the same as in . This operation may require to mirror (see Fig. 4). The next theorem uses arguments similar to [8].

###### Theorem 4.1 ()

Let be an orthogonal representation of a planar 3-graph and be the restriction of to , where is an inner component of the SPQR-tree of  with respect to a reference edge . Replacing in with an equivalent representation yields a planar orthogonal representation of .

We are now ready to describe our drawing algorithm. It is based on a dynamic programming technique that visits bottom-up the SPQR-tree with respect to the reference edge of . Based on Lemma 3 and Theorem 4.1, the algorithm stores for each visited node of a set of candidate orthogonal representations of , together with their cost in terms of bends. For a Q-node, the set of candidate orthogonal representations consists of three representations, with 0, 1, and 2 bends, respectively. This suffices by Property O1. For a P- or an R-node, the set of candidate representations consists of a bend-minimum  -shaped and a bend-minimum -shaped representation. This suffices by Property O2. For an S-node, the set of candidate representations consists of a bend-minimum representation for each value of spirality . This suffices by Property O3. In the following we explain how to compute the set of candidate representations for a node that is a P-, an S-, or an R-node (computing the set of a Q-node is trivial). To achieve overall linear-time complexity, the candidate representations stored at are described incrementally, linking the desired representation in the set of the children of for each virtual edge of .

Candidate Representations for a P-node. By property T1 of Lemma 1, has two children and , where is an S-node and is an S-node or a Q-node. The cost of the -shaped representation of is the sum of the costs of and both with spirality one. The cost of the  -shaped representation of is the minimum between the cost of with spirality two and the cost of with spirality two. This immediately implies the following.

###### Lemma 5

Let be an inner P-node. There exists an -time algorithm that computes a set of candidate orthogonal representations of , each having at most two bends per edge.

Candidate Representations for an S-node. By property T3 of Lemma 1, without its reference edge is a sequence of edges such that the first edge and the last edge are real (they correspond to Q-nodes) and at most one virtual edge, corresponding to either a P- or an R-node, appears between two real edges. Let be the sum of the costs of the cheapest (in terms of bends) orthogonal representations of all P-nodes and R-nodes corresponding to the virtual edges of . By Property O2, each of these representations is either  - or -shaped. Let be the number of edges of that correspond to Q-nodes and let be the number of edges of that correspond to P- and R-nodes whose cheapest representation is  -shaped. Obviously, any bend-minimum orthogonal representation of satisfying O2 has cost at least . We have the following.

###### Lemma 6 ()

An inner S-component admits a bend-minimum orthogonal representation respecting Properties O1-O3 and with cost if its spirality and with cost if .

Note that the possible presence in of virtual edges corresponding to P- and R-nodes whose cheapest representation is -shaped does not increase the spirality reachable at cost by the S-node. Lemma 6 also provides an alternative proof of a known result ([8, Lemma 5.2]), stating that for a planar -graph the number of bends of a bend-minimum -spiral representation of an inner S-component does not decrease when increases. Moreover, since for an inner S-component , a consequence of Lemma 6 is Corollary 1. It implies that every bend-minimum -spiral representation of an inner S-component does not require additional bends with respect to the bend-minimum representations of their subcomponents when .

###### Corollary 1

For each , every inner S-component admits a bend-minimum orthogonal representation of cost with spirality .

###### Lemma 7 ()

Let be an inner S-node and be the number of vertices of . There exists an -time algorithm that computes a set of candidate orthogonal representations of , each having at most two bends per edge.

Candidate Representations for an R-node. If is an R-node, its children are S- or Q-nodes (Property T2 of Lemma 1). To compute a bend-minimum orthogonal representation of that satisfies Properties O1-O3, we devise a variant of the linear-time algorithm by Rahman, Nakano, and Nishizeki [18] that exploits the properties of inner S-components.

###### Lemma 8 ()

Let be an inner R-node and be the number of vertices of . There exists an -time algorithm that computes a set of candidate orthogonal representations of , each having at most two bends per edge.

###### Proof (sketch)

Let be the poles of . Our algorithm works in two steps. First, it computes an -shaped orthogonal representation and a  -shaped orthogonal representation of , with a variant of the recursive algorithm in [18]. Then, it computes a bend-minimum -shaped representation and a bend-minimum  -shaped representation of , by replacing each virtual edge in each of and with the representation in the set of the corresponding S-node whose spirality equals the number of bends of . Every time the algorithm needs to insert a degree- vertex along an edge of a bad cycle, it adds this vertex on a virtual edge, if such an edge exists. By Corollary 1, this vertex does not cause an additional bend in the final representation when the virtual edge is replaced by the corresponding S-component.

### 4.2 Handling the Root Child Component

Let be the SPQR-tree of with respect to edge and let be the root child of . Assuming to have already computed the set of candidate representations for the children of , we compute an orthogonal representation of and a bend-minimum orthogonal representation of (with on the external face) depending on the type of .

Algorithm P-root-child. Let be a P-node with children and . By Property T1 of Lemma 1, both and are S-nodes. Let () be the maximum spirality of a representation () at the same cost () as a -spiral representation. W.l.o.g., let . We have three cases:

Case 1: . Compute a -shaped by merging a -spiral and a -spiral representation of and , respectively; add with bends to get  (Fig. 6).

Case 2: . Compute an -shaped by merging a -spiral and a -spiral representation of and , respectively; add with bend to get  (Fig. 6).

Case 3: or . Compute a  -shaped by merging a -spiral and a -spiral representation of and , respectively; add with bends to get  (Figs. 66).

###### Lemma 9 ()

P-root-child computes a bend-minimum orthogonal representation of with on the external face and at most two bends per edge in  time.

Algorithm S-root-child. Let be an S-node. if starts and ends with one edge, we compute the candidate orthogonal representations of as if it were an inner S-node, and we obtain by adding with zero bends to the -spiral representation of (Fig. 6). Else, if only starts or ends with one edge, we add to the other end of , compute the candidate representations of as if it were an inner S-node, and obtain by adopting the representation of with spirality and by identifying the first and last vertex (Fig. 6). Finally, if starts and ends with an R- or a P-node, we add two copies , of at the beginning and at the end of , compute the candidate representations of as if it were an inner S-node, and obtain from the representation of with spirality , by identifying the first and last vertex of and by smoothing the resulting vertex (Fig. 6).

###### Lemma 10 ()

S-root-child computes a bend-minimum orthogonal representation of with on the external face and at most two bends per edge in  time, where is the number of vertices of .

Algorithm R-root-child. Let be an R-node and let and be the two planar embeddings of obtained by choosing as external face one of those incident to . For each , compute an orthogonal representation of by: finding a representation of (included ) with the variant of [18] given in the proof of Lemma 8, but this time assuming that all the four designated corners of the external face in the initial step must be found; replacing each virtual edge that bends times in with a minimum-bend -spiral representation of its corresponding S-component. is the cheapest of and . Since the variant of [18] applied to still causes at most two bends per edge, with the same arguments as in Lemma 8 we have:

###### Lemma 11

R-root-child computes a bend-minimum orthogonal representation of with on the external face and at most two bends per edge in  time, where be the number of vertices of .

Proof of Theorem 1.1. If is biconnected, Lemmas 578911 yield an -time algorithm that computes a bend-minimum orthogonal representation of with a distinguished edges on the external face and at most two bends per edge. Call BendMin-RefEdge this algorithm. An extension of BendMin-RefEdge to a simply-connected graph , which still runs in time, is easily derivable by exploiting the block-cut-vertex tree of (see Appendix 0.C). Running BendMin-RefEdge for every possible reference edge, we find in time a bend-minimum orthogonal representation of over all its planar embeddings. If is a distinguished vertex of , running BendMin-RefEdge for every edge incident to , we find in time a bend-minimum orthogonal representation of with on the external face (recall that ). Finally, an orthogonal drawing of is computed in time from an orthogonal representation of  [7].

## 5 Open Problems

We suggest two research directions related to our results: (i) Is there an -time algorithm to compute a bend-minimum orthogonal drawing of a 3-connected planar cubic graph, for every possible choice of the external face? (ii) It is still unknown whether an -time algorithm for the bend-minimization problem in the fixed embedding setting exists [9]. This problem could be tackled with non-flow based approaches. A positive result in this direction is given in [19] for plane 3-graphs.

## References

• [1]

Biedl, T.C., Kant, G.: A better heuristic for orthogonal graph drawings. Comput. Geom.

9(3), 159–180 (1998). https://doi.org/10.1016/S0925-7721(97)00026-6
• [2] Bläsius, T., Rutter, I., Wagner, D.: Optimal orthogonal graph drawing with convex bend costs. ACM Trans. Algorithms 12(3), 33:1–33:32 (2016). https://doi.org/10.1145/2838736
• [3] Brandenburg, F., Eppstein, D., Goodrich, M.T., Kobourov, S.G., Liotta, G., Mutzel, P.: Selected open problems in graph drawing. In: Liotta, G. (ed.) Graph Drawing, 11th International Symposium, GD 2003, Perugia, Italy, September 21-24, 2003, Revised Papers. Lecture Notes in Computer Science, vol. 2912, pp. 515–539. Springer (2003). https://doi.org/10.1007/978-3-540-24595-7_55
• [4] Chang, Y., Yen, H.: On bend-minimized orthogonal drawings of planar 3-graphs. In: Aronov, B., Katz, M.J. (eds.) 33rd International Symposium on Computational Geometry, SoCG 2017, July 4-7, 2017, Brisbane, Australia. LIPIcs, vol. 77, pp. 29:1–29:15. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik (2017). https://doi.org/10.4230/LIPIcs.SoCG.2017.29, http://www.dagstuhl.de/dagpub/978-3-95977-038-5
• [5] Cohen, M.B., Madry, A., Tsipras, D., Vladu, A.: Matrix scaling and balancing via box constrained newton’s method and interior point methods. In: Umans, C. (ed.) 58th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2017, Berkeley, CA, USA, October 15-17, 2017. pp. 902–913. IEEE Computer Society (2017). https://doi.org/10.1109/FOCS.2017.88, http://ieeexplore.ieee.org/xpl/mostRecentIssue.jsp?punumber=8100284
• [6] Cornelsen, S., Karrenbauer, A.: Accelerated bend minimization. J. Graph Algorithms Appl. 16(3), 635–650 (2012). https://doi.org/10.7155/jgaa.00265
• [7] Di Battista, G., Eades, P., Tamassia, R., Tollis, I.G.: Graph Drawing: Algorithms for the Visualization of Graphs. Prentice-Hall (1999)
• [8] Di Battista, G., Liotta, G., Vargiu, F.: Spirality and optimal orthogonal drawings. SIAM J. Comput. 27(6), 1764–1811 (1998). https://doi.org/10.1137/S0097539794262847
• [9] Di Giacomo, E., Liotta, G., Tamassia, R.: Graph drawing. In: Goodman, J., O’Rourke, J., Toth, C. (eds.) Handbook of Discrete and Computational Geometry, Third Edition, pp. 1451–1477. Chapman and Hall/CRC (2017)
• [10] Didimo, W., Liotta, G., Patrignani, M.: On the complexity of HV-rectilinear planarity testing. In: Duncan, C., Symvonis, A. (eds.) Proc. 22nd International Symposium on Graph Drawing (GD ’14). Lecture Notes in Computer Science, vol. 8871, pp. 343–354 (2014). https://doi.org/10.1007/978-3-662-45803-7_29
• [11] Garg, A., Liotta, G.: Almost bend-optimal planar orthogonal drawings of biconnected degree-3 planar graphs in quadratic time. In: Kratochvíl, J. (ed.) Graph Drawing, 7th International Symposium, GD’99, Stirín Castle, Czech Republic, September 1999, Proceedings. Lecture Notes in Computer Science, vol. 1731, pp. 38–48. Springer (1999). https://doi.org/10.1007/3-540-46648-7_4
• [12] Garg, A., Tamassia, R.: On the computational complexity of upward and rectilinear planarity testing. SIAM J. Comput. 31(2), 601–625 (2001). https://doi.org/10.1137/S0097539794277123
• [13] Gutwenger, C., Mutzel, P.: A linear time implementation of SPQR-trees. In: Marks, J. (ed.) Graph Drawing, 8th International Symposium, GD 2000, Colonial Williamsburg, VA, USA, September 20-23, 2000, Proceedings. Lecture Notes in Computer Science, vol. 1984, pp. 77–90. Springer (2000). https://doi.org/10.1007/3-540-44541-2_8
• [14] Hopcroft, J.E., Tarjan, R.E.: Dividing a graph into triconnected components. SIAM J. Comput. 2(3), 135–158 (1973). https://doi.org/10.1137/0202012
• [15] Kant, G.: Drawing planar graphs using the canonical ordering. Algorithmica 16(1), 4–32 (1996). https://doi.org/10.1007/BF02086606
• [16] Liu, Y., Morgana, A., Simeone, B.: A linear algorithm for 2-bend embeddings of planar graphs in the two-dimensional grid. Discrete Applied Mathematics 81(1-3), 69–91 (1998). https://doi.org/10.1016/S0166-218X(97)00076-0
• [17] Rahman, M.S., Egi, N., Nishizeki, T.: No-bend orthogonal drawings of subdivisions of planar triconnected cubic graphs. IEICE Transactions 88-D(1), 23–30 (2005)
• [18] Rahman, M.S., Nakano, S., Nishizeki, T.: A linear algorithm for bend-optimal orthogonal drawings of triconnected cubic plane graphs. J. Graph Algorithms Appl. 3(4), 31–62 (1999), http://www.cs.brown.edu/publications/jgaa/accepted/99/SaidurNakanoNishizeki99.3.4.pdf
• [19] Rahman, M.S., Nishizeki, T.: Bend-minimum orthogonal drawings of plane 3-graphs. In: Kucera, L. (ed.) Graph-Theoretic Concepts in Computer Science, 28th International Workshop, WG 2002, Cesky Krumlov, Czech Republic, June 13-15, 2002, Revised Papers. Lecture Notes in Computer Science, vol. 2573, pp. 367–378. Springer (2002). https://doi.org/10.1007/3-540-36379-3_32
• [20] Rahman, M.S., Nishizeki, T., Naznin, M.: Orthogonal drawings of plane graphs without bends. J. Graph Algorithms Appl. 7(4), 335–362 (2003), http://jgaa.info/accepted/2003/Rahman+2003.7.4.pdf
• [21]

Storer, J.A.: The node cost measure for embedding graphs on the planar grid (extended abstract). In: Miller, R.E., Ginsburg, S., Burkhard, W.A., Lipton, R.J. (eds.) Proceedings of the 12th Annual ACM Symposium on Theory of Computing, April 28-30, 1980, Los Angeles, California, USA. pp. 201–210. ACM (1980).

https://doi.org/10.1145/800141.804667
• [22] Tamassia, R.: On embedding a graph in the grid with the minimum number of bends. SIAM J. Comput. 16(3), 421–444 (1987). https://doi.org/10.1137/0216030
• [23] Tamassia, R., Tollis, I.G., Vitter, J.S.: Lower bounds for planar orthogonal drawings of graphs. Inf. Process. Lett. 39(1), 35–40 (1991). https://doi.org/10.1016/0020-0190(91)90059-Q
• [24] Thomassen, C.: Plane representations of graphs. In: Bondy, J., Murty, U. (eds.) Progress in Graph Theory, pp. 43–69 (1987)
• [25] Vijayan, G., Wigderson, A.: Rectilinear graphs and their embeddings. SIAM Journal on Computing 14(2), 355–372 (1985)
• [26] Zhou, X., Nishizeki, T.: Orthogonal drawings of series-parallel graphs with minimum bends. SIAM J. Discrete Math. 22(4), 1570–1604 (2008). https://doi.org/10.1137/060667621

## Appendix 0.A Additional Material for Section 2

is -connected, or simply-connected, if there is a path between any two vertices. is -connected, for , if the removal of vertices leaves the graph -connected. A -connected (-connected) graph is also called biconnected (triconnected).

A planar drawing of is a geometric representation in the plane such that: each vertex is drawn as a distinct point ; each edge is drawn as a simple curve connecting and ; no two edges intersect in except at their common end-vertices (if they are adjacent). A graph is planar if it admits a planar drawing. A planar drawing of divides the plane into topologically connected regions, called faces. The external face of is the region of unbounded size; the other faces are internal. A planar embedding of is an equivalence class of planar drawings that define the same set of (internal and external) faces, and it can be described by the clockwise sequence of vertices and edges on the boundary of each face plus the choice of the external face. Graph together a given planar embedding is an embedded planar graph, or simply a plane graph: If is a planar drawing of whose set of faces is that described by the planar embedding of , we say that preserves this embedding, or also that is an embedding-preserving drawing of .

See 1

###### Proof

We prove the four properties separately.

• Proof of T1. By definition, a P-node has at least two children. Also, since has no multiple edges, has at most one child that is a Q-node. At the same time, since , has neither three children nor a child that is an R-node, as otherwise at least one of its poles would have degree greater than in . Finally, if is the root child of , its poles coincides with the end-vertices of the reference edge ; if a child of is a Q-node, has multiple edges, a contradiction.

• Proof of T2. Let be a child of an R-node; if is a P-node or an R-node, the poles of have degree greater than one in , which implies that these vertices have degree greater than three in , a contradiction.

• Proof of T3. Let be an inner S-node of and let be a pole of . The parent of in is either a P-node or an R-node. If it is a P-node, then the edge incident to in cannot be a virtual edge, as otherwise has degree at least two in and it has at least two edges outside ; this would contradict the fact that . If the parent node of is an R-node, then has exactly three incident edges in the skeleton of this R-node, thus it must have degree one in . Finally, two virtual edges cannot be incident in , as they would imply a vertex of degree four in the graph.

## Appendix 0.B Additional Material for Section 3

See 3

###### Proof

We prove in three steps the existence of a bend-minimum orthogonal representation that satisfies O1-O3. We start by a bend-minimum orthogonal representation of with on the external face, and in the first step we prove that it either satisfies O1 or it can be locally modified, without changing its planar embedding, so to satisfy O1. In the second step, we prove that from the orthogonal representation obtained in the first step we can derive a new orthogonal representation (still with same embedding) that satisfies O2 in addition to O1. Finally, we prove that this last representation also satisfies O3.

Step 1: Property O1. Suppose that is a bend-minimum orthogonal representation of with on the external face and having an edge (possibly coincident with ) with at least three bends. Let be the rectilinear image of , and let be the plane graph underlying . Since has no bend, satisfies Conditions  of Theorem 2.1. Denote by , , and three bend vertices in that correspond to three bends of in . Assume first that is an internal edge of (i.e., does not belong to the external face). Let be the plane graph obtained from by smoothing . We claim that still satisfies Conditions  of Theorem 2.1. Indeed, if this is not the case, there must be a bad cycle in that contains both and . This is a contradiction, because no bad cycle can contain two vertices of degree two. It follows that there exists an (embedding-preserving) orthogonal representation of without bends, which is the rectilinear image of an orthogonal representation of with fewer bends than , a contradiction. Assume now that is on the external cycle of . If contains more than four vertices of degree two, then we can smooth vertex and apply the same argument as above to contradict the optimality of (note that, such a smoothing does not violate Condition of Theorem 2.1). Suppose vice versa that contains exactly four vertices of degree two (three of them being , , and ). In this case, just smoothing violates Condition  of Theorem 2.1. However, we can smooth and subdivide an edge of (such an edge exists because has at least three edges and, by hypothesis and a simple counting argument, at least one of its edges has no bend in ). The resulting plane graph still satisfies the three conditions of Theorem 2.1 and admits a representation without bends; the orthogonal representation of which is the rectilinear image is a bend-minimum orthogonal representation of with at most two bends per edge. To see that two bends per edge is worst case optimal, just consider the complete graph on four vertices. Every planar embedding of has three edges on . By Condition  of Theorem 2.1, a bend-minimum orthogonal representation of has four bends on the external face and thus two of them are on the same edge.

Step 2: Property O2. Let be a bend-minimum orthogonal representation of that satisfies O1 and let be its rectilinear image. The plane underlying graph of satisfies the three conditions of Theorem 2.1. Rhaman, Nishizeki, and Naznin [20, Lemma 3] prove that, in this case, has an embedding-preserving orthogonal representation without bends in which every -legged cycle is either -shaped or  -shaped, where the two poles of the shape are the two leg-vertices of . On the other hand, if is an inner P-component or an inner R-component, the external cycle is a -legged cycle of , where the two leg-vertices of are the poles of . Indeed, is a simple cycle and each pole has exactly one incident edge not belonging to . It follows that, the orthogonal representation of whose rectilinear image is satisfies O2, as is either -shaped or  -shaped. Also note that the bends of are the same as in , because the bend vertices of coincide with those of . Hence, still satisfies O1 and has the minimum number of bends.

Step 3: Property O3. Suppose now that is a bend-minimum orthogonal representation of (with on the external face) that satisfies both O1 and O2. More precisely, assume that is the orthogonal representation obtained in the previous step, where its rectilinear image is computed by the algorithm of Rhaman et al. [20], which we simply call NoBend-Alg. This algorithm works as follows (see also Fig. 5). In the first step, it arbitrarily designates four degree-2 vertices on the external face. A 2-legged cycle (resp. 3-legged cycle) of the graph is bad with respect to these four vertices if it does not contain at least two (resp. one) of them; a bad cycle is maximal if it is not contained in for any other bad cycle . The algorithm finds every maximal bad cycle (the maximal bad cycles are independent of each other) and it collapses into a supernode . Then it computes a rectangular representation of the resulting coarser plane graph (i.e., a representation with all rectangular faces) where each of (or a supernode containing it) is an external corner. Such a representation exists because the graph satisfies a characterization of Thomassen [24]. In the next steps, for each supernode , NoBend-Alg recursively applies the same approach to compute an orthogonal representation of ; if is 2-legged (resp. 3-legged), then two (resp. three) designated vertices coincide with the leg-vertices of . The representation of each supernode is then “plugged” into .

Suppose now that is an inner S-component of and let and be its poles. Let be the biconnected components of that are not single edges. We call each a subcomponent of (if is a sequence of edges, it has no subcomponents). Consider a generic step of NoBend-Alg, in which it has to draw , for some cycle (possibly the external cycle of ) such that . We distinguish between three cases.

Case 1 - is not contained in any maximal bad cycle. If all the edges of are internal edges of , the external cycle of each is a maximal bad 2-legged cycle (as it contains no designated vertices). In this case each is collapsed into a supernode, and in the rectangular drawing of the resulting graph all the degree-2 vertices and supernodes of the series will belong to the same side of a rectangular face. Thus, when all subcomponents of are drawn and plugged into , gets spirality zero. If has some edges on the external face, some might not be a maximal bad cycle (in which case it contains at least two designated vertices); in this case the spirality of will be equal to the number of designated vertices on its external edges, which is at most four.

Case 2 - is contained in a maximal bad cycle that passes through both and . In this case, is collapsed into a supernode before the computation of a rectangular drawing . The two legs of that are incident to and will form at in either two flat angles or a right angle: In the former case, will have spirality zero, while in the latter case it will have spirality one.

Case 3 - is contained in a maximal bad cycle that does not passes through both and . In this case, is still collapsed into a supernode before the computation of a rectangular drawing , and in one of the subsequent steps of the recursive algorithm on we will fall in Case 1 or in Case 2.

Figure 5 shows an example of how NoBend-Alg works. The input plane graph is in Fig. 5, and it is the same graph of Fig. 2, with the addition of some degree-2 vertices (small squares), needed to satisfy the properties of Theorem 2.1. The external face of contains exactly four degree-2 vertices, which are assumed to be the four designated vertices in the first step of NoBend-Alg. In the figure, the bad cycles with respect to the designated vertices are highlighted in red; the two cycles with thicker boundaries are maximal, and therefore they are collapsed as shown in Fig. 5. Note that, one of the two maximal cycles includes a designated vertex; once this cycle is collapsed, the corresponding supernode becomes the new designated vertex. Figure 5 depicts a rectangular representation of the graph in Fig. 5, and it also shows the representations of the subgraphs in the supernodes, computed in the recursive procedure of NoBend-Alg; these representations are plugged in the rectangular representation, in place of the supernodes, yielding the final representation of Fig. 5.

## Appendix 0.C Additional Material for Section 4

See 4

###### Proof

The proof is trivial if is a P-node or an R-node since, in order to be equivalent, and must be both  -shaped or -shaped, which, by definition, implies that their contour paths have the same turn numbers. If is an S-node, then and have the same spirality  and, by Lemma 2, their contour paths have the same turn number as any path from one pole of to the other pole.

See 4.1

###### Proof

The statement easily follows from Lemma 4 and from a characterization of orthogonal representations first stated in [25]. Let be a biconnected embedded planar graph and let be a function that assigns: (i) a value in to each pair of consecutive edges in the circular order around each vertex of  and (ii) a sequence of left and right turns to each edge of . Denote by the turn number of a face , that is, the difference between the number of right and the number of left turns encountered while clockwise traversing the border of , where a angle counts as zero, a angle (resp., angle) counts as one if is an internal face (resp., if is the external face), and a angle (resp., angle) counts as if is an internal face (resp., if is the external face). Then corresponds to an orthogonal representation of if and only if the turn number of each face is four.

Hence, an orthogonal representation of induces an assignment satisfying the above mentioned property. Let be the restriction of to the internal faces of . Let be an orthogonal representation of equivalent to and let be the assignment corresponding to . We now prove that replacing with yields a new orthogonal representation by showing that the corresponding function satisfies the above characterization. In the following, assuming that and are the two poles of and that and are the two contour paths of , we call the contour path of such that and the contour path of such that (if a mirroring of is needed in the replacement, the two contour paths of are renamed). Also, let be the face of to the left of while moving along from to , and let be the face of to the left of while moving along from to . The faces and are defined symmetrically. Assignment is such that: (a) Each face of whose boundary is exclusively composed of edges not belonging to has the same shape as in and for the angles and edges of we have , hence . (b) Each face whose boundary is exclusively composed of edges of has the same shape as in and for the angles and edges of we have , hence . (c) The remaining two faces of are and . The boundary of is composed of path plus another path . By construction, the boundary of is composed of path plus . Also, again by construction, the two angles at and in are the same as the two angles at and in . Since the turn number of in equals the turn number of in . The same for .

See 6

###### Proof

The proof is by induction on the number of children of that are not Q-nodes. Suppose that has only Q-node children (). It is trivial that , which is a path, can be drawn with cost zero and with spirality in , while has increasing costs for higher values of spirality. For the inductive case, note that inserting an -shaped child in between two Q-nodes does not increase nor decrease the spirality of an orthogonal drawing of . Instead, a  -shaped child inserted in between two Q-nodes can be used as if it were an additional Q-node to increase the spirality of one unit without additional costs.

See 7

###### Proof

By virtue of Lemma 6 we can sum up the cheapest costs of the representations of all P- and R-node children of to obtain the cost of a bend-minimum orthogonal representation of with spirality in . If we are done. Otherwise, by Property O2 of Lemma 3, we can optimally increase the spirality of by inserting bends into the Q-nodes of . Since and the needed extra bends are at most three (because ), if we evenly distribute the extra bends among the real edges of , we end up with at most two bends per edge, satisfying Property O1 of Lemma 3.

See 8

###### Proof

We first briefly recall the algorithm in [18], which we call MinBendCubic-Alg and which is conceptually similar to NoBend-Alg (described in the proof of Lemma 3). MinBendCubic-Alg takes as input an embedded planar triconnected cubic graph and computes an embedding-preserving bend-minimum orthogonal representation of . It initially inserts four dummy vertices of degree two on , by suitably subdividing some external edges; these vertices act as the four designated vertices of NoBend-Alg. Note that, since is triconnected, each maximal bad cycle with respect to is a -legged cycle. For each such cycle , the algorithm collapses into a supernode , thus obtaining a coarser graph, which admits a rectangular representation  [24]. In the successive steps, for each supernode , MinBendCubic-Alg recursively applies the same approach to compute an orthogonal representation of , where three of the four designated vertices coincide with the leg-vertices of . The representation of  is then plugged into . All designated vertices added throughout the algorithm are bends of the final representation. Crucial to the bend-minimization process of MinBendCubic-Alg is the insertion of the designated vertices along edges that are shared by more than one bad cycles (if any). For example, let and be two bad cycles such that is maximal, belongs to , and and share a path ; since both and need a bend, MinBendCubic-Alg inserts a designated vertex along to save bends. At any step of the recursion, a red edge is an edge for which placing a designated vertex along it leads to a sub-optimal solution; the remaining edges are green. As it is proven in [18], every bad cycle has at least one green edge. A bad cycle is a corner cycle if it has at least one green edge on the external face and there is no other bad cycle inside having this property. In order to save bends when placing the four designated vertices on , MinBendCubic-Alg gives preference to the green edges of the corner cycles, if they exist. We remark that, algorithm MinBendCubic-Alg produces orthogonal drawings with at most one bend per edge, with the possible exception of one edge in the outer face, which is bent twice if the external boundary is a 3-cycle.

We now describe our algorithm, called Rset-Alg. Let be the poles of . Rset-Alg consists of two steps. In the first step it computes an -shaped orthogonal representation and a  -shaped orthogonal representation of , using a variant of MinBendCubic-Alg. In the second step, a bend-minimum -shaped orthogonal representation and a bend-minimum  -shaped orthogonal representation of are constructed, by replacing each virtual edge in each of and with the representation in the set of the corresponding S-node whose spirality equals the number of bends of . Every time the algorithm needs to insert a designated vertex that subdivides an edge of the graph (either to break a bad cycle or to guarantee four external corners in the initial step), it adds this vertex on a virtual edge, if such an edge exists. Indeed, by Corollary 1, this vertex does not cause an additional bend in the final representation when the virtual edge is replaced by the corresponding S-component. To find , where and are two of the four designated vertices on the external face of