dgl.sparse.SparseMatrix.has_duplicate

SparseMatrix.has_duplicate()[source]

Returns True if the sparse matrix contains duplicate indices.

Examples

>>> indices = torch.tensor([[1, 0, 0, 0, 1], [1, 1, 1, 2, 2]])
>>> val = torch.tensor([0, 1, 2, 3, 4])
>>> A = dglsp.spmatrix(indices, val)
>>> A.has_duplicate()
True
>>> A.coalesce().has_duplicate()
False