to_edge_index
¶
Converts an adjacency matrix to an edge index representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
adjacency_matrix
|
array
|
the input adjacency matrix |
required |
dtype
|
Dtype
|
type of the output edge_index. Default to uint32. |
uint32
|
Returns:
| Type | Description |
|---|---|
array
|
A [2, num_edges] array representing the source and target nodes of each edge |
Example:
matrix = mx.array(
[
[0, 1, 2],
[3, 0, 0],
[5, 1, 2],
]
)
edge_index = to_edge_index(matrix)
# mx.array([[0, 0, 1, 2, 2, 2], [1, 2, 0, 0, 1, 2]])
Source code in mlx_graphs/utils/transformations.py
from mlx_graphs.utils.transformations import to_edge_index · mlx_graphs/utils/transformations.py