mesh_degree_matrix

compas.datastructures.mesh_degree_matrix(mesh, rtype='array')[source]

Creates a vertex degree matrix from a Mesh datastructure.

Parameters:
meshcompas.datastructures.Mesh

Instance of mesh.

rtypeLiteral[‘array’, ‘csc’, ‘csr’, ‘coo’, ‘list’], optional

Format of the result.

Returns:
array_like

Constructed vertex degree matrix.

Examples

>>> from compas.datastructures import Mesh
>>> mesh = Mesh.from_polyhedron(6)
>>> D = mesh_degree_matrix(mesh)
>>> type(D)
<class 'numpy.ndarray'>
>>> D = mesh_degree_matrix(mesh, rtype='csr')
>>> D = mesh_degree_matrix(mesh)
>>> D.diagonal()
array([3., 3., 3., 3., 3., 3., 3., 3.])