Drawing Arrangement Graphs In Small Grids,
Or How To Play Planarity
Abstract
We describe a lineartime algorithm that finds a planar drawing of every graph of a simple line or pseudoline arrangement within a grid of area . No known input causes our algorithm to use area for any ; finding such an input would represent significant progress on the famous set problem from discrete geometry. Drawing line arrangement graphs is the main task in the Planarity puzzle.
1 Introduction
Planarity (http://planarity.net/) is a puzzle developed by John Tantalo and Mary Radcliffe in which the user moves the vertices of a planar graph, starting from a tangled circular layout (Figure 1), into a position where its edges (drawn as straight line segments) do not have any crossings. The game is played in a sequence of levels, of increasing difficulty. To construct the graph for the th level of the game, the game applet chooses random lines in general position in the plane. It creates a vertex for each of the crossings of two lines in this arrangement, and an edge for each of the pairs of crossings that are consecutive on the same line.
One strategy for solving Planarity would be to reconstruct a set of lines forming the given graph (Figure 2, left). However, this is tedious to do by hand, and has high computational complexity: testing whether an arrangement of curves can be stretched to form a combinatorially equivalent line arrangement is NPhard [21], from which it follows that recognizing the graphs of line arrangements is also NPhard [4]. More precisely, both problems are complete for the existential theory of the reals [18]. And although drawings constructed in this way accurately convey the underlying construction of the graph, they have low angular resolution (at most ) and close vertex spacing, making them hard to read and hard to place accurately by hand. Instead, in practice these puzzles may be solved more easily by an incremental embedding strategy that maintains a planar embedding of a subgraph of the input, starting from a single short cycle (such as a triangle or quadrilateral), and that at each step extends the embedding by a single face, bounded by a short path connecting two vertices on the boundary of the previous embedding. When using this strategy to solve a Planarity puzzle, the planar embedding may be kept tidy by placing each vertex into an approximate grid (Figure 2, right). Curiously, the grid drawings found by this incremental gridplacement heuristic appear to have nearlinear area; in contrast, there exist planar graphs such as the nested triangles graph that cannot be drawn planarly in a grid of less than area [7, 25].
In this paper we explain this empirical finding of small grid area by developing an efficient algorithm for constructing compact grid drawings of the arrangement graphs arising in Planarity. Because recognizing line arrangement graphs is NPhard, we identify a larger family of planar graphs (the graphs of simple pseudoline arrangements) that may be recognized and decomposed into their constituent pseudolines in linear time. We show that every vertex simple pseudoline arrangement graph may be drawn in linear time in a grid of size ; here is the maximum complexity of a level of a pseudoline arrangement with pseudolines [16, 23, 20], a topological variant of the famous set problem from discrete geometry (see Section 3 for a formal definition). The best proven upper bounds of on the complexity of levels [6, 23, 20] imply that the grid in which our algorithm draws these graphs has size and area . However, all known lower bounds on level complexity are of the form for all [16, 24], suggesting that our algorithm is likely to perform even better in practice than our worstcase bound. If we could find a constant and a family of inputs that would cause our algorithm to use area , such a result would represent significant progress on the set problem.
We also investigate the problem of constructing universal point sets for arrangement graphs, sets of points that can be used as the vertices for a straightline planar drawing of every vertex arrangement graph. Our construction directly provides a universal point set consisting of grid points; we show how to sparsify this structure, leading to the construction of a universal set of points in the form of a subset of a grid whose dimensions are again .
Finally, we formalize and justify an algorithm for manual solution of these puzzles that greedily finds short cycles and adds them as faces to a partial planar embedding. Although this algorithm may fail for general planar graphs, we show that for arrangement graphs it always finds a planar embedding that is combinatorially equivalent to the original arrangement.
2 Preliminaries
Following Shor [21], we define a pseudoline to be the image of a line under a homeomorphism of the Euclidean plane. Pseudolines include lines, nonselfcrossing polygonal chains starting and ending in infinite rays, and the graphs of continuous real functions. A crossing of two pseudolines is a point such that a neighborhood of can be mapped homeomorphically to a neighborhood of the crossing point of two lines, with the map taking the pseudolines to the lines within this neighborhood. An arrangement of pseudolines is a finite set of pseudolines, the intersection of every two of which is a single crossing point. An arrangement is simple if all pairs of pseudolines have distinct crossing points. A pseudoline arrangement graph is a planar graph whose vertices correspond to the crossings in a simple pseudoline arrangement, and whose edges connect consecutive crossings on a common pseudoline.
Most of the ideas in the following result are from Bose et al. [4], but we elaborate on that paper to show that linear time recognition of arrangement graphs is possible. (See [9] for a more complicated linear time algorithm that recognizes the dual graphs of a wider class of arrangement graphs, the graphs of weak pseudoline arrangements in which pairs of pseudolines need not cross)
Lemma 1
If we are given as input a graph , then in linear time we can determine whether it is a pseudoline arrangement graph, determine its (unique) embedding as an arrangement graph, and find a pseudoline arrangement for which it is the arrangement graph.
Proof
Let be formed from a pseudoline arrangement graph by adding a new vertex adjacent to all vertices in of degree less than four. As Bose et al. [4] show, is 3connected and planar, and its unique planar embedding is compatible with the embedding of as an arrangement graph. For convenience we include two edges in from to each degree two vertex in , so that, in , all vertices except have degree four. With this modification, the pseudolines of the arrangement for are represented in by paths starting and ending at that, at each other vertex, connect two opposite edges in the embedding.
For any given graph of maximum degree four we may, in linear time, add a new vertex , test planarity of the augmented graph , and embed in the plane. The edge partition of into paths through opposite edges at each degree four vertex may be found in linear time by connected component analysis. By labeling each edge with the identity of its path, we may verify that this partition does not include cycles disjoint from and that no path crosses itself. We additionally check that has vertices, where is the number of paths. Finally, by listing the pairs of paths passing through each vertex and bucket sorting this list, we may verify in linear time that no two paths cross more than once. If passes all of these checks, its decomposition into paths gives a valid pseudoline arrangement, which may be constructed by viewing the embedding of as being on a sphere, puncturing the sphere at point , and homeomorphically mapping the punctured sphere to the plane.
3 Small Grids
To describe our grid drawing algorithm for pseudoline arrangement graphs, we need to introduce the concept of a wiring diagram. A wiring diagram is a particular kind of pseudoline arrangement, in which the pseudolines largely lie on horizontal lines (with coordinates , , , ). The pseudolines on two adjacent tracks may cross each other, swapping which track they lie on, near points with coordinates , , , ; each crossing is formed by removing two short segments of track and replacing them by two crossing line segments between the tracks. It is convenient to require different crossings to have different coordinates, following Goodman [12], although some later sources omit this requirement. Figure 4 depicts an example. Wiring diagrams already provide reasonably nice grid drawings of arrangement graphs [17], but are unsuitable for our purposes, for two reasons: they draw the edges connecting pairs of adjacent crossings as polygonal chains with two bends, and for some arrangements, even allowing crossings to share coordinates, drawing the wiring diagram of lines in a grid may require width (Figure 5), much larger than our bounds. Instead, we will use these diagrams as a tool for constructing a different and more compact straightline drawing.
For an arrangement of nonvertical lines in general position, an equivalent wiring diagram may be constructed by a plane sweep algorithm [3], which simulates the lefttoright motion of a vertical line across the arrangement. At most points in the sweep, the intersection points of the arrangement lines with the sweep line maintain a fixed toptobottom order with each other, with their positions in this order reflected in the assignment of the corresponding pseudolines to tracks. When the sweep line crosses a vertex of the arrangement, two intersection points swap positions in the toptobottom order, corresponding to a crossing in the wiring diagram. The lefttoright order of crossings in the wiring diagram is thus exactly the sorted order of the crossing points of the arrangement, as sorted by their coordinates. The wiring diagram in Figure 4 was constructed in this way from the approximate line arrangement depicted in Figure 1.
Every simple pseudoline arrangement, also, has an equivalent wiring diagram, that may be constructed in time linear in its number of crossings. The proof of this fact uses topological sweeping, a variant of plane sweeping originally developed to speed up sweeping of straight line arrangements by relaxing the strict lefttoright ordering of the crossing points [8], that can also be extended to apply to pseudoline arrangements [22]. The steps of the topological sweeping algorithm require only determining the relative ordering of crossings along each of the input pseudolines, something that may easily be determined from our path decomposition of a pseudoline arrangement graph by precomputing the position of each crossing on each of the two pseudolines it belongs to.
We define the th level in a wiring diagram to be the set of crossings that occur between tracks and . A crossing belongs to if and only if lines pass between it and the bottom face of the arrangement (the face below all of the tracks in the wiring diagram); therefore, once this bottom face is determined, the levels are fixed by this choice regardless of how the crossings are ordered to form a wiring diagram. If we define the size of a diagram to be its number of pseudolines, and the level complexity to be , then it is a longstanding open problem in discrete geometry (a variant of the set problem) to determine the maximum level complexity of an arrangement of pseudolines, . The known bounds on this quantity are [6, 23, 20], and for some constant [16, 24], where the last bound is for all constants .
Theorem 3.1
Let be a pseudoline arrangement graph with vertices, determined by pseudolines. Then in time we may construct a planar straightline drawing of , in a grid of size .
Proof
We find a decomposition of into pseudoline paths, by the algorithm of Lemma 1, and use topological sweeping to convert this decomposition into a wiring diagram. We place each vertex of at the coordinates , where is the position of within its level of the wiring diagram and is the number of tracks below its level of the wiring diagram.
With this layout, every edge of either connects consecutive vertices within the same level as each other, or it connects vertices on two consecutive levels. In the latter case, each edge between two consecutive levels corresponds to a horizontal segment of the wiring diagram that lies on the track between the two levels; the lefttoright ordering of these horizontal segments is the same as the lefttoright ordering of both the lower endpoints and the upper endpoints of these edges. Because of this consistent ordering of endpoints, no two edges between the same two consecutive levels can cross. There can also not be any crossings between edges that do not both lie in the same level or connect the same two consecutive levels. Therefore, the drawing we have constructed is planar. By construction, it has the dimensions given in the theorem.
Figure 6 depicts the output of our algorithm, using the wiring diagram of Figure 4, for the graph of Figure 1. Although the grid found by this algorithm is not quite as compact as the manuallyfound grid of Figure 2, it is much smaller than standard grid drawings that do not take advantage of the arrangement structure of this graph. A more careful placement of vertices within each row would improve the angular resolution and edge length of the drawing but we have omitted this step in order to make the construction more clear.
4 Universal Point Sets
A universal point set for the vertex graphs in a class of graphs is a set of points in the plane such that every vertex graph in can be drawn with its vertices in and with its edges drawn as noncrossing straight line segments [5]. Grids of points form universal sets of quadratic size for the planar graphs [10, 19], and despite very recent improvements to the constant factor in this quadratic size bound [2] this remains the best known upper bound. A rectangular grid that is universal must have points [7, 25]; the best known lower bounds for universal point sets that are not required to be grids are only linear [5].
Subquadratic bounds are known on the size of universal point sets for subclasses of the planar graphs including the outerplanar graphs [14], simplynested planar graphs [1, 2], planar 3trees [11], and graphs of bounded pathwidth [2]; however, these results do not apply to arrangement graphs. The grid drawing technique of Theorem 3.1 immediately provides a universal point set for arrangement graphs of size ; in this section we significantly improve this bound, while only increasing the area of our drawings by a constant factor.
Following Bannister et al. [2], define a sequence of positive integers for by the equation where denotes the bitwise binary exclusive or operation. The sequence of these values begins
Lemma 2 (Bannister et al. [2])
Let the finite sequence have sum . Then there is a subsequence of the first terms of such that, for all , . The sum of the first terms of is between and .
Recall that the grid drawing technique of Theorem 3.1 produces a drawing in which the vertices are organized into rows of at most vertices per row, where is the number of lines in the underlying vertex arrangement. In this drawing, suppose that there are vertices on the th row of the drawing, and define a sequence .
Lemma 3
.
Proof
We may partition the vertices in the th row into groups of exactly vertices, together with at most one smaller group; then is the number of groups. The contribution to from the groups of exactly vertices is at most . There is at most one smaller group per row so the contribution from the smaller groups is at most . Thus the total value of the sum is at most .
Theorem 4.1
There is a universal point set of points for the vertex arrangement graphs, forming a subset of a grid of dimensions .
Proof
Let . We form our universal point set as a subset of an grid; the area of the grid from which the points are drawn is exactly 3/2 times the area of the row grid drawing technique of Theorem 3.1. In the th row of this grid, we include in our universal point set of the grid vertices in that row. It does not matter for our construction exactly which points of the row are chosen to make this number of points.
By Lemma 2, there is a subsequence of the first rows of sequence , such that the is termwise greater than or equal to . This subsequence corresponds to a subsequence of the rows of our universal point set, such that row has at least points in it. Mapping the th row of the drawing of Theorem 3.1 to row of this point set will not create any crossings, because the mapping is monotonic within each row and because all edges of the drawing connect pairs of vertices that are either in the same row or in consecutive rows.
The number of points in the point set is where . Therefore, this number of points is .
5 Greedy embedding algorithm
The algorithm of Lemma 1 uses as a subroutine a lineartime planarity testing algorithm. Although such algorithms may be efficiently implemented on computers, they are not really suitable for hand solution of Planarity puzzles. Instead, it is more effective in practice to build up a planar embedding one face at a time, by repeatedly finding a short cycle in the input graph and attaching it to the previously constructed partial embedding. Here “short” means as short as can be found; it is not possible to limit attention to cycles of length three, four, or any fixed bound. For instance in Figure 3 the central triangle is separated from the rest of the graph by faces with five sides, and by modifying this example it is possible to separate part of an arrangement graph from the rest of the graph by faces with arbitrarily many sides. Thus, this handsolution heuristic may be formalized by the following steps.

Choose an arbitrary starting vertex .

Find a cycle of minimum possible length containing .

Embed as a simple cycle in the plane.

While some of the edges of the input graph have not yet been embedded:

Let be the cycle bounding the current partial embedding. Define an attachment vertex of to be a vertex that is incident with edges not already part of the current embedding.

Choose two attachment vertices and , and a path in from to , such that there are no attachment vertices interior to .

Find a shortest path from to , using only edges that are not already part of the current partial embedding.

If necessary, adjust the positions of the embedded vertices (without changing the combinatorial structure of the embedding) so that may be drawn with straight line edges.

Add to the embedding, outside , so that the new face between and does not contain . After this change, the new bounding cycle of the partial embedding is formed from by replacing by .

When it is successful, this algorithm decomposes the input graph into the cycle and a sequence of edgedisjoint paths , , etc. Such a decomposition is known as an open ear decomposition [15].
This greedy ear decomposition algorithm does not always work for arbitrary planar graphs: even the initial cycle that is found by the algorithm may not be a face of an embedding of the given graph, causing the algorithm to make incorrect assumptions about the structure of the embedding. However (ignoring the possible difficulty of performing step d) the algorithm does always correctly embed the arrangement graphs used by Planarity. These graphs may have multiple embeddings; to distinguish among them, define the canonical embedding of an arrangement graph to be the one given by the arrangement from which it was constructed. By Lemma 1, the canonical embedding is unique. As we prove below, the cycles of an arrangement graph that the algorithm assumes to be faces really are faces of the canonical embedding.
Lemma 4
Let be an arbitrary vertex of arrangement graph , and be a shortest cycle containing . Then is a face of the canonical embedding of .
Proof
Let be an arbitrary simple cycle through . Then if is not a face of the arrangement forming , there is a line that crosses it; let and be two vertices on the boundary of connected through the interior of by (Figure 7). Then together with the path along from to form a thetagraph, a graph with two degree three vertices ( and ) connected by three paths. Every vertex of between and is caused by a crossing of with another line that also must cross the other two paths of the thetagraph; in addition, each of these two paths must bend at least once at a vertex that does not correspond to a line that crosses . Therefore, the path through is strictly shorter than the other two paths in the thetagraph. Replacing one of the two paths of from to by the path through produces a shorter cycle that still contains . Since an arbitrary cycle that is not a face can be replaced by a shorter cycle through , it follows that every shortest cycle through is a face.
Lemma 5
Let be a drawing of a subset of the faces of the canonical embedding of an arrangement graph whose union is a topological disk, let and be two attachment vertices on the boundary of with no attachment vertices interior to the boundary path from to , and let be a shortest path from to using only edges not already part of . Then the cycle formed by the union of and is a face of the canonical embedding of .
Proof
Assume for a contradiction that is not a face; then as in the proof of Lemma 4, this cycle must be crossed by a line , a path of which forms a thetagraph together with . Additionally, because is assumed to be part of a drawing of a subset of the faces of , it cannot be crossed by , for any crossing would cause it to have an attachment vertex between and . Therefore, the two degreethree vertices of the thetagraph both belong to . By the same reasoning as in the proof of Lemma 4, must be strictly shorter than the other two paths of the thetagraph, so replacing the path that is entirely within by would produce a shorter path from to , contradicting the construction of as a shortest path. This contradiction shows that must be a face, as the lemma states.
Theorem 5.1
When the greedy ear decomposition embedding algorithm described above is applied to an arrangement graph , it correctly constructs the canonical embedding of .
Proof
We use induction on the number of steps of the algorithm, with an induction hypothesis that after each step the partial embedding found so far consists of faces of the canonical embedding whose union is a disk. Lemma 4 shows as a base case that the induction hypothesis is true after the first step. In each subsequent step, the ability to find two attachment vertices follows from the fact that arrangement graphs are 2vertexconnected, which in turn follows from the fact that they can be augmented by a single vertex to be 3vertexconnected [4]. Lemma 5 shows that, if the induction hypothesis is true after steps then it remains true after steps.
6 Conclusions
We have found a grid drawing algorithm for pseudoline arrangement graphs that uses area within a small factor of linear, much smaller than the known quadratic grid area lower bounds for arbitrary planar graphs. We have also shown that these graphs have nearlinear universal point sets within a constant factor of the same area, and that a simple greedy embedding heuristic suitable for hand solution of Planarity puzzles is guaranteed to find a correct embedding.
The precise area used by our grid drawing algorithm depends on the worstcase behavior of the function counting the number of crossings in a level of an arrangement; closing the gap between the upper and lower bounds for this function remains an important and difficult open problem in combinatorial geometry. However, closing this gap is not the only possible method for improving our drawing algorithm.
A tempting avenue for improvement is to observe that a single pseudoline arrangement may be represented by many different wiring diagrams; therefore, we can select the wiring diagram that represent the same pseudoline arrangement and that minimizes . However, this would not improve our worst case width by more than a constant factor. For, if the input forms a pseudoline arrangement constructed by stacking two arrangements of lines with maximal level complexity, one above the other (Figure 8), then one of these two instances will survive intact in any wiring diagram for the arrangement, forcing our algorithm to produce a drawing with width at least . Further improvements in our algorithm will likely come by finding an alternative layout that avoids the complexity of levels, by proving that levels are small in the average case if not the worst case, or by reducing the known combinatorial bounds on levels.
References
 [1] P. Angelini, G. Di Battista, M. Kaufmann, T. Mchedlidze, V. Roselli, and C. Squarcella. Small point sets for simplynested planar graphs. Proc. 19th Int. Symp. Graph Drawing (GD 2011), pp. 75–85. Springer, LNCS 7034, 2012, doi:10.1007/9783642258787_8.
 [2] M. J. Bannister, Z. Cheng, W. E. Devanny, and D. Eppstein. Superpatterns and universal point sets. Manuscript, 2013.
 [3] J. L. Bentley and T. A. Ottmann. Algorithms for reporting and counting geometric intersections. IEEE Transactions on Computers C28(9):643–647, 1979, doi:10.1109/TC.1979.1675432.
 [4] P. Bose, H. Everett, and S. Wismath. Properties of arrangement graphs. International Journal of Computational Geometry & Applications 13(6):447–462, 2003, doi:10.1142/S0218195903001281.
 [5] M. Chrobak and H. Karloff. A lower bound on the size of universal sets for planar graphs. SIGACT News 20:83–86, 1989.
 [6] T. L. Dey. Improved bounds for planar sets and related problems. Discrete and Computational Geometry 19(3):373–382, 1998, doi:10.1007/PL00009354.
 [7] D. Dolev, T. Leighton, and H. Trickey. Planar embedding of planar graphs. Advances in Computing Research 2:147–161, 1984.
 [8] H. Edelsbrunner and L. J. Guibas. Topologically sweeping an arrangement. Journal of Computer and System Sciences 38(1):165–194, 1989, doi:10.1016/00220000(89)90038X. Corrigendum, JCSS 42 (2): 249–251, 1991.
 [9] D. Eppstein. Algorithms for drawing media. Proc. 12th Int. Symp. Graph Drawing (GD 2004), pp. 173–183. Springer, LNCS 3383, 2005, doi:10.1007/9783540318439_19, arXiv:cs.DS/0406020.
 [10] H. de Fraysseix, J. Pach, and R. Pollack. Small sets supporting Fáry embeddings of planar graphs. Proc. 20th ACM Symp. Theory of Computing (STOC 1988), pp. 426–433, 1988, doi:10.1145/62212.62254.
 [11] R. Fulek and C. Toth. Universal point sets for planar threetrees. Algorithms and Data Structures Symposium (WADS). Springer, LNCS, 2013, arXiv:1212.6148.
 [12] J. E. Goodman. Proof of a conjecture of Burr, Grünbaum, and Sloane. Discrete Mathematics 32(1):27–35, 1980, doi:10.1016/0012365X(80)900965.
 [13] J. E. Goodman. Pseudoline arrangements. Handbook of Discrete and Computational Geometry, pp. 83–109. CRC Press, 1997.
 [14] P. Gritzmann, B. Mohar, J. Pach, and R. Pollack. Embedding a planar triangulation with vertices at specified positions. Amer. Math. Monthly 98(2):165–166, 1991, http://www.jstor.org/stable/2323956.
 [15] S. Khuller. Ear decompositions. SIGACT News 20(1):128, 1989.
 [16] M. Klawe, M. Paterson, and N. Pippenger. Inversions with transpositions at the median. Unpublished manuscript, September 21 1982.
 [17] S. Muthukrishnan, S. C. Sahinalp, and M. S. Paterson. Grid layout of switching and sorting networks. US Patent 6185220, 2001.
 [18] M. Schaefer. Complexity of some geometric and topological problems. Proc. 17th Int. Symp. Graph Drawing (GD 2009), pp. 334–344. Springer, LNCS 5849, 2010, doi:10.1007/9783642118050_32, http://ovid.cs.depaul.edu/documents/convex.pdf.
 [19] W. Schnyder. Embedding planar graphs on the grid. Proc. 1st ACM/SIAM Symp. Discrete Algorithms (SODA 1990), pp. 138–148, 1990.
 [20] M. Sharir and S. Smorodinsky. Extremal configurations and levels in pseudoline arrangements. Algorithms and Data Structures: 8th International Workshop, WADS 2003, Ottawa, Ontario, Canada, July 30  August 1, 2003, Proceedings, pp. 127–139. Springer, LNCS 2748, 2003, doi:10.1007/9783540450788_12.
 [21] P. W. Shor. Stretchability of pseudolines is NPhard. Applied Geometry and Discrete Mathematics: The Victor Klee Festschrift, pp. 531–554. Amer. Math. Soc., DIMACS Series in Discrete Mathematics and Theoretical Computer Science 4, 1991.
 [22] J. Snoeyink and J. Hershberger. Sweeping arrangements of curves. Proc. 5th ACM Symp. on Computational Geometry (SCG ’89), pp. 354–363, 1989, doi:10.1145/73833.73872.
 [23] H. Tamaki and T. Tokuyama. A characterization of planar graphs by pseudoline arrangements. Algorithmica 35(3):269–285, 2003, doi:10.1007/s0045300209999.
 [24] G. Tóth. Point sets with many sets. Discrete and Computational Geometry 26(2):187–194, 2001, doi:10.1007/s004540010022.
 [25] L. G. Valiant. Universality considerations in VLSI circuits. IEEE Transactions on Computers C30(2):135–140, 1981, doi:10.1109/TC.1981.6312176.