draw_problem#
- iqm.applications.graph_utils.draw_problem(problem_instance=None, *, graph_to_plot=None, orig_to_new_mapping=None, fixed_vars=frozenset({}), bitstring=None, seed=None, highlight_edge_by_node_count=frozenset({2}))[source]#
High-level wrapper that prepares and visualizes a problem graph.
- This function orchestrates three steps:
Extraction of problem data via
_extract_problem_info().Conversion into plotting data with
prepare_plot_data().Visualization using
plot_graph().
It exists primarily as a convenience entry point — most argument validation and interpretation is handled by
_extract_problem_info().- Parameters:
problem_instance (QUBOInstance | ISInstance | None) – Optional optimization problem instance from which graph and mapping data can be derived.
graph_to_plot (nx.Graph | None) – Graph object to visualize. Overrides the graph from
problem_instance, if both are provided.orig_to_new_mapping (Mapping[Any, int] | None) – Mapping from original variable names to integer node indices. Overrides the mapping from
problem_instance, if both are provided.fixed_vars (frozenset[int]) – Variables that have been fixed and should appear dimmed in the visualization. Overrides the fixed variables from
problem_instance, if both are provided.bitstring (str | None) – Bitstring representing highlighted nodes in the graph.
highlight_edge_by_node_count (frozenset[int]) – Specifies which edges are highlighted based on the number of connected highlighted nodes (subset of
{0, 1, 2}).seed (int | None) – Optional random seed for layout stability.
- Raises:
AttributeError – If
problem_instanceis provided and it does not contain a valid graph (and a graph wasn’t explicitly provided).ValueError – If
graph_to_plotandorig_to_new_mappingare not both provided (or obtainable from providedproblem_instance).ValueError – If the provided
highlight_edge_by_node_countis not a subset of{0, 1, 2}.ValueError – If the provided
bitstringhas different length than the graph has nodes.
- Return type:
None