to_adjacency_matrix
¶
to_adjacency_matrix(
edge_index: array,
edge_features: Optional[array] = None,
num_nodes: Optional[int] = None,
) -> array
Converts an edge index representation to an adjacency matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edge_index
|
array
|
a [2, num_edges] array representing the source and target nodes of each edge |
required |
edge_features
|
Optional[array]
|
a 1-dimensional array representing the features corresponding to the edges in edge_index. Defaults to None. |
None
|
num_nodes
|
Optional[int]
|
the number of nodes in the graph. Defaults to the number of nodes in edge_index |
None
|
Returns:
| Type | Description |
|---|---|
array
|
The resulting adjacency matrix |
Source code in mlx_graphs/utils/transformations.py
from mlx_graphs.utils.transformations import to_adjacency_matrix · mlx_graphs/utils/transformations.py