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 theedge_dictionaryof 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
Noneno 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
Noneno 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 toNoneto skip writing weights.- create_usingtype[networkx.Graph] or None, default=None
NetworkX graph class used to construct each output graph. Defaults to
None(an undirectednetworkx.Graph). Any subclass is accepted, e.g.nx.DiGraphornx.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
Xis a single graph and a list of networkx.Graph objects otherwise.