segregate_self_loops
¶
segregate_self_loops(
edge_index: array, edge_features: Optional[array] = None
) -> tuple[array, Optional[array], array, Optional[array]]
Splits the edges of a graph into the self-loops and the other edges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
a [2, num_edges] array representing the source and target nodes of each edge |
required |
edge_features
|
Optional[array]
|
Optional features of each edge, of shape
|
None
|
Returns:
| Type | Description |
|---|---|
array
|
A tuple `(edge_index, edge_features, loop_edge_index, |
Optional[array]
|
loop_edge_features)` with the edges that are not self-loops, their |
array
|
features, the self-loops and their features (features are |
Optional[array]
|
|
Example:
edge_index = mx.array([[0, 0, 1], [0, 1, 0]])
segregate_self_loops(edge_index)
# (mx.array([[0, 1], [1, 0]]), None, mx.array([[0], [0]]), None)
Source code in mlx_graphs/utils/loop.py
from mlx_graphs.utils import segregate_self_loops · mlx_graphs/utils/loop.py