## 1 Introduction

Directed graphs explaining hierarchy naturally appear in multiple industrial and academic applications. Some examples include PERT diagrams, UML component diagrams, text edition networks [1], text variant graphs [20]

, philogenetic and neural networks. In these, and many other applications, it is essential to visualize the implied directed graph so that the viewer can perceive the hierarchical structure it contains. By far the most popular way to achieve this is to apply the

*Sugyiama framework*– a generic network visualization algorithm that results in a drawing where each vertex lies on a horizontal line, called

*layer*, and each edge is directed from a lower layer to a higher layer [15].

The Sugyiama framework consists of several steps: elimination of directed cycles in the initial graph, assignement of vertices to layers, vertex ordering and coordinate assignement. During each of these steps several criteria are optimized, by leading to more readable visualizations, see e.g. [15]. In this paper we concentrate on the last step of the framework, namely coordinate assignment.
Thus, the subject of our study are *level graphs* defined as follows. Let be a directed graph.
A *-level assignment* of is a function that assigns each vertex of to one of levels.
We refer to together with as to a (-)*level graph*.
The *length* of an edge is defined as .
We say that is *proper* if all edges have length one.
The level graph shown in Fig. 1 (a) is proper, whereas the one shown in (b) is not.
For a non-proper level graph there exists a *proper subdivision* obtained by subdividing all edges with length greater than one which result in a proper graph.

A *level drawing* of a level graph maps each vertex to a point on the horizontal line with -coordinate and a real -coordinate , and each edge to a -monotone curve between its endpoints.
A level drawing is called *level-planar* if no two edges intersect except in common endpoints.
It is *straight-line* if the edges are straight lines.
A level drawing of a proper (subdivision of a) level graph induces a total left-to-right order on the vertices of a level.
We say that two drawings are *equivalent* if they induce the same order on every level.
An equivalence class of this equivalence relation is an *embedding* of .
We refer to together with an embedding to as *embedded level graph* .
The third step of Sugyiama framework, vertex ordering, results in an embedded level graph.

The general goal of the coordinate assignment step is to produce a final visualization while further improving its readability. The criteria of readability that have been considered in the literature for this step include
straightness and verticality of the edges [15].
Here we study the problem of coordinate assignment step with bounded number of slopes.
The *slope* of an edge in is defined as .
For proper level graphs this simplifies to . We restrict our study to drawings in which all slopes are non-negative; such drawings can be transformed into drawings with negative slopes by shearing; see Fig. 1.

A level drawing is a *-slope drawing* if all slopes in appear in the set .
We study embedding-preserving straight-line level-planar -slope drawings, or *-drawings* for short and refer to the problem of finding these drawings as -Drawability .
Since the possible edge slopes in a -drawing are integers all vertices lie on the integer grid.

#### Related Work.

The number of slopes used for the edges in a graph drawing can be seen as an indication of the simplicity of the drawing.
For instance, the measure *edge orthogonality*, which specifies how close a drawing is to an *orthogonal drawing*, where edges are polylines consisting of horizontal and vertical segments only, has been proposed as a measure of aesthetic quality of a graph drawing [33]. In a similar spirit, Kindermann et al. studied the effect reducing the segment complexity on the aesthetics preference of graph drawings and observed that in some cases people prefer drawings using lower segment complexity [23].
More generally, the use of few slopes for a graph drawing may contribute to the formation of “Prägnanz” (“good figure” in German) of the visualization, that accordingly to the Gestalt law of Prägnanz, or law of simplicity, contributes to the perceived quality of the visualizations.
This is design principle often guides the visualization of metro maps.
See [30] for a survey of the existing approaches, most of which generate octilinear layouts of metro maps, and [29] for a recent model for drawing more general -linear metro maps.

Level-planar drawing with few slopes have not been considered in the literature but drawings of undirected graphs with few slopes have been extensively studied.
The (*planar*) *slope number* of a (planar) graph is the smallest number so that has a (planar) straight-line drawing with edges of at most distinct slopes.
Special attention has been given to proving bounds on the (planar) slope number of undirected graph classes [4, 9, 10, 11, 13, 22, 21, 24, 25, 31].
Determining the planar slope number is hard in the existential theory of reals [17].

