mindspore_gl.graph.remove_self_loop
- mindspore_gl.graph.remove_self_loop(adj, mode='dense')[source]
Remove the diagonal matrix from the input matrix object, you can choose to operate on a dense matrix or a matrix in COO format.
- Parameters
adj (scipy.sparse.coo) – Target matrix.
mode (str, optional) – type of operation matrix. Support type is
'dense'
and'coo'
. Default:'dense'
.
- Returns
adj (scipy.sparse.coo) - The object after removing the diagonal matrix.
'dense'
returns the Tensor type.'coo'
returns the scipy.sparse.coo type.
- Supported Platforms:
Ascend
GPU
Examples
>>> from mindspore_gl.graph.self_loop import remove_self_loop >>> import scipy.sparse as sp >>> adj = sp.csr_matrix(([1, 2, 3, 4], ([0, 1, 2, 2], [0, 1, 2, 1])), shape=(3, 3)).tocoo() >>> adj = remove_self_loop(adj, 'coo') >>> print(adj) (1, 2) 4