I have asked this question before in my previous post, but I'm still unable to generate the coding. I'm new to Mathematica and I am currently still having some troubles generating the code for finding the neighboring lists of triangles for a given triangulation. Here is what I have so far.
(* Number of data points *)
numpts = 5;
(* Test data set *)
pts = {{0, 0}, {1, 0}, {0, 1}, {1, 1}, {0.3, 0.4}};
dmesh = DelaunayMesh[pts];
(* Extract the triangle list from the Delaunay triangulation *)
tris = MeshCells[dmesh, 2];
numtris = Length[tris];
(* This demonstrates how to access the pts from the tris list *)
Print["Number of triangles numtris = ", numtris];
Do[
Print["Tri ", i,
" v1=", pts[[tris[[i, 1, 1]]]],
" v2=", pts[[tris[[i, 1, 2]]]],
" v3 = ", pts[[tris[[i, 1, 3]]]]],
{i, 1, numtris}
];
(* Data structure to hold neighbor data *)
nghbrs = Table[{0, 0, 0}, {i, 1, numtris}];
What I'm planning to do for the neighboring list is the following -For each vertex of each triangle, i, define the vertices of edge across from the current vertex, v2 and v3. For each triangle except for the current triangle, look for the triangle that shares the same vertices, v2 and v3, as across from the current vertex. If it is found, load this triangle as neighbor for the current triangle. Otherwise, set neighbor to -1.
I want to put what I'm planning to do for the neighboring list into a do loop but I am having some trouble with that. Can anybody help me by showing me what to input for the do loop? I would appreciate if you can help me with this. Thank you.