graphix.visualization module¶
Functions to visualize graph-based objects: open graphs, flows and XZ-corrections.
- class Colored(value: _T, color: Color)[source]¶
Bases:
Generic[_T]A generic container pairing a value with a color for visualization.
- Parameters:
value (_T) – The value to be colored. Can be any type.
color (Color) – The color to associate with the value, used during visualization.
- value: _T¶
- color: Color¶
- class PlotLims(xmin: float, xmax: float, ymin: float, ymax: float)[source]¶
Bases:
objectDataclass to wrap the plot limits in axis coordinates.
- class DrawKwargs[source]¶
Bases:
TypedDictCommon keyword arguments for graph visualization methods.
The keys correspond to the fields of
VisualizationOptions.
- class VisualizationOptions(pauli_measurements: bool = True, measurement_labels: bool = False, local_clifford: bool = False, node_labels: bool | Mapping[int, str] = True, node_distance: tuple[float, float] = (1, 1), legend: bool = True, figsize: tuple[int, int] | None = None, filename: Path | None = None)[source]¶
Bases:
objectOptions controlling graph visualization.
- Parameters:
pauli_measurements (bool, default=True) – If
True, Pauli-measured nodes are highlighted with distinct coloring.measurement_labels (bool, default=False) – If
True, measurement labels (planes and axis) are displayed in the visualization.local_clifford (bool, default=False) – If
True, Clifford operations are displayed in the visualization.node_labels (bool | Mapping[int, str], default=True) – If
True, display numeric node labels. If a mapping, use custom labels for nodes specified in the mapping.node_distance (tuple[float, float], default=(1, 1)) – Scaling factors (x_scale, y_scale) applied to node positions.
legend (bool, default=True) – If
True, legend is shown.figsize (tuple[int, int] | None, default=None) – Figure dimensions (width, height) in inches. If
None, dimensions are determined automatically based on graph structure.filename (Path | None, default=None) – File path to save the visualization. If
None, figure is displayed but not saved.
- class GraphVisualizer(og: OpenGraph[AbstractMeasurement], pos: Mapping[int, _Point], edge_paths: Mapping[_Edge, _Path], arrow_paths: Mapping[_Edge, Colored[_Path]] | None = None, n_layers: int | None = None, options: VisualizationOptions = <factory>, _source: _Source | None = None)[source]¶
Bases:
objectVisualizer for flows and XZ-correction structures.
- og¶
The open graph of the object being rendered.
- Type:
- edge_paths¶
Bezier curve paths for graph edges.
- Type:
Mapping[_Edge, _Path]
- arrow_paths¶
Colored bezier curve paths for correction dependency arrows.
- Type:
Mapping[_Edge, Colored[_Path]]
- n_layers¶
Number of measurement layers in the partial order (determines horizontal extent).
- Type:
- options¶
Options controlling graph visualization.
- Type:
VisualizationOptions, default=VisualizationOptions()
- _source¶
Internal metadata indicating the source of the graph (e.g.,
OpenGraph,PauliFloworXZCorrections).- Type:
_Source | None, default=None
Notes
Instantiate this class via factory methods rather than direct construction: -
from_opengraph(): Create fromOpenGraphinstance. -from_flow(): Create fromPauliFlowinstance. -from_xzcorrections(): Create fromXZCorrectionsinstance.Call
visualize()to generate and display the graph visualization.- edge_paths: Mapping[_Edge, _Path]¶
- options: VisualizationOptions¶
- static from_opengraph(og: OpenGraph[AbstractMeasurement], **kwargs: Unpack[DrawKwargs]) GraphVisualizer[source]¶
Create a
GraphVisualizerfrom anOpenGraphinstance.- Parameters:
og (OpenGraph[AbstractMeasurement])
options (Unpack[DrawKwargs]) – Options controlling graph visualization. See
VisualizationOptions.
- Return type:
- static from_flow(flow: PauliFlow[AbstractMeasurement], **kwargs: Unpack[DrawKwargs]) GraphVisualizer[source]¶
Create a
GraphVisualizerfrom aPauliFlowinstance.- Parameters:
flow (PauliFlow[AbstractMeasurement])
options (Unpack[DrawKwargs]) – Options controlling graph visualization. See
VisualizationOptions.
- Return type:
- static from_xzcorrections(xz_corr: XZCorrections[AbstractMeasurement], **kwargs: Unpack[DrawKwargs]) GraphVisualizer[source]¶
Create a
GraphVisualizerfrom anXZCorrectionsinstance.- Parameters:
xz_corr (XZCorrections[AbstractMeasurement])
options (Unpack[DrawKwargs]) – Options controlling graph visualization. See
VisualizationOptions.
- Return type: