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:

    Waiting for the race to become official, he began to feel as if he had as much effect on the final outcome of the operation as a single piece of a jumbo jigsaw puzzle has to its predetermined final design. Only the addition of the missing fragments of the puzzle would reveal if the picture was as he guessed it would be.
    Stanley Kubrick (b. 1928)

    Once I prophesied that this generation of Americans had a rendezvous with destiny. That prophecy now comes true. To us much is given; more is expected. This generation will nobly save or mainly lose the last best hope of earth. The way is plain, peaceful, generous just. A way, which if followed, the world will forever applaud, and God must forever bless.
    Franklin D. Roosevelt (1882–1945)