# Planarity

Planarity is a puzzle computer game by John Tantalo, based on a concept by Mary Radcliffe at Western Michigan University.[1] The name comes from the concept of planar graphs in graph theory; these are graphs that can be embedded in the Euclidean plane so that no edges intersect. By Fáry's theorem, if a graph is planar, it can be drawn without crossings so that all of its edges are straight line segments. In the planarity game, the player is presented with a circular layout of a planar graph, with all the vertices placed on a single circle and with many crossings. The goal for the player is to eliminate all of the crossings and construct a straight-line embedding of the graph by moving the vertices one by one into better positions.

## History and versions

The game was written in Flash by John Tantalo at Case Western Reserve University.[2] Online popularity and the local notoriety he gained placed Tantalo as one of Cleveland's most interesting people for 2006.[3][4] It in turn has inspired the creation of a GTK+ version by Xiph.org's Chris Montgomery, which possesses additional level generation algorithms and the ability to manipulate multiple nodes at once.[5]

## Puzzle generation algorithm

The definition of the planarity puzzle does not depend on how the planar graphs in the puzzle are generated, but the original implementation uses the following algorithm:

1. Generate a set of random lines in a plane such that no two lines are parallel and no three lines meet in a single point.
2. Calculate the intersections of every line pair.
3. Create a graph with a vertex for each intersection and an edge for each line segment connecting two intersections (the arrangement of the lines).

If a graph is generated from $L$ lines, then the graph will have exactly $\tbinom{L}{2} = \tfrac{L(L-1)}{2}$ vertices (each line has $L-1$ vertices, and each vertex is shared with one other line) and $L(L-2)$ edges (each line contains $L-2$ edges). The first level of Planarity is built with $L=4$ lines, so it has $L(L-1)/2=6$ vertices and $L(L-2)=8$ edges. Each level after is generated by one more line than the last. If a level was generated with $L$ lines, then the next level has $L$ more vertices and $2L-1$ more edges.

The best known algorithms from computational geometry for constructing the graphs of line arrangements solve the problem in $O(L^2)$ time,[6] linear in the size of the graph to be constructed, but they are somewhat complex. Alternatively and more simply, it is possible to index each crossing point by the pair of lines that cross at that point, sort the crossings along each line by their $x$-coordinates, and use this sorted ordering to generate the edges of the planar graph, in near-optimal $O(L^2\log L)$ time. Once the vertices and edges of the graph have been generated, they may be placed evenly around a circle using a random permutation.

## Related theoretical research

The problem of determining whether a graph is planar can be solved in linear time,[7] and any such graph is guaranteed to have a straight-line embedding by Fáry's theorem, that can also be found from the planar embedding in linear time.[8] Therefore, any puzzle could be solved in linear time by a computer. However, these puzzles are not as straightforward for human players to solve.

In the field of computational geometry, the process of moving a subset of the vertices in a graph embedding to eliminate edge crossings has been studied by Pach and Tardos (2002),[9] and others, inspired by the planarity puzzle.[10][11][12] The results of these researchers shows that (in theory, assuming that the field of play is the infinite plane rather than a bounded rectangle) it is always possible to solve the puzzle while leaving $n^\epsilon$ of the $n$ input vertices fixed in place at their original positions, for a constant $\epsilon$ that has not been determined precisely but lies between 1/4 and 1/2. When the planar graph to be untangled is a cycle graph, a larger number of vertices may be fixed in place. However, determining the largest number of vertices that may be left in place for a particular input puzzle (or equivalently, the smallest number of moves needed to solve the puzzle) is NP-complete.

Verbitsky (2008) has shown that the randomized circular layout used for the initial state of Planarity is nearly the worst possible in terms of its number of crossings: regardless of what planar graph is to be tangled, the expected value of the number of crossings for this layout is within a factor of three of the largest number of crossings among all layouts.[13]

## References

1. ^ Arar, Yardena (August 1, 2005), Cat's Cradle on Steroids, "Today @ PC World", PCWorld, archived from the original on 2009-06-04
2. ^ Massie, Laura (2005-06-20). "Case student develops booming on-line game". Case Western Reserve University News Center. Retrieved 2007-09-30.
3. ^ Castro, Laura (2005-11-18). "Case student one of Cleveland's "Most Interesting People"". The Observer. Retrieved 2007-09-30.
4. ^ "Most Interesting People 2006" (Press release). Cleveland Magazine. January, 2006. Retrieved 2007-09-30.
5. ^
6. ^ Chazelle, B.; Guibas, L. J.; Lee, D. T. (1985), "The power of geometric duality", BIT 25 (1): 76–90, doi:10.1007/BF01934990
7. ^ Mehlhorn, K.; Mutzel, P. (1996), "On the embedding phase of the Hopcroft and Tarjan planarity testing algorithm", Algorithmica 16 (2): 233–242, doi:10.1007/s004539900046, MR 1394503
8. ^ de Fraysseix, Hubert; Pach, János; Pollack, Richard (1990), "How to draw a planar graph on a grid", Combinatorica 10: 41–51, doi:10.1007/BF02122694, MR 1075065
9. ^ Pach, János; Tardos, Gábor (2002), "Untangling a polygon", Discrete & Computational Geometry 28 (4): 585–592, doi:10.1007/s00454-002-2889-y
10. ^ Bose, Prosenjit; Dujmovic, Vida; Hurtado, Ferran; Langerman, Stefan; Morin, Pat; Wood, David R. (2008), "A polynomial bound for untangling geometric planar graphs", Discrete & Computational Geometry 42 (4): 570–585, doi:10.1007/s00454-008-9125-3
11. ^ Cibulka, Josef (2009), "Untangling Polygons and Graphs", Discrete & Computational Geometry 43 (2): 402–411, doi:10.1007/s00454-009-9150-x
12. ^ Goaoc, Xavier; Kratochvíl, Jan; Okamoto, Yoshio; Shin, Chan-Su; Spillner, Andreas; Wolff, Alexander (2009), "Untangling a Planar Graph", Discrete & Computational Geometry 42 (4): 542–569, doi:10.1007/s00454-008-9130-6
13. ^ Verbitsky, Oleg (2008), "On the obfuscation complexity of planar graphs", Theoretical Computer Science 396 (1-3): 294–300, arXiv:0705.3748, doi:10.1016/j.tcs.2008.02.032, MR 2412266