Several graph visualization problems have been considered in the partial and simultaneous settings.
In the *partial drawing extension* problem, one is presented with a graph and an immutable drawing of some subgraph thereof.
The task is to determine whether the given drawing of the subgraph can be completed to a drawing of the entire graph. The problem has been studied for the planar setting [26, 32] and also the level-planar setting [7].
In the *simultaneous drawing* problem, one is presented with two graphs that may share some subgraph.
The task is to draw both graphs so that the restrictions of both drawings to the shared subgraph are identical. We refer the reader to [5] for an older literature overview.
The problem has been considered for orthogonal drawings [2] and level-planar drawings [3]. Up to our knowledge, neither partial nor simultaneous drawings have been considered in the restricted slope setting.

#### Contribution.

We introduce and study the -Drawability problem. To solve this problem for proper level graphs, we introduce two models. In Section 3 we describe the first model, which uses a classic integer-circulation-based approach. This model allows us to solve the -Drawability in time and obtain a -drawing within the same running time if one exists. In Section 4, we describe the second distance-based model. It uses the duality between flows in the primal graph and distances in the dual graph and allows us to solve the -Drawability in time. We also address the partial and simultaneous settings. The classic integer-circulation-based approach can be used to extend connected partial -drawings in time. In Section 5, we build on the distance-based model to extend not-necessarily-connected partial -drawings in time, and to obtain simultaneous -drawings in time if they exist. We finish with some concluding remarks in Section 6 and refer to Appendix 0.A for a proof that 2-Drawability is NP-hard even for biconnected graphs where all edges have length one or two.

## 2 Preliminaries

Let be a level-planar drawing of an embedded level-planar graph .
The *width* of is defined as .
An integer is a *gap* in if it is for all , and for some , and for no edge .
A drawing is *compact* if it has no gap.
Note that a -drawing of a connected level-planar graph is inherently compact.
While in a -drawing of a non-connected level-planar graph every gap can be eliminated by a shift.
The fact that we only need to consider compact -drawings helps us to limit their width. Thus, any compact -drawing has a width of at most .

Let and be two vertices on the same level .
With (or when is clear from the context) we denote the set of vertices that contains and all vertices in between and on level in .
We say that two vertices and are *consecutive in * when .
Two edges are *consecutive in * when the only edges with one endpoint in and the other endpoint in are and .

A *flow network* consists of a set of nodes connected by a set of directed arcs .
Each arc has a *demand* specified by a function and a *capacity* specified by a function where encodes unlimited capacity.
A *circulation* in is a function that assigns an integral flow to each arc of and satisifies the two following conditions.
First, the circulation has to respect the demands and capacities of the arcs, i.e., for each arc it is .
Second, the circulation has to respect flow conservation, i.e., for each node it is .
Depending on the flow network no circulation may exist.

## 3 Flow Model

In this section, we model the -Drawability as a problem of finding a circulation in a flow network.
Let be an embedded proper -level graph together with a level-planar drawing .
As a first step, we add two directed paths and that consist of one vertex on each level from 1 to to .
Insert and into to the left and right of all other vertices as the *left* and *right boundary*, respectively.
See Fig. 2 (a) and (c).

From now on, we assume that and contain the left and right boundary.

The flow network consists of nodes and arcs and is similar to a directed dual of with the difference that it takes the levels of into account.
In particular, for every edge of , contains two nodes and , in the left and the right faces incident to , and a dual *slope arc* with demand and capacity ; see the blue arcs in Fig. 2 (b) and (c).
The flow across determines the slope of .
Additionally, for every pair of consecutive vertices we add two nodes and to and connect them by a *space arc* ; see the red arcs in Fig. 2 (b) and (c).
The flow across determines the space between and .
The space between and needs to be at least one to prevent and from colliding and can be at most due to the restriction to compact drawings.
So, assign to a demand of one and a capacity of .
To obtain the final flow network we merge certain nodes.
Let and be consecutive edges.
Merge the nodes , the nodes and the nodes
into a single node.
Next, merge all remaining source and sink nodes into one source node and one sink node , respectively.
See Fig. 2 (c), where the gray areas touch nodes that are merged into a single node.
Finally, insert an arc from to with unlimited capacity.

The network is designed in such a way that the circulations in correspond bijectively to the -drawings of . Let be a drawing of and let be the function that assigns to each vertex of its -coordinate in . We define a dual circulation as follows. Recall that every arc of is either dual to an edge of or to two consecutive vertices in . Hence, the left and right incident faces and of in contain vertices of . Define the circulation by setting . We remark the following, although we defer the proof to the next section.

###### Lemma 1

Let be an embedded proper level-planar graph together with a -drawing . The dual of the function that assigns to each vertex of its -coordinate in is a circulation in .

In the reverse direction, given a circulation in we define a dual function that, when interpeted as assigning an -coordinate to the vertices of , defines a -drawing of . Refer to the level-1-vertex as . Start by setting , i.e., the -coordinate of is 0. Process the remaining vertices of the right boundary in ascending order with respect to their levels. Let be an edge of the right boundary so that has already been processed and has not been processed yet. Then set , where is the slope arc dual to . Let be a pair of consecutive vertices so that has already been processed and has not yet been processed yet. Then set , where is a space arc. It turns out that defines a -drawing of .

###### Lemma 2

Let be an embedded proper level-planar graph, let and let be a circulation in . Then the dual , when interpeted as assigning an -coordinate to the vertices of , defines a -drawing of .

While both Lemma 1 and Lemma 2 can be proven directly, we defer their proofs to Section 4 where we introduce the distance model and prove Lemma 3 and Lemma 4, the stronger versions of Lemma 1 and Lemma 2, respectively. Combining Lemma 1 and Lemma 2 we obtain the following.

###### Theorem 3.1

Let be an embedded proper level-planar graph and let . The circulations in correspond bijectively to the -drawings of .

Theorem 3.1 implies that a -drawing can be found by applying existing flow algorithms to . For that, we transform our flow network with arc demands to the standard maximum flow setting without demands by introducing new sources and sinks. We can then use the -time multiple-source multiple-sink maximum flow algorithm due to Borradaile et al. [6] to find a circulation in or to determine that no circulation exists.

###### Corollary 1

Let be an embedded proper level-planar graph and let . It can be tested in time whether a -drawing of exists, and if so, such a drawing can be found within the same running time.

### 3.1 Connected Partial Drawings

Recall that a partial -drawing is a tuple , where is an embedded level-planar graph, is an embedded subgraph of and is a -drawing of . We say that is *-extendable* if
admits a -drawing whose restriction to is . Here is referred to as a *-extension* of .

In this section we show that in case is connected, we can use the flow model to decide whether is -extendable. Observe that when is connected is completely defined by the slopes of the edges in up to horizontal translation. Let be the flow network corresponding to . In order to fix the slopes of an edge of to a value , we fix the flow across the dual slope arc in to . Checking whether a circulation in the resulting flow network exists can be reduced to a multiple-source multiple-sink maximum flow problem, which once again can be solved by the algorithm due to Borradaile et al. [6].

###### Corollary 2

Let be a partial -drawing where is connected. It can be tested in time whether is -extendable, and if so, a corresponding -extension can be constructed within the same running time.

## 4 Dual Distance Model

A minimum cut (and, equivalently, the value of the maximum flow) of an -planar graph can be determined by computing a shortest -path in a dual of [18, 19]. Hassin showed that to construct a flow, it is sufficient to compute the distances from to all other vertices in the dual graph [14]. To the best of our knowledge, this duality has been exploited only for flow networks with arc capacities, but not with arc demands. In this section, we extend this duality to arcs with demands. The resulting dual distance model improves the running time for the -Drawability, lets us test the existence of -extensions of partial -drawings for non-connected subgraphs, and allows us to develop an efficient algorithm for testing the existence of simultaneous -drawings.

We define to be the directed dual of as follows. Let be an arc of with demand and capacity . Further, let and denote the left and the right faces of in , respectively. The dual contains and as vertices connected by one edge with length and another edge with length ; see Fig. 3.

Observe that to obtain from (with left and right paths and ) we added dual arcs to edges of

and dual arcs to the space between two consecutive vertices on one level. Consider for a moment the graph

obtained from by adding edges for all consecutive vertices , where is to the right of . Graph and are identical and therefore has the vertex set of and contains a subset of its edges. Recall that the dual slope arcs in have demand and capacity , therefore the edges of that connect vertices on different layers have non-negative length. While the edges of between consecutive vertices on the same level have length .A *distance labeling* is a function that for every edge of with length satisfies .
We also say that *imposes the distance constraint* .
A distance labeling for is the -coordinate assignment for a -drawing:
For an edge of where are consecutive vertices in , the distance labeling guarantees , i.e., the consecutive vertices are in the correct order and do not overlap.
If an edge between layers has length , then the distance labeling ensures , i.e., has a slope in .
Computing the shortest distances from in to every vertex (if they are well-defined) gives a distance labeling that we refer to as the *shortest distance labeling*.
A distance labeling of does not necessarily exist.
This is the case when contains a negative cycle, e.g., when the in- or out-degree of a vertex in is strictly larger than .
For a distance labeling of we define a dual circulation by setting for each arc of with left and right incident faces and .

###### Lemma 3

Let be an embedded level-planar graph and be a -drawing of . The function that assigns to each vertex of its -coordinate in is a distance labeling of and its dual is a circulation in .

###### Proof

Since preserves the embedding of , for each consecutive vertices , with preceeding in it holds that . Since is a grid drawing , which implies , where is the length of . Since is a -drawing, i.e. every edge between the two levels has a slope in , it holds that , which implies , for the edge of with length zero and for the edge of with length . Hence, is a distance labeling of .

We now show that is a circulation in . Let be the faces incident to some node of in counter-clockwise order. Let be the arc incident to and dual to the edge between and with . If is an incoming arc, it adds a flow of to . If is an outgoing arc, it removes a flow of from , or, equivalently, it adds a flow of to . Therefore, the flow through is . This sum cancels to zero, i.e., the flow is preserved at . Recall that the edge with length in ensures , which gives . So, no capacities are exceeded. Analogously, the edge with length in ensures , which gives . Hence, all demands are fulfilled and is indeed a circulation in . ∎

Recall from Section 3 that for a circulation in we define a dual drawing by setting the -coordinates of the vertices of as follows. For the lowest vertex of the right boundary set . Process the remaining vertices of the right boundary in ascending order with respect to their levels. Let be an edge of the right boundary so that has already been processed and has not been processed yet. Then set , where is the slope arc dual to . Let be a pair of consecutive vertices so that has already been processed and has not yet been processed yet. Then set , where is a space arc. It turns out that is a distance labeling of and a -drawing of .

###### Lemma 4

Let be an embedded level-planar graph, let , and let be a circulation in . The dual is a distance labeling of and the drawing induced by interpreting the distance label of a vertex as its -coordinate is a -drawing of .

###### Proof

We show that is a distance labeling in . The algorithm described above assings a value to every vertex of . We now show that is indeed a distance labeling by showing that every edge satisfies a distance constraint.

Observe that the distance constraints imposed by edges dual to the space arcs are satisfied by construction.
To show that the distance constraints imposed by edges dual to the slope arcs are also satisfied, we prove that for every edge , it holds that .
We refer to this as *condition * for short.
Since and the length of is we obtain , which implied that is a distance labeling of .

The proof is by induction based on the bottom to top and right to left order among the edges of . We say that *precedes* if either , or and is to the right of , or and is to the right of (in case ).
For the base case observe that the edges with both end-vertices on the first level and the edges of satisfy condition by the definition of .
Now let be an edge not addressed in the base case and assume that for every edge preceding edge condition holds.
For the inductive step we show that condition also holds for .
Let denote the edge to the right of so that and are consecutive; see Fig. 5.

Because is not the rightmost vertex on its level this edge exists. Let denote the set of space arcs in with . Analogously, let denote the set of space arcs in with . It is by definition of . Further, by induction hypothesis and since precedes it holds that . Inserting the latter into the former equation, we obtain . Again, by definition of , it is . By subtracting from we obtain

(1) |

Flow conservation on the vertex of to which edges of and are incident gives . Solving this equation for and inserting it into (1) yields , i.e. the condition holds for . Therefore is a distance labeling, which we have shown to define a -drawing of . ∎

Because is planar we can use the -time shortest path algorithm due to Mozes and Wulff-Nilsen [28] to compute the shortest distance labeling. This improves our -time algorithm from Section 3.

###### Theorem 4.1

Let be an embedded proper level-planar graph. The distance labelings of correspond bijectively to the -drawings of . If such a drawing exists, it can be found in time.

## 5 Partial and Simultaneous Drawings

In this section we use the distance model from Section 4 to construct partial and simultaneous -drawings.
We start with introducing a useful kind of drawing.
Let be a -drawing of .
We call a *-rightmost* drawing when there exists no -drawing with for some .
In this definition, we assume to exclude trivial horizontal translations.
Hence, a drawing is rightmost when every vertex is at its rightmost position across all level-planar -slope grid drawings of .
It is not trivial that a -rightmost drawing exists, but it follows directly from the definition that if such a drawing exists, it is unique.
The following lemma establishes the relationship between -rightmost drawings and shortest distance labelings of .

###### Lemma 5

Let be an embedded proper level-planar graph. If has a shortest distance labeling it describes the -rightmost drawing of .

###### Proof

The shortest distance labeling of is maximal in the sense that for any vertex there exists a vertex and an edge with length so that it is . Recall that the definition of distance labelings only requires . The claim then follows by induction over in ascending order with respect to the shortest distance labeling. ∎

### 5.1 Partial Drawings

