6
$\begingroup$

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

enter image description here

and False for the graphs

enter image description here

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.

$\endgroup$
  • 1
    $\begingroup$ Please check the update. $\endgroup$ – Szabolcs Mar 15 at 16:42
8
$\begingroup$
  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
| improve this answer | |
$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – sam wolfe Mar 15 at 21:04
  • 2
    $\begingroup$ @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. $\endgroup$ – Szabolcs Mar 15 at 21:29

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.