grakelx.graph_from_networkx

grakelx.graph_from_networkx(X: nx.Graph | Iterable[nx.Graph], node_labels_tag: str | None = None, edge_labels_tag: str | None = None, edge_weight_tag: str | None = None, val_node_labels: Label | None = None, val_edge_labels: Label | None = None) Graph | list[Graph][source][source]

Transform networkx objects to grakel.Graph objects.

A function for helping a user that has a collection of graphs in networkx to use grakel.

Parameters:
Xnetworkx.Graph or Iterable[networkx.Graph]

A networkx graph or an iterable of networkx graphs.

node_labels_tagstr or None

Define where to search for labels of nodes, inside the node attribute of each graph. If None no labels are assigned.

edge_labels_tagstr or None

Define where to search for labels of edges, inside the edge attribute of each graph. If None no labels are assigned.

edge_weight_tagstr or None

Define where to search for weights inside the edge attribute of each graph. If None 1.0 weights are assigned.

val_node_labelsLabel, default=None

Sets constant value to all nodes labels of a graph if missing. See grakelx.utils._type_hints.Label for the accepted values.

val_edge_labelsLabel, default=None

Sets constant value to all edges labels of a graph if missing. See grakelx.utils._type_hints.Label for the accepted values.

Returns:
converted_graphsgrakel.Graph or list[grakel.Graph]

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

Examples using grakelx.graph_from_networkx

Example of transforming NetworkX graphs to GraKeL graphs.

Example of transforming NetworkX graphs to GraKeL graphs.