dgl.sparse.SparseMatrix.transpose

SparseMatrix.transpose()[source]

Returns the transpose of this sparse matrix.

Returns:

The transpose of this sparse matrix.

Return type:

SparseMatrix

Examples

>>> indices = torch.tensor([[1, 1, 3], [2, 1, 3]])
>>> val = torch.tensor([1, 1, 2])
>>> A = dglsp.spmatrix(indices, val)
>>> A = A.transpose()
SparseMatrix(indices=tensor([[2, 1, 3],
                             [1, 1, 3]]),
             values=tensor([1, 1, 2]),
             shape=(4, 4), nnz=3)