Let be a partial -drawing. In Section 3.1 we have shown that the flow model can be adapted to check whether has a -extension, in case is connected. In this section, we show how to adapt the distance model to extend partial -drawings, including the case is disconnected. Recall that the distance label of a vertex is its -coordinate. A partial -drawing fixes the -coordinates of the vertices of . The idea is to express this with additional constraints in . Let be a vertex of . In a -extension of , the relative distance along the -axis between a vertex of and vertex should be . This can be achieved by adding an edge with length and an edge with length . The first edge ensures that it is , i.e., and the second edge ensures . Together, this gives . Let be augmented by the edges with lengths as described above.

To decide existence of -extension and in affirmative construct the corresponding drawing we compute the shortest distance labeling in . Observe that this network can contain negative cycles and therefore no shortest distance labeling. Unfortunately, is not planar, and thus we cannot use the embedding-based algorithm of Mozes and Wulff-Nilsen.
However, since all newly introduced edges have as one endpoint, is an *apex* of , i.e., removing from makes it planar.
Therefore can be recursively separated by separators of size .
We can therefore use the shortest-path algorithm due to Henzinger et al. to compute the shortest distance labeling of in time [16].

###### Theorem 5.1

Let be a partial -drawing. In time it can be determined whether has a -extension and in the affirmative the corresponding drawing can be computed within the same running time.

### 5.2 Simultaneous Drawings

In the simultaneous -drawing problem, we are given a tuple of two embedded level-planar graphs that share a common subgraph . We assume w.l.o.g. that and share the same right boundary and that the embeddings of and coincide on . The task is to determine whether there exist -drawings of , respectively, so that and coincide on the shared graph . The approach is the following. Start by computing the rightmost drawings of and . Then, as long as these drawings do not coincide on add necessary constraints to and . This process terminates after a polynomial number of iterations, either by finding a simultaneous -drawing, or by determining that no such drawing exist.

Finding the necessary constraints works as follows. Suppose that are the rightmost drawings of , respectively. Because both and have the same right boundary they both contain vertex . We define the coordinates in the distance labelings of and in terms of this reference vertex.

Now suppose that for some vertex of the -coordinates in and differ, i.e., it is . Assume without loss of generality. Because is a rightmost drawing, there exists no drawing of where has an -coordinate greater than . In particular, there exist no simultaneous drawings where has an -coordinate greater than . Therefore, we must search for a simultaneous drawing where . We can enforce this constraint by adding an edge with length into . We then attempt to compute the drawing of defined by the shortest distance labeling in . This attempt produces one of two possible outcomes. The first possibility is that there now exists a negative cycle in . This means that there exists no drawing of with . Because is a rightmost drawing, this means that no simultaneous drawings of and exist. The algorithm then terminates and rejects this instance. The second possiblity is that we obtain a new drawing . This drawing is rightmost among all drawings that satisfy the added constraint . In this case there are again two possibilities. Either we have for each vertex in . In this case and are simultaneous drawings and the algorithm terminates. Otherwise there exists at least one vertex in with . We then repeat the procedure just described for adding a new constraint.

We repeat this procedure of adding other constraints. To bound the number of iterations, recall that we only consider compact drawings, i.e., drawings whose width is at most . In each iteration the -coordinate of at least one vertex is decreased by at least one. Therefore, each vertex is responsible for at most iterations. The total number of iterations is therefore bounded by .

Note that due to the added constraints and are generally not planar. We therefore apply the -time shortest-path algorithm due to Henzinger et al. that relies not on planarity but on -sized separators to compute the shortest distance labellings. This gives the following.

###### Theorem 5.2

Let be embedded level-planar graphs that share a common subgraph . In time it can be determined whether admit simultaneous -drawings and if so, such drawings can be computed within the same running time.

## 6 Conclusion

In this paper we studied -drawings, i.e., level-planar drawings with slopes. We model -drawings of proper level-planar graphs as integer flow networks. This lets us find -drawings and extend connected partial -drawings in time. We extend the duality between integer flows in a primal graph and shortest distances in its dual to obtain a more powerful distance model. This distance model allows us to find -drawings in time, extend not-necessarily-connected partial -drawings in time and find simultaneous -drawings in time.

In the non proper case, testing the existence of a -drawing becomes NP-hard, even for biconnected graphs with maximum edge length two; see Appendix 0.A.

## References

- [1] FAUSTEDITION. http://www.faustedition.net/macrogenesis/dag.
- [2] Patrizio Angelini, Steven Chaplick, Sabine Cornelsen, Giordano Da Lozzo, Giuseppe Di Battista, Peter Eades, Philipp Kindermann, Jan Kratochvíl, Fabian Lipp, and Ignaz Rutter. Simultaneous orthogonal planarity. In Yifan Hu and Martin Nöllenburg, editors, Proceedings of the 24th International Symposium on Graph Drawing and Network Visualization, pages 532–545. Springer, Cham, 2016.
- [3] Patrizio Angelini, Giordano Da Lozzo, Giuseppe Di Battista, Fabrizio Frati, Maurizio Patrignani, and Ignaz Rutter. Beyond level planarity. In Yifan Hu and Martin Nöllenburg, editors, Proceedings of the 24th International Symposium on Graph Drawing and Network Visualization, pages 482–495. Springer, Cham, 2016.
- [4] János Barát, Jivr’i Matouvsek, and David R. Wood. Bounded-degree graphs have arbitrarily large geometric thickness. Electr. J. Comb., 13(1), 2006.
- [5] Thomas Bläsius, Stephen G. Kobourov, and Ignaz Rutter. Simultaneous embedding of planar graphs. In Tamassia [36], pages 349–381.
- [6] Glencora Borradaile, Philip N. Klein, Shay Mozes, Yahav Nussbaum, and Christian Wulff-Nilsen. Multiple-source multiple-sink maximum flow in directed planar graphs in near-linear time. In Proceedings of the 52nd Annual IEEE Symposium on Foundations of Computer Science, pages 170–179. IEEE Press, New York, 2011.
- [7] Guido Brückner and Ignaz Rutter. Partial and constrained level planarity. In Philip N. Klein, editor, Proceedings of the 28th Annual ACM-SIAM Symposium on Discrete Algorithms, pages 2000–2011. SIAM, 2017.
- [8] Mark de Berg and Amirali Khosravi. Optimal binary space partitions in the plane. In My T. Thai and Sartaj Sahni, editors, Proceedings of the 16th International Computing and Combinatorics Conference, pages 216–225. Springer, Berlin, Heidelberg, 2010.
- [9] Emilio Di Giacomo, Giuseppe Liotta, and Fabrizio Montecchiani. Drawing outer 1-planar graphs with few slopes. Journal of Graph Algorithms and Applications, 19(2):707–741, 2015.
- [10] Vida Dujmović, David Eppstein, Matthew Suderman, and David R. Wood. Drawings of planar graphs with few slopes and segments. Computational Geometry, 38(3):194–212, October 2007.
- [11] Vida Dujmović, Matthew Suderman, and David R. Wood. Graph drawings with few slopes. Computational Geometry, 38(3):181–193, October 2007.
- [12] Shimon Even, Alon Itai, and Adi Shamir. On the complexity of timetable and multicommodity flow problems. SIAM Journal on Computing, 5(4):691–703, December 1976.
- [13] Emilio Di Giacomo, Giuseppe Liotta, and Fabrizio Montecchiani. Drawing subcubic planar graphs with four slopes and optimal angular resolution. Theor. Comput. Sci., 714:51–73, 2018.
- [14] Refael Hassin. Maximum flow in planar networks. Information Processing Letters, 13(3):107, December 1981.
- [15] Patrick Healy and Nikola S. Nikolov. Hierarchical drawing algorithms. In Tamassia [36], pages 409–453.
- [16] Monika R. Henzinger, Philip N. Klein, Satish Rao, and Sairam Subramanian. Faster shortest-path algorithms for planar graphs. Journal of Computer and System Sciences, 55(1):3–23, August 1997.
- [17] Udo Hoffmann. On the complexity of the planar slope number problem. J. Graph Algorithms Appl., 21(2):183–193, 2017.
- [18] Te Chiang Hu. Integer Programming and Network Flows. Addison-Wesley, Reading, MA, 1969.
- [19] Alon Itai and Yossi Shiloach. Maximum flow in planar networks. SIAM Journal on Computing, 8(2):135–150, May 1979.
- [20] Stefan Jänicke, Annette Geßner, Greta Franzini, Melissa Terras, Simon Mahony, and Gerik Scheuermann. Traviz: A visualization for variant graphs. DSH, 30(Suppl-1):i83–i99, 2015.
- [21] Balázs Keszegh, János Pach, and Dömötör Pálvölgyi. Drawing planar graphs of bounded degree with few slopes. SIAM Journal on Discrete Mathematics, 27(2):1171–1183, June 2013.
- [22] Balázs Keszegh, János Pach, Dömötör Pálvölgyi, and Géza Tóth. Drawing cubic graphs with at most five slopes. Computational Geometry, 40(2):138–147, July 2008.
- [23] Philipp Kindermann, Wouter Meulemans, and André Schulz. Experimental analysis of the accessibility of drawings with few segments. Journal of Graph Algorithms and Applications, 22(3):501–518, 2018.
- [24] Kolja B. Knauer, Piotr Micek, and Bartosz Walczak. Outerplanar graph drawings with few slopes. Comput. Geom., 47(5):614–624, 2014.
- [25] William Lenhart, Giuseppe Liotta, Debajyoti Mondal, and Rahnuma Islam Nishat. Planar and plane slope number of partial 2-trees. In Stephen K. Wismath and Alexander Wolff, editors, Graph Drawing - 21st International Symposium, GD 2013, Bordeaux, France, September 23-25, 2013, Revised Selected Papers, volume 8242 of Lecture Notes in Computer Science, pages 412–423. Springer, 2013.
- [26] Tamara Mchedlidze, Martin Nöllenburg, and Ignaz Rutter. Extending convex partial drawings of graphs. Algorithmica, 76(1):47–67, September 2016.
- [27] Carol Meyers and Andreas Schulz. Integer equal flows. Operations Research Letters, 37(4):245–249, July 2009.
- [28] Shay Mozes and Christian Wulff-Nilsen. Shortest paths in planar graphs with real lengths in time. In Mark de Berg and Ulrich Meyer, editors, Proceedings of the 18th Annual European Conference on Algorithms, pages 206–217. Springer, Berlin, Heidelberg, 2010.
- [29] Soeren Nickel and Martin Nöllenburg. Drawing -linear Metro Maps. CoRR, abs/1904.03039, 2019.
- [30] Martin Nöllenburg. A survey on automated metro map layout methods. In Schematic Mapping Workshop. Essex, UK, April 2014.
- [31] János Pach and Dömötör Pálvölgyi. Bounded-degree graphs can have arbitrarily large slope numbers. Electr. J. Comb., 13(1), 2006.
- [32] Maurizio Patrignani. On extending a partial straight-line drawing. Int. J. Found. Comput. Sci., 17(5):1061–1070, 2006.
- [33] Helen C. Purchase. Metrics for graph drawing aesthetics. J. Vis. Lang. Comput., 13(5):501–516, 2002.
- [34] Sartaj Sahni. Computationally related problems. SIAM Journal on Computing, 3(4):262–279, December 1974.
- [35] K. Srinathan, Pranava R. Goundan, M. V. N. Ashwin Kumar, R. Nandakumar, and C. Pandu Rangan. Theory of equal-flows in networks. In Oscar H. Ibarra and Louxin Zhang, editors, Proceedings of the 8th International Computing and Combinatorics Conference, pages 514–524. Springer, Berlin, Heidelberg, 2002.
- [36] Roberto Tamassia, editor. Handbook on Graph Drawing and Visualization. Chapman and Hall/CRC, 2013.

## Appendix 0.A Complexity of the General Case

So far, we have considered proper level graphs, i.e., level graphs where all edges have length one.
In this section, we consider the general case, where edges may have arbitrary lengths.
We say that an edge with length two or more is *long*.
One approach would be to try to adapt the flow model from Section 3 to this more general case.
By subdividing long edges, any level graph can be transformed into a proper level graph .
Observe that two edges in created by subdividing the same long edge must have the same slope in order to yield a fixed-slope drawing of .
In the context of our flow model, this means that the amount of flow across the corresponding slope arcs must be the same.
Our problem then becomes an instance of the *integer equal flow problem*.
In this problem, we are given a flow network along with disjoint sets of arcs.
The task is to find the maximum flow from to such that the amount of flow across arcs in the same set is the same.
This problem was introduced and shown to be NP-hard by Sahni [34].
The problem remains NP-hard in special cases [12, 35] and the integrality gap of the fractional LP can be arbitrarily large [27].

In this section we show that the level-planar grid drawing problem is NP-complete even for two slopes and biconnected graphs where all edges have length one or two.
To this end, we present a reduction from *rectilinear planar monotone 3-Sat* [8].
An instance of this problem consists of a set of variables and a set of clauses .
A clause is *positive* (*negative*) when it consists of only positive (negative) literals.
We say that the instance is *monotone* when each clause is either positive or negative.
Further, the instance can be planarly drawn as a graph with vertices ; see Fig. 6.

In this drawing, the variables are aligned along a virtual horizontal line . Positive clauses are drawn as vertices above and connected by an edge to a variable if the clause contains the corresponding postive literal. Symmetrically, negative clauses are drawn as vertices below and connected by an edge to a variable if the clause contains the corresponding negative literal.

Our reduction works by first replacing every vertex that corresponds to a variable by a variable gadget and every vertex that corresponds to a positive (negative) clause by a positive (negative) clause gadget.
All three gadgets consist of *fixed* and *movable* parts.
The fixed parts only admit one level-planar two-slope grid drawing, whereas the movable parts admit two or more drawings depending on the choice of slope for some edges.
Second, the gadgets are connected by a common fixed frame.
All fixed parts of the gadgets are connected to the common frame in order to provide a common point of reference.
The movable parts of the gadgets then interact in such a way that any level-planar two-slope grid drawing induces a solution to the underlying planar monotone 3-Sat instance.

The variable gadget consists of a number of *connectors* arranged around a fixed horizontal line that connects all variable gadgets along the virtual line of variables .
See Fig. 7, where the fixed structure is shaded in gray.

Vertices drawn as squares are fixed, i.e., they cannot change their position relative to other vertices drawn as squares.
Vertices drawn as circles are movable, i.e., they can change their position relative to vertices drawn as squares.
The line of variables extends from the the square vertices on the left and right boundaries of the drawing.
Every connector consists of two *pins*: the movable *assignment pin* and the fixed *reference pin*.
The variable gadget in Fig. 7 features four connectors: two above the horizontal line and two below the horizontal line.
Assignment pins are shaded in yellow and reference pins are shaded in gray.
The relative position of the assignment pin and the reference pin of one connector encodes the truth assignment of the underlying variable.
Moreover, the reference pin allows the fixed parts of the clause gadgets to be connected to the variable gadgets and thereby to the common frame.
Comparing Fig. 7 (a) and (b), observe how the relative position of the two pins of each connector changes depending on the truth assignment of the underlying variable.
The key structure of the variable gadget is that the position of the assignment pins of one variable gadget are coordinated by long edges.
In Fig. 7, long edges are drawn as thick lines.
Changing the slope of these long edges moves all assignment pins above the horizontal line in one direction and all assignment pins below the horizontal line in the reverse direction.
In this way, all connectors encode the same truth assignment of the underlying variable.
Note that we can introduce as many connectors as needed for any one variable.

The positive clause gadget consists of a fixed boundary, a movable *wiggle* and three *assignment pin endings*.
See Fig. 8, where the fixed boundary is shaded in gray, the wiggle is highlighted in blue and the assignment pin endings are highlighted in yellow.

The fixed boundary is connected to the reference pin of the variable gadget that is rightmost amongst the connected variable gadgets. Because the variable gadgets are fixed to the common frame, the boundary of the positive clause gadget is also connected to the common frame. The assignment pin endings are connected to assigment pins of connectors of the corresponding variable gadgets. The idea of the positive clause gadget is that the wiggle has to wiggle through the space bounded by the assignment pin endings on the left and the fixed boundary on the right. Recall that the assignment pins change their horizontal position depending on the truth assignment of their underlying variables. The positive clause gadget is designed so that the wiggle can always be drawn, except for the case when all variables are assigned to false. See Fig. 8 (a)–(c), which shows the three possible situations when exactly one variable is assigned to true. In any case where at least one variable is assigned to true the wiggle can be drawn in one of the three ways shown. However, as shown in Fig. 8 (d), the wiggle cannot be drawn in the case where all variables are assigned to false. The reason for this is that the the assignment pin endings get so close to the fixed boundary that they leave too little space for the wiggle to be drawn. This means that some vertices must intersect, for example those shown in red in Fig. 8 (d).

The negative clause gadgets works very similarly. It is drawn below the horizontal line of variables and it forces at least one of the incident variable gadgets to be configured as false. See Fig. 9, where subfigures (a)–(c) show the admissible drawings and subfigure (d) shows that the case when all incident variables are configured as true cannot occur.

Note that this uses the design of the variable gadget that the assignment and reference pins below the horizontal line are closer when the variable is assigned to true (i.e., the inverse situtation compared to the situation above the horizontal line).

It is evident that any level-planar two-slope grid drawing of the resulting graph induces a solution of the underlying planar monotone 3-Sat problem and vice versa. Note that the variable gadgets become biconnected when embedded into the common frame and that the clause gadgets are biconnected by design. Furthermore, all long edges have length two. We therefore conclude the following.

###### Theorem 0.A.1

The level-planar grid drawing problem is NP-complete even for two slopes and biconnected graphs where all edges have length one or two.