loom.visualizer.circuit_visualizer
Copyright 2024 Entropica Labs Pte Ltd
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
- loom.visualizer.circuit_visualizer.hierarchy_layout(graph, root=None, x_spacing=1.0, y_spacing=1.5)[source]
Pure-Python replacement for graphviz_layout (hierarchical layout).
- Parameters:
graph (nx.DiGraph) – Directed acyclic graph to layout.
root (node or None) – Optional root node. If None, the first node with in-degree 0 is used.
x_spacing (float) – Horizontal spacing between sibling nodes.
y_spacing (float) – Vertical spacing between levels.
- Returns:
Mapping of node -> (x, y) positions.
- Return type:
dict
- loom.visualizer.circuit_visualizer.plot_circuit_tree(circuit, max_layer=None, layer_colors=None, layer_labels=None, num_layers_with_text=1)[source]
Plot the tree structure of a Circuit object.
- Parameters:
circuit (Circuit) – Circuit which should be plotted
max_layer (int | None) – Maximum layer up to which the tree should be plotted. If None is provided, all layers are plotted.
layer_colors (list[str] | None) – Array of colors for the markers in different layers.
layer_labels (list[str] | None) – Array of labels for the different layers. If None is provided, they are labeled by their number.
num_layers_with_text (int | None) – Number of layers where their name is written on top of the markers
- Returns:
Interactive go.Figure object for the circuit tree
- Return type:
go.Figure