xugrid.Ugrid1d.format_connectivity_as_sparse#

static Ugrid1d.format_connectivity_as_sparse(dense_connectivity: ndarray) csr_matrix#

Convert a rectangular dense connectivity array to a sparse CSR matrix.

This function converts a dense rectangular array with fill values representing irregular connectivities into a sparse CSR matrix where only the valid connections are stored. Irregular connectivities must be marked with a fill value of -1.

Parameters:

dense_connectivity (np.ndarray) – Connectivity in rectangular dense form, where each row contains the connections for an entity and -1 represents missing connections.

Returns:

sparse – Connectivity in CSR sparse format.

Return type:

scipy.sparse.csr_matrix