get_top_n_color_pairs

get_top_n_color_pairs#

iqm.applications.graph_utils.get_top_n_color_pairs(max_color_pairs, problem_graph=None, color_sets=None)[source]#

Helper function for the greedy router.

Finds an edge coloring of a graph, and then returns max_color_pairs largest (by the number of edges) pairs of colors. If there is less than max_color_pairs color pairs, then it returns all of them.

Parameters:
  • max_color_pairs (int) – The maximum number of edge color pairs to return.

  • problem_graph (Graph | None) – The graph to be colored. Ignored if color_sets is provided.

  • color_sets (Iterable[set[TypeAliasForwardRef('~iqm.qaoa.transpiler.quantum_hardware.LogEdge')]] | None) – Edge coloring of the graph. If None, obtained by coloring problem_graph with iqm.qaoa.transpiler.sparse.edge_coloring.find_edge_coloring().

Returns:

The largest color pairs.

Raises:

ValueError – If both problem_graph and color_sets are None.

Return type:

list[tuple[set[TypeAliasForwardRef(‘~iqm.qaoa.transpiler.quantum_hardware.LogEdge’)], set[TypeAliasForwardRef(‘~iqm.qaoa.transpiler.quantum_hardware.LogEdge’)]]]