# Examples from pyvista.PolyData.vert_connectivity
# ================================================

import pyvista as pv
mesh = pv.PolyData([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [2.0, 0.0, 0.0]])
mesh.vert_connectivity

# The array is read-only and writing to it raises a `ValueError`.
mesh.vert_connectivity.flags['WRITEABLE']

# Assign a new array instead. Here the order of the vertex cells is reversed.
mesh.vert_connectivity = [2, 1, 0]
mesh.vert_connectivity

# For a mesh large enough that the copy matters, keep the connectivity array and
# edit it in place.
import numpy as np
connectivity = np.array([0, 1, 2], dtype=pv.ID_TYPE)
mesh.verts = pv.CellArray.from_arrays(
    [0, 1, 2, 3], connectivity, deep=False
)
connectivity[:] = [2, 0, 1]
mesh.vert_connectivity

# ----------------------------------------------------------------------
# Generated by sphinx-examples-as-code https://github.com/pyvista/sphinx-examples-as-code
