RemoveSelfLoops
¶
Bases: BaseTransform
Removes the self-loops of a graph, together with their per-edge
attributes (e.g. edge_features, edge_labels).
Example:
graph = GraphData(edge_index=mx.array([[0, 1, 1], [1, 1, 2]]))
graph = RemoveSelfLoops()(graph)
graph.edge_index
# mx.array([[0, 1], [1, 2]])
Methods:
| Name | Description |
|---|---|
process |
Removes the self-loops of |
process
¶
Removes the self-loops of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph without self-loops. Its number of nodes is unchanged. |
Source code in mlx_graphs/transforms/structure.py
from mlx_graphs.transforms import RemoveSelfLoops · mlx_graphs/transforms/structure.py