to_undirected
¶
to_undirected(
edge_index: array,
edge_features: Optional[array] = None,
coalesce: bool = False,
num_nodes: Optional[int] = None,
reduce: str = "add",
) -> Union[array, tuple[array, array]]
Converts a graph given as edge_index and, optionally, edge_features
to an undirected one, by adding the reverse of every edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
The edge index of the graph. |
required |
edge_features
|
Optional[array]
|
Edge features associated with each edge. |
None
|
coalesce
|
bool
|
If |
False
|
num_nodes
|
Optional[int]
|
Number of nodes, only used when |
None
|
reduce
|
str
|
How the features of merged edges are combined when
|
'add'
|
Returns:
| Type | Description |
|---|---|
Union[array, tuple[array, array]]
|
The undirected |
Source code in mlx_graphs/utils/transformations.py
from mlx_graphs.utils.transformations import to_undirected · mlx_graphs/utils/transformations.py