neighbors_to_metis, a C++ code which reads a file describing the graph-theoretic adjacency structure of the elements in a mesh of triangles or tetrahedrons and writes out a similar file that is suitable for input to the mesh partitioning program metis().
Since we know we are dealing with a triangle or tet mesh, each "node" of the adjacency graph has 3 or 4 potential edges. If a potential edge is not used (in other words, if a face is a boundary face), then by convention we write out a "-1" for the neighbor value. Otherwise, the adjacency information lists the index of the element that is a neighbor on that face of the element
Converting to a METIS GRAPH format is trivial. We include an initial line that lists the number of "nodes" (elements) and "edges" (interfaces between pairs of elements), followed by, for each node (element), a list of the adjacent nodes (a list of the adjacent elements, omitting the "-1" values). A cross-eyed schoolboy sitting on a tack would be able to carry out this task!
The computer code and data files described and made available on this web page are distributed under the MIT license
neighbors_to_metis is available in a C++ version and a FORTRAN90 version and a MATLAB version.
METIS, a C library which partitions the nodes of a graph or the elements of a mesh, for division among a number of parallel processes, or to reorder the variables in a sparse matrix to minimize fillin;
METIS_GRAPH, a data directory of examples of METIS GRAPH files, the format for graphs to be read by METIS, which can partition a graph;
TET_MESH_TET_NEIGHBORS, a C++ code which reads information about a tet mesh and writes out a list of the tetrahedrons that are adjacent to a given tetrahedron;
TRIANGULATION_TRIANGLE_NEIGHBORS, a C++ code which reads data defining a triangulation, determines the neighboring triangles of each triangle, and writes that information to a file.