DataSetFilters.connectivity(largest=False, progress_bar=False)[source]#

Find and label connected bodies/volumes.

This adds an ID array to the point and cell data to distinguish separate connected bodies. This applies a vtkConnectivityFilter filter which extracts cells that share common points and/or meet other connectivity criterion.

Cells that share vertices and meet other connectivity criterion such as scalar range are known as a region.

largestbool, default: False

Extract the largest connected part of the mesh.

progress_barbool, optional

Display a progress bar to indicate progress.


Dataset with labeled connected bodies. Return type matches input.


Join two meshes together and plot their connectivity.

>>> import pyvista
>>> mesh = pyvista.Sphere() + pyvista.Sphere(center=(2, 0, 0))
>>> conn = mesh.connectivity(largest=False)
>>> conn.plot(cmap=['red', 'blue'])

See Volumetric Analysis for more examples using this filter.