random_planar(g,n) --- create a random planar triangulation
SYNOPSIS
function random_planar(g,n)
DESCRIPTION
random_planar(g,n) --- create a random planar triangulation
This does NOT create a random "uniform" triangulation. Rather, it places
n points at random in the plane and builds the Delaunay triangulation
thereon.
0001 function random_planar(g,n)
0002 % random_planar(g,n) --- create a random planar triangulation
0003 % This does NOT create a random "uniform" triangulation. Rather, it places
0004 % n points at random in the plane and builds the Delaunay triangulation
0005 % thereon.
0006
0007 xy = rand(n,2)*sqrt(n);
0008 resize(g,0)
0009 resize(g,n)
0010 embed(g,xy)
0011
0012 triangles = delaunay(xy(:,1), xy(:,2));
0013 nt = size(triangles,1);
0014
0015 edges = [triangles(:,1:2); triangles(:,2:3); triangles(:,[1,3])];
0016 edges = sortrows(edges);
0017 edges = unique(edges,'rows');
0018 add(g,edges)