degree
¶
degree(
index: array,
num_nodes: Optional[int] = None,
edge_weights: Optional[array] = None,
) -> array
Counts the number of ocurrences of each node in the given index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
array
|
Array with node indices, usually src or dst of an |
required |
num_nodes
|
Optional[int]
|
Size of the output degree array. If not provided, the number
of nodes will be inferred from the |
None
|
edge_weights
|
Optional[array]
|
Optional edge weights that will be leveraged instead
of 1 values during the degree compute. Default: |
None
|
Returns:
| Type | Description |
|---|---|
array
|
Array of length |
Source code in mlx_graphs/utils/scatter.py
from mlx_graphs.utils.scatter import degree · mlx_graphs/utils/scatter.py