mlx_graphs.utils.convert.to_networkx#
- mlx_graphs.utils.convert.to_networkx(data: GraphData, remove_self_loops: bool = False) networkx.DiGraph [source]#
Converts a
mlx_graphs.data.GraphData
instance to a a directednetworkx.DiGraph
otherwise.- Parameters:
- Return type:
- Returns:
A networkx graph
Examples:
import mlx.core as mx edge_index = mx.array( [ [0, 1, 1, 2, 2, 3], [1, 0, 2, 1, 3, 2], ] ) node_features = mx.array([[1], [1], [1], [1]]) data = GraphData(node_features=node_features, edge_index=edge_index) G = to_networkx(data) print(G.edges) >>> OutEdgeView([(0, 0), (0, 1), (1, 0), (1, 2), (2, 1), (2, 3), (3, 2)])