get_isolated_nodes_mask
¶
Returns the indices of non-isolated nodes, or of isolated nodes.
A node is isolated if it has no edge to another node (self-loops are ignored).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
Edge index from which to remove isolated nodes. |
required |
num_nodes
|
int
|
Number of nodes of the graph. |
required |
complement
|
bool
|
If |
True
|
Returns:
| Type | Description |
|---|---|
array
|
A sorted array of node indices. |
Example:
edge_index = mx.array([[0, 2, 0], [2, 0, 0]])
mask = get_isolated_nodes_mask(edge_index, 3)
>>> mx.array([0,2])
mask = get_isolated_nodes_mask(edge_index, 3, complement=False)
>>> mx.array([1])
Source code in mlx_graphs/utils/transformations.py
from mlx_graphs.utils.transformations import get_isolated_nodes_mask · mlx_graphs/utils/transformations.py