filter_adj
¶
filter_adj(
edge_index: array,
edge_features: Optional[array],
perm: array,
num_nodes: Optional[int] = None,
) -> tuple[array, Optional[array]]
Keeps the edges between the nodes perm, relabeled by their position
in perm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Edges of shape |
required |
edge_features
|
Optional[array]
|
Optional features of each edge, of shape
|
required |
perm
|
array
|
Indices of the kept nodes. Node |
required |
num_nodes
|
Optional[int]
|
Number of nodes. Default: |
None
|
Returns:
| Type | Description |
|---|---|
tuple[array, Optional[array]]
|
The filtered |
Example:
import mlx.core as mx
from mlx_graphs.nn import filter_adj
edge_index = mx.array([[0, 1, 2], [1, 2, 0]])
edge_index, _ = filter_adj(edge_index, None, mx.array([2, 0]))
>>> edge_index
array([[0],
[1]], dtype=int32)
Source code in mlx_graphs/nn/pooling/select.py
from mlx_graphs.nn import filter_adj · mlx_graphs/nn/pooling/select.py