relabel_graph_nodes

relabel_graph_nodes#

iqm.applications.graph_utils.relabel_graph_nodes(graph)[source]#

Map original node labels of the Graph to consecutive integers starting from 0.

Creates two dictionaries that keep track of the mapping between the original labels and the new labels.

Parameters:

graph (Graph) – The graph whose nodes should be relabeled.

Returns:

A tuple containing the input graph with relabeled nodes and two dictionaries containing the mapping from the old labels to the new ones and vice versa.

Return type:

tuple[Graph, dict[Any, int], dict[int, Any]]