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:

    The at present unutterable things we may find somewhere uttered. These same questions that disturb and puzzle and confound us have in their turn occurred to all the wise men; not one has been omitted; and each has answered them, according to his ability, by his words and his life.
    Henry David Thoreau (1817–1862)

    My generation of the Sixties, with all our great ideals, destroyed liberalism, because of our excesses.
    Camille Paglia (b. 1947)