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_pairslargest (by the number of edges) pairs of colors. If there is less thanmax_color_pairscolor 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_setsis provided.color_sets (Iterable[set[LogEdge]] | None) – Edge coloring of the graph. If None, obtained by coloring
problem_graphwithiqm.qaoa.transpiler.sparse.edge_coloring.find_edge_coloring().
- Returns:
The largest color pairs.
- Raises:
ValueError – If both
problem_graphandcolor_setsareNone.- Return type: