rllm.utils.adj_to_edge_index

class rllm.utils.adj_to_edge_index(adj: Tensor)[source]

Bases:

Convert a sparse adjacency matrix to an edge index tensor.

Parameters:

adj (Tensor) – A sparse adjacency tensor in COO, CSR, or CSC format.

Returns:

A tuple (edge_index, edge_attr) where edge_index has shape [2, num_edges] and edge_attr is None if all edge weights are 1.

Return type:

Tuple[Tensor, Optional[Tensor]]