%% 2-D Delaunay Triangulation
% Find neighboring triangles in a 2-D Delaunay triangulation.
% Create a 2-D Delaunay triangulation.

x = gallery('uniformdata',[10,1],0);
y = gallery('uniformdata',[10,1],1);
TR = delaunayTriangulation(x,y);

%
% Find the neighbors of the first triangle. NaN indicates that the triangle is on the boundary of the triangulation and only has two neighbors.

N = neighbors(TR,1)

%
% Examine the vertex IDs of the third neighbor.

TR.ConnectivityList(N(3),:)

% Copyright 2012 The MathWorks, Inc.