'How can I tell if a mesh is a plane from a topological point of view?

I need to distinguish between meshes that can be topologically transformed to a plane (a triangulated square, for example) and those that can not (a cube or a spherical mesh).

How would I do that - ideally in python, with a representation based on nodes and edges.

Even better if I can tell toruses etc. but that’s just a nice to have.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source