mesh_degree_matrix
- compas.datastructures.mesh_degree_matrix(mesh, rtype='array')[source]
Creates a vertex degree matrix from a Mesh datastructure.
- Parameters
mesh (compas.datastructures.Mesh) – Instance of mesh.
rtype ({‘array’, ‘csc’, ‘csr’, ‘coo’, ‘list’}) – 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') >>> type(D) <class 'scipy.sparse.csr.csr_matrix'>
>>> D = mesh_degree_matrix(mesh) >>> D.diagonal() array([3., 3., 3., 3., 3., 3., 3., 3.])