2
$\begingroup$

I would like to find an efficient way to detect whether a region has a hole regardless of how many it has. This question (Separate boundaries of multiply connected region) shows some methods but it relies on discretizing the region. One can also maybe convert the graphics to an image and use ImageMeasurements[#, "ContourHierarchy"]& but it also relies on discretization.

One algebraic geometry way is to use CylindricalDecomposition as in this question : Connectivity of semi-algebraic set. However that might be too complicated for complex geometries I am not sure.

A naive way would be to consider the center of the region and rotate an infinite line along a discrete set of angles but that might not work with small holes and might require computing a lot of intersections.

Is there an efficient or simple way to check if a region is simply connected ?

Examples:

Disk[]

Annulus[]

From documentation:

Polygon[{{0, 0}, {5, 0}, {2.5, 4}, {2, 1}, {2, 2}, {3, 2}, {3, 
 1}}, {1, 2, 3} -> {{4, 5, 6, 7}}]

enter image description here

From documentation on cylindrical decomposition under neat examples:

disk[{x0_, y0_}, r_] := (x - x0)^2 + (y - y0)^2 < r^2

 disk[{-7/4, 9/4}, 1/3] || 
    disk[{9/4, 9/4}, 
  1/3] || (disk[{0, 0}, 5] && ! disk[{2, 2}, 1] && ! 
    disk[{-2, 2}, 1] && (! disk[{0, -1}, Sqrt[5]] || disk[{0, 1}, 3]))

enter image description here

For polygons one can do:

RegionEqual[OuterPolygon[poly], poly]

EDIT :

Length@RegionBoundary[poly][[1]] > 1

works too

EDIT :

Length@RegionBoundary[Annulus[]][[2]] > 1

Works for an annulus (notice the 2 instead of one as it is a boolean region)

Maybe there is a way to use RegionBoundary without checking what it looks like.

$\endgroup$

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.