relabel_graph_nodes

relabel_graph_nodes#

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

Map original node labels of the Graph to new ones between 0 and graph.number_of_nodes - 1.

Creates two dictionaries that keep track of the mapping between original labels and new labels numbered between 0 and graph.number_of_nodes - 1.

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 old labels to new and vice versa.

Return type:

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