# Checking if a Graph forms a Mesh

Given a random graph, I want to define a function MeshGraphQ that tests if the graph is a lattice (or mesh) graph. Here, I don't need the tiling to be regular. Therefore, I believe it is enough to check the following

1. If any two edges intersect.
2. If some part of the graph does not form a polygon.
3. If the graph is disconnected.

If any of these points are true, return False. Return True otherwise.

For example, I want MeshGraphQ to return True for the graphs

and False for the graphs

Just to give a bit of context, my goal is to slightly improve the graphToMesh function defined in this answer, in order to account for the cases where the graph does not define a lattice. I presume Mathematica already has some tools to help me do this, but I'm not used to working with graphs much, so any ideas/hints are appreciated.

• Please check the update. – Szabolcs Mar 15 at 16:42

1. To verify that the graph can be drawn in the plane without edge crossings, use PlanarGraphQ. But note that you could have a mesh on a toroidal surface and that is not planar. This check is not really necessary.
2. To verify that all faces of the graph form a polygon, check that it is biconnected: KVertexConnectedGraphQ[graph, 2]
3. To check that it is connected, use ConnectedGraphQ
• Regarding 1, it doesn't seem to work (doesn't work for the first example of those that should yield False). I'm only interested in 2D lattices. Any alternatives? Does the KVertexConnectedGraphQ function solve this? – sam wolfe Mar 15 at 21:04
• @samwolfe Are you saying that you have a non-planar graph for which PlanarGraphQ returns True? That could be a bug, but it's much more likely that you are mistaken about it being non-planar. You can edit an example into the question. BTW "If any two edges intersect" makes no sense for graphs, as graphs are not geometrical objects. If you are talking about a specific drawing of a graph, that's an entirely different thing. – Szabolcs Mar 15 at 21:29