20

What is the most efficient way to generate a large (~ 300k vertices) random planar graph ("random" here means uniformly distributed)?

Tomas
  • 52,167
  • 46
  • 207
  • 345
Marat Salikhov
  • 5,819
  • 4
  • 29
  • 33

5 Answers5

7

Another possibility consists in randomly choosing coordinates and then compute a Delaunay Triangulation, which is a planar graph (and looks nice as well). See http://en.wikipedia.org/wiki/Delaunay_triangulation There are O(n log(n)) algorithms to compute such a triangulation.

4

Have you looked at Boltzmann sampling? See the paper by Eric Fusy "Uniform random sampling of planar graphs in linear time". The paper and the implementation are available in his homepage which the paper says can generate instances of size 100K in a few seconds.

Valentas
  • 1,536
  • 14
  • 22
3

Without any other requirements, I'd say look up random maze generation. If you want cycles in the graph, remove some walls at random from a simple maze. The intersections in the maze become the nodes in your graph and the removed walls are the edges. That means you can select the number of nodes by choosing the size of the maze.

Mazes are typically done on a 2d grid with at most 4 connections from one point to another, but there is nothing stopping you from doing a maze on hex tiles, or something else.

phkahler
  • 5,474
  • 1
  • 20
  • 31
2

If by uniform you mean uniformly distributed in space, then this is a pretty fast algorithm I developed for generating planar graphs for a spatial ecological/evolutionary simulator. It will generate random planar graphs with an expected degree you specify, of course with some variation around it. You could extend it to pick the expected degree based on a uniform random number if instead you wanted uniform random degrees in your planar graph.

https://github.com/briandconnelly/seeds/blob/master/seeds/plugins/topology/CartesianTopology.py

Peter O.
  • 28,965
  • 14
  • 72
  • 87
LuisZaman
  • 104
  • 4
  • 3
    It seems this algorithm can generate graphs whose edges cross ? That is not a planar graph. For example, if there are 4 points in a circle of the given radius, they will all connect to each other and the diagonals will cross, making the graph non-planar. – Sid Datta Nov 29 '12 at 21:10
1

Well one method would be to try and generate a random graph which satisfies similar constraints as a planar graph (for instance, edges <= 3*vertices - 6) and check if it is planar in O(n) time using Tarjan's planarity testing algorithm. If it is not planar, generate again. Not sure how efficient this would be for 300K vertices!, though (or if it will even give you graphs with uniform probability).

There is some literature on generating planar graphs, I could find one paper here : Generating Labeled Planar Graphs which apparently has expected O(n^4) running time, and might not be worth it either. Perhaps the references there will help you track down something that might help.

Good luck!

  • 3
    surely almost all random graphs are not planar? – andrew cooke Jan 15 '13 at 11:35
  • 1
    Random graphs are planar with only exponentially small probability, meaning the suggested algorithm has exponential time complexity! Alas, random graphs have a completely different structure than planar graphs (e.g. spectral properties). – user2316602 Mar 16 '19 at 19:57