RemoveDuplicatedEdges
¶
Bases: BaseTransform
Removes the duplicated edges of a graph and sorts the edges by source
then destination (see coalesce()).
The attributes of merged edges are combined with reduce.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Optional[Union[str, list[str]]]
|
Name(s) of the per-edge attributes to merge with |
None
|
reduce
|
str
|
How the attributes of merged edges are combined: |
'add'
|
Example:
graph = GraphData(
edge_index=mx.array([[0, 1, 0], [1, 2, 1]]),
edge_weights=mx.array([1.0, 2.0, 3.0]),
)
graph = RemoveDuplicatedEdges()(graph)
graph.edge_index
# mx.array([[0, 1], [1, 2]])
graph.edge_weights
# mx.array([4.0, 2.0])
Methods:
| Name | Description |
|---|---|
process |
Merges the duplicated edges of |
Source code in mlx_graphs/transforms/edge_cleanup.py
process
¶
Merges the duplicated edges of data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphData
|
The graph to transform. |
required |
Returns:
| Type | Description |
|---|---|
GraphData
|
The graph without duplicated edges. |
Source code in mlx_graphs/transforms/edge_cleanup.py
from mlx_graphs.transforms import RemoveDuplicatedEdges · mlx_graphs/transforms/edge_cleanup.py