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.digraph_node_link_json#
- digraph_node_link_json(graph, /, path=None, graph_attrs=None, node_attrs=None, edge_attrs=None)#
Generate a JSON object representing a
PyDiGraph
in a node-link format- Parameters:
graph (PyDiGraph) – The graph to generate the JSON for
path (str) – An optional path to write the JSON output to. If specified the function will not return anything and instead will write the JSON to the file specified.
graph_attrs – An optional callable that will be passed the
attrs
attribute of the graph and is expected to return a dictionary of string keys to string values representing the graph attributes. This dictionary will be included as attributes in the output JSON. If anything other than a dictionary with string keys and string values is returned an exception will be raised.node_attrs – An optional callable that will be passed the node data payload for each node in the graph and is expected to return a dictionary of string keys to string values representing the data payload. This dictionary will be used as the
data
field for each node.edge_attrs – An optional callable that will be passed the edge data payload for each node in the graph and is expected to return a dictionary of string keys to string values representing the data payload. This dictionary will be used as the
data
field for each edge.
- Returns:
Either the JSON string for the payload or
None
ifpath
is specified- Return type:
str