Sparse
reorder
spektral.utils.reorder(edge_index, edge_weight=None, edge_features=None)
Reorders edge_index
, edge_weight
, and edge_features
according to the row-major
ordering of edge_index
.
Arguments
-
edge_index
: np.array of shape[n_edges, 2]
(representing rows and columns of the adjacency matrix), indices to sort in row-major order. -
edge_weight
: np.array or None, edge weight to sort according to the new order of the indices. -
edge_features
: np.array or None, edge features to sort according to the new order of the indices.
Return
- edge_index: np.array, edge_index sorted in row-major order.
- edge_weight: If edge_weight is not None, edge_weight sorted according to the new order of the indices. Otherwise, None.
- edge_features: If edge_features is not None, edge_features sorted according to the new order of the indices. Otherwise, None.
sp_matrix_to_sp_tensor
spektral.utils.sp_matrix_to_sp_tensor(x)
Converts a Scipy sparse matrix to a SparseTensor. The indices of the output are reordered in the canonical row-major ordering, and duplicate entries are summed together (which is the default behaviour of Scipy).
Arguments
x
: a Scipy sparse matrix.
Return
A SparseTensor.