Triangle Neighbors
in a Triangulation

TRIANGULATION_TRIANGLE_NEIGHBORS, a C program which computes the three neighboring triangles of each triangle in a triangulation.

The user supplies a node file and a triangle file, containing the coordinates of the nodes, and the indices of the nodes that make up each triangle. Either 3-node or 6-node triangles may be used.

The program reads the data, computes the triangle neighbor information, and writes out the information to a file. In cases where one side of a triangle has no triangle neighbor, a value of -1 is assigned.

The triangle neighbor array is useful if the triangulation has to be searched to find the triangle containing a given point. It is also useful when analyzing the bandwidth of the adjacency matrix, or of a finite element matrix derived from the triangulation.


triangulation_triangle_neighbors prefix
where prefix is the common filename prefix:


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


TRIANGULATION_TRIANGLE_NEIGHBORS is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

TRIANGLE, a C program which computes a triangulation of a geometric region.

TRIANGULATION, a C library which performs various operations on order 3 (linear) or order 6 (quadratic) triangulations.

TRIANGULATION_NODE_TO_ELEMENT, a C program which reads files describing a set of nodes, their triangulation, and the value of one or more quantities at each node, and outputs a file that averages the quantities for each element. This operation in effect creates an "order1" finite element model of the data.

TRIANGULATION_SVG, a C program which creates a Scalable Vector Graphics (SVG) image of a triangulation, which can be displayed by a web browser.


TRIG_TO_NEIB, a C program which reads "NODE" and "ELE" files (a format prescribed by triangle) describing a triangulation, and produces a file defining the neighbor triangles of each element; the program can also produce information about the Voronoi diagram. The program is by Lili Ju.


  1. Marc deBerg, Marc Krevald, Mark Overmars, Otfried Schwarzkopf,
    Computational Geometry,
    Springer, 2000,
    ISBN: 3-540-65620-0.
  2. Joseph ORourke,
    Computational Geometry,
    Second Edition,
    Cambridge, 1998,
    ISBN: 0521649765,
    LC: QA448.D38.

Source Code:

Last revised on 23 August 2019.