What is the most efficient way to get adjacency information from a MeshRegion, i.e. some efficient representation of which vertex is connected to which other one?

The result could be a packed adjacency list, a sparse array or a Graph.


r = TriangulateMesh@DiscretizeRegion[Cuboid[]]

Now r["AdjacencyMatrix"] does not work. MeshCells[r,1] works well, but it gives a list of Lines, not a packed array.

adj1 = MeshCells[r, 1];

adj2 = Developer`ToPackedArray[adj1[[All, 1]]];

{ByteCount[adj1], ByteCount[adj2]}
(* {3433488, 312280} *)

You could use:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.