grakelx.networkx_from_graph

grakelx.networkx_from_graph(X: Graph | Iterable[Graph], node_labels_tag: str | None = None, edge_labels_tag: str | None = None, edge_weight_tag: str = 'weight', create_using: type[nx.Graph] | None = None) nx.Graph | list[nx.Graph][source][source]

Transform grakel.Graph objects to networkx graph objects.

Inverse operation of graph_from_networkx. Iterates the edge_dictionary of each input graph and writes nodes, edges and (optionally) labels and weights as networkx node/edge attributes.

Parameters:
Xgrakel.Graph or Iterable[grakel.Graph]

A GraKeL graph or an iterable of GraKeL graphs.

node_labels_tagstr or None, default=None

If provided, the dictionary labels of every node are written as a node attribute with this tag. If None no node attribute is written.

edge_labels_tagstr or None, default=None

If provided, the dictionary labels of every edge are written as an edge attribute with this tag. If None no edge attribute is written.

edge_weight_tagstr or None, default=”weight”

If provided, the weight of every edge is written as an edge attribute with this tag. The default "weight" follows the NetworkX convention. Set to None to skip writing weights.

create_usingtype[networkx.Graph] or None, default=None

NetworkX graph class used to construct each output graph. Defaults to None (an undirected networkx.Graph). Any subclass is accepted, e.g. nx.DiGraph or nx.MultiGraph. GraKeL graphs are inherently non-directed, so when using a directed container the symmetric entries of the edge dictionary are merged into a single canonical edge (min(u, v), max(u, v)).

Returns:
converted_graphsnetworkx.Graph or list[networkx.Graph]

Returns a networkx.Graph if X is a single graph and a list of networkx.Graph objects otherwise.