mlx_graphs.utils.transformations.remove_self_loops

mlx_graphs.utils.transformations.remove_self_loops#

mlx_graphs.utils.transformations.remove_self_loops(edge_index: mlx.core.array, edge_features: mlx.core.array | None = None) mlx.core.array | tuple[mlx.core.array, mlx.core.array][source]#

Removes self-loops from the given graph represented by edge_index and edge_features.

Parameters:
  • edge_index (array) – a [2, num_edges] array representing the source and target nodes of each edge

  • edge_features (Optional[array]) – Optional tensor representing features associated with each edge, with shape [num_edges, num_edge_features]

Return type:

Union[array, tuple[array, array]]

Returns:

A tuple containing the updated edge_index and edge_features without self-loops.