draw_problem#
- iqm.applications.graph_utils.draw_problem(problem_instance=None, *, graph_to_plot=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.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) – Binary string indicating which nodes are highlighted in the graph. Its length must match
len(problem_instance.original_variables)and represent the state of all original variables (both fixed and unfixed). If the bitstring encodes only unfixed variables, it must first be converted usingrestore_fixed_variables_bitstring().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:
ValueError – If
graph_to_plotis not 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