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:
- 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.
- Calculate the intersections of every line pair.
- 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:
“Scholars and artists thrown together are often annoyed at the puzzle of where they differ. Both work from knowledge; but I suspect they differ most importantly in the way their knowledge is come by. Scholars get theirs with conscientious thoroughness along projected lines of logic; poets theirs cavalierly and as it happens in and out of books. They stick to nothing deliberately, but let what will stick to them like burrs where they walk in the fields.”
—Robert Frost (18741963)
“Society in America means all the honest, kindly-mannered, pleasant- voiced women, and all the good, brave, unassuming men, between the Atlantic and the Pacific. Each of these has a free pass in every city and village, good for this generation only, and it depends on each to make use of this pass or not as it may happen to suit his or her fancy.”
—Henry Brooks Adams (18381918)