Note
This is the documentation for the current state of the development branch of rustworkx. The documentation or APIs here can change prior to being released.
rustworkx.networkx_converter#
- networkx_converter(graph, keep_attributes=False)[source]#
Convert a networkx graph object into a rustworkx graph object.
Note
networkx is not a dependency of rustworkx and this function is provided as a convenience method for users of both networkx and rustworkx. This function will not work unless you install networkx independently.
- Parameters:
graph (networkx.Graph) – The networkx graph to convert.
keep_attributes (bool) – If
True, add networkx node attributes to the data payload in the nodes of the output rustworkx graph. When set toTrue, the node data payloads in the output rustworkx graph object will be dictionaries with the node attributes from the input networkx graph where the"__networkx_node__"key contains the node from the input networkx graph.
- Returns:
A rustworkx graph, either a
PyDiGraphor aPyGraphbased on whether the input graph is directed or not.- Return type: