pyvista.DataSet.point_neighbors#

DataSet.point_neighbors(ind: int) list[int][source]#

Get the point neighbors of the ind-th point.

Parameters:
indint

Point ID.

Returns:
list[int]

List of neighbor points IDs for the ind-th point.

Examples

Get the point neighbors of the 0-th point.

>>> import pyvista as pv
>>> mesh = pv.Sphere(theta_resolution=10)
>>> mesh.point_neighbors(0)
[2, 226, 198, 170, 142, 114, 86, 254, 58, 30]

Plot them.

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh, show_edges=True)
>>>
>>> # Label the 0-th point
>>> _ = pl.add_point_labels(
...     mesh.points[0], ["0"], text_color="blue", font_size=40
... )
>>>
>>> # Get the point neighbors and plot them
>>> neighbors = mesh.point_neighbors(0)
>>> _ = pl.add_point_labels(
...     mesh.points[neighbors],
...     labels=[f"{i}" for i in neighbors],
...     text_color="red",
...     font_size=40,
... )
>>> pl.camera_position = "xy"
>>> pl.camera.zoom(7.0)
>>> pl.show()
../../../_images/pyvista-DataSet-point_neighbors-1_00_00.png