mqt.qmap.visualization.visualize_search_graph

Function for visualization of search graphs.

Exceptions

RootNodeNotFoundError

Raised when the root node of a search graph could not be found.

FinalNodeNotFoundError

Raised when the final solution node of a search graph could not be found.

Classes

SearchNode

Represents a node in the search graph.

Functions

visualize_search_graph(→ ipywidgets.Widget)

Creates a widget to visualize a search graph.

Module Contents

class SearchNode[source]

Represents a node in the search graph.

total_cost() float[source]

Returns the total cost of the node, i.e. fixed cost + heuristic cost + lookahead penalty.

total_fixed_cost() float[source]

Returns the total fixed cost of the node, i.e. fixed cost + lookahead penalty.

exception RootNodeNotFoundError[source]

Bases: Exception

Raised when the root node of a search graph could not be found.

Initialize self. See help(type(self)) for accurate signature.

exception FinalNodeNotFoundError[source]

Bases: Exception

Raised when the final solution node of a search graph could not be found.

Initialize self. See help(type(self)) for accurate signature.

visualize_search_graph(data_logging_path: str, layer: int | Literal['interactive'] = 'interactive', architecture_node_positions: MutableMapping[int, Position] | None = None, architecture_layout: Literal['dot', 'neato', 'fdp', 'sfdp', 'circo', 'twopi', 'osage', 'patchwork'] = 'sfdp', search_node_layout: Literal['walker', 'dot', 'neato', 'fdp', 'sfdp', 'circo', 'twopi', 'osage', 'patchwork'] = 'walker', search_graph_border: float = 0.05, architecture_border: float = 0.05, swap_arrow_spacing: float = 0.05, swap_arrow_offset: float = 0.05, use3d: bool = True, projection: Literal['orthographic', 'perspective'] = 'perspective', width: int = 1400, height: int = 700, draw_search_edges: bool = True, search_edges_width: float = 0.5, search_edges_color: str = '#888', search_edges_dash: str = 'solid', tapered_search_layer_heights: bool = True, show_layout: Literal['hover', 'click'] | None = 'hover', show_swaps: bool = True, show_shared_swaps: bool = True, show_only_solution_path: bool = False, color_valid_mapping: str | None = 'green', color_final_node: str | None = 'red', search_node_color: str | Callable[[SearchNode], float] | Sequence[str | Callable[[SearchNode], float]] = 'total_cost', prioritize_search_node_color: bool | Sequence[bool] = False, search_node_color_scale: Colorscale | Sequence[Colorscale] = 'YlGnBu', search_node_invert_color_scale: bool | Sequence[bool] = True, search_node_colorbar_title: str | Sequence[str | None] | None = None, search_node_colorbar_spacing: float = 0.06, search_node_height: str | Callable[[SearchNode], float] | Sequence[str | Callable[[SearchNode], float]] = 'total_cost', draw_stems: bool = False, stems_width: float = 0.7, stems_color: str = '#444', stems_dash: str = 'solid', show_search_progression: bool = True, search_progression_step: int = 10, search_progression_speed: float = 2, plotly_settings: MutableMapping[str, MutableMapping[str, object]] | None = None) ipywidgets.Widget[source]

Creates a widget to visualize a search graph.

Parameters:
  • data_logging_path – Path to the data logging directory of the search process to be visualized.

  • layer – Index of the circuit layer, of which the mapping should be visualized. Defaults to “interactive”, in which case a slider menu will be created.

  • architecture_node_positions – MutableMapping from physical qubits to (x, y) coordinates. Defaults to None, in which case architecture_layout will be used to generate a layout.

  • architecture_layout – The method to use when layouting the qubit connectivity graph. Defaults to “sfdp”.

  • search_node_layout – The method to use when layouting the search graph. Defaults to “walker”.

  • search_graph_border – Size of the border around the search graph. Defaults to 0.05.

  • architecture_border – Size of the border around the qubit connectivity graph. Defaults to 0.05.

  • swap_arrow_spacing – Lateral spacing between arrows indicating swaps on the qubit connectivity graph. Defaults to 0.05.

  • swap_arrow_offset – Offset of heads and shaft of swap arrows from qubits they are pointing to/from. Defaults to 0.05.

  • use3d – If a 3D graph should be used for the search graph using the z-axis to plot data features. Defaults to True.

  • projection – Projection type to use in 3D graphs. Defaults to “perspective”.

  • width – Pixel width of the widget. Defaults to 1400.

  • height – Pixel height of the widget. Defaults to 700.

  • draw_search_edges – If edges between search nodes should be drawn. Defaults to True.

  • search_edges_width – Width of edges between search nodes. Defaults to 0.5.

  • search_edges_color – Color of edges between search nodes (in CSS format, i.e. ‘#rrggbb’, ‘#rgb’, ‘colorname’, etc.). Defaults to “#888”.

  • search_edges_dash – Dashing of search edges (in CSS format, i.e. ‘solid’, ‘dot’, ‘dash’, ‘longdash’, etc.). Defaults to “solid”.

  • tapered_search_layer_heights – If search graph tree should progressively reduce the height of each layer. Defaults to True.

  • show_layout – If the current qubit layout should be shown on the qubit connectivity graph, when clicking or hovering on a search node or not at all. Defaults to “hover”.

  • show_swaps – Showing swaps on the connectivity graph. Defaults to True.

  • show_shared_swaps – Indicate a shared swap by 1 arrow with 2 heads, otherwise 2 arrows in opposite direction are drawn for the 1 shared swap. Defaults to True.

  • show_only_solution_path – If only the final solution path should be shown. Defaults to False.

  • color_valid_mapping – Color to use for search nodes containing a valid qubit layout (in CSS format). Defaults to “green”.

  • color_final_node – Color to use for the final solution search node (in CSS format). Defaults to “red”.

  • search_node_color – Color to be used for search nodes. Either a static color (in CSS format) or function mapping a mqt.qmap.visualization.SearchNode to a float value, which in turn gets translated into a color by search_node_color_scale, or a preset data feature (‘total_cost’ | ‘fixed_cost’ | ‘heuristic_cost’ | ‘lookahead_penalty’). In case a 3D search graph is used with multiple points per search node, each point’s color can be controlled individually via a list. Defaults to “total_cost”.

  • prioritize_search_node_color – If search_node_color should be prioritized over color_valid_mapping and color_final_node. Defaults to False.

  • search_node_color_scale – Color scale to be used for converting float data features to search node colors. (See https://plotly.com/python/builtin-colorscales/ for valid values). Defaults to “YlGnBu”.

  • search_node_invert_color_scale – If the color scale should be inverted. Defaults to True.

  • search_node_colorbar_title – Title(s) to be shown next to the colorbar(s). Defaults to None.

  • search_node_colorbar_spacing – Spacing between multiple colorbars. Defaults to 0.06.

  • search_node_height – Function mapping a mqt.qmap.visualization.SearchNode to a float value to be used as z-value in 3D search graphs or a preset data feature (‘total_cost’ | ‘fixed_cost’ | ‘heuristic_cost’ | ‘lookahead_penalty’). Or a list any of such functions/data features, to draw multiple points per search node. Defaults to “total_cost”.

  • draw_stems – If a vertical stem should be drawn in 3D search graphs to each search node. Defaults to False.

  • stems_width – Width of stems in 3D search graphs. Defaults to 0.7.

  • stems_color – Color of stems in 3D search graphs (in CSS format). Defaults to “#444”.

  • stems_dash – Dashing of stems in 3D search graphs (in CSS format). Defaults to “solid”.

  • show_search_progression – If the search progression should be animated. Defaults to True.

  • search_progression_step – Step size (in number of nodes added) of search progression animation. Defaults to 10.

  • search_progression_speed – Speed of the search progression animation in steps per second. Defaults to 2.

  • plotly_settings – Plotly configuration dictionaries to be passed through. Defaults to None.

{
    "layout": settings for plotly.graph_objects.Layout (of subplots figure)
    "arrows": settings for plotly.graph_objects.layout.Annotation
    "stats_legend": settings for plotly.graph_objects.layout.Annotation
    "search_nodes": settings for plotly.graph_objects.Scatter resp. ...Scatter3d
    "search_edges": settings for plotly.graph_objects.Scatter resp. ...Scatter3d
    "architecture_nodes": settings for plotly.graph_objects.Scatter
    "architecture_edges": settings for plotly.graph_objects.Scatter
    "architecture_edge_labels": settings for plotly.graph_objects.Scatter
    "search_xaxis": settings for plotly.graph_objects.layout.XAxis resp. ...layout.scene.XAxis
    "search_yaxis": settings for plotly.graph_objects.layout.YAxis resp. ...layout.scene.YAxis
    "search_zaxis": settings for plotly.graph_objects.layout.scene.ZAxis
    "architecture_xaxis": settings for plotly.graph_objects.layout.XAxis
    "architecture_yaxis": settings for plotly.graph_objects.layout.YAxis
}
Returns:

An interactive IPython widget to visualize the search graph.

Raises:

TypeError – If any of the arguments are invalid.