Planarity - Puzzle Generation Algorithm

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 lines, then the graph will have exactly vertices (each line has vertices, and each vertex is shared with one other line) and edges (each line contains edges). The first level of Planarity is built with lines, so it has vertices and edges. Each level after is generated by one more line than the last. If a level was generated with lines, then the next level has more vertices and more edges.

The best known algorithms from computational geometry for constructing the graphs of line arrangements solve the problem in time, 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 -coordinates, and use this sorted ordering to generate the edges of the planar graph, in near-optimal time. Once the vertices and edges of the graph have been generated, they may be placed evenly around a circle using a random permutation.

Read more about this topic:  Planarity

Famous quotes containing the words puzzle and/or generation:

    —My good friend, quoth I—as sure as I am I—and you are you
    —And who are you? said he.—Don’t puzzle me; said I.
    Laurence Sterne (1713–1768)

    ... if women once learn to be something themselves, that the only way to teach is to be fine and shining examples, we will have in one generation the most remarkable and glorious children.
    Brenda Ueland (1891–1985)