mlx_graphs.utils.scatter.degree

Contents

mlx_graphs.utils.scatter.degree#

mlx_graphs.utils.scatter.degree(index: mlx.core.array, num_nodes: int | None = None, edge_weights: mlx.core.array | None = None) mlx.core.array[source]#

Counts the number of ocurrences of each node in the given index.

Parameters:
  • index (array) – Array with node indices, usually src or dst of an edge_index.

  • num_nodes (Optional[int]) – Size of the output degree array. If not provided, the number of nodes will be inferred from the index.

  • edge_weights (Optional[array]) – Optional edge weights that will be leveraged instead of 1 values during the degree compute. Default: None

Return type:

array

Returns:

Array of length num_nodes with the degree of each node.