QuantumGraphVisualizer

class lsst.pipe.base.quantum_graph.visualization.QuantumGraphVisualizer

Bases: Generic[_G, _Q, _D]

A base class for exporting quantum graphs to graph-visualization languages.

Notes

This base class is not intended to support implementations for every possible visualization language, but it does neatly unify common logic for at least GraphViz and Mermaid.

Methods Summary

render_dataset(dataset_id, data)

Return the representation of a dataset in a graph visualization.

render_edge(a, b, data)

Return the representation of an edge a graph visualization.

render_footer(qg, is_bipartite)

Return the ending of a graph visualization.

render_header(qg, is_bipartite)

Return the beginning of a graph visualization.

render_quantum(quantum_id, data, is_bipartite)

Return the representation of a quantum in a graph visualization.

write_bipartite(qg, stream)

Write a visualization for graph with both quantum and dataset nodes.

write_quantum_only(qg, stream)

Write a visualization for graph with only quantum nodes.

Methods Documentation

abstract render_dataset(dataset_id: UUID, data: _D) str

Return the representation of a dataset in a graph visualization.

Parameters:
dataset_iduuid.UUID

ID of the dataset.

dataDatasetInfo

Mapping with additional information about the dataset.

Returns:
renderedstr

String that represents the dataset. May contain newlines, but an additional newline will automatically be added after the string, before the next node or edge.

abstract render_edge(a: UUID, b: UUID, data: BipartiteEdgeInfo | None) str

Return the representation of an edge a graph visualization.

Parameters:
auuid.UUID

ID of the quantum or dataset for which this is an outgoing edge.

buuid.UUID

ID of the quantum or dataset for which this is an incoming edge.

dataBipartiteEdgeInfo

Mapping with additional information about the dataset.

Returns:
renderedstr

String that represents the edge. May contain newlines, but an additional newline will automatically be added after the string, before the next edge.

Return the ending of a graph visualization.

Parameters:
qgBaseQuantumGraph

Quantum graph to visualize.

is_bipartitebool

Whether a bipartite graph visualization is being requested.

Returns:
renderedstr

String that ends the visualization. May contain newlines, but an additional newline will automatically be added after the string, at the end of the file.

abstract render_header(qg: _G, is_bipartite: bool) str

Return the beginning of a graph visualization.

Parameters:
qgBaseQuantumGraph

Quantum graph to visualize.

is_bipartitebool

Whether a bipartite graph visualization is being requested.

Returns:
renderedstr

String that starts the visualization. May contain newlines, but an additional newline will automatically be added after the string, before the first node.

abstract render_quantum(quantum_id: UUID, data: _Q, is_bipartite: bool) str

Return the representation of a quantum in a graph visualization.

Parameters:
quantum_iduuid.UUID

ID of the quantum.

dataQuantumInfo

Mapping with additional information about the quantum.

is_bipartitebool

Whether a bipartite graph visualization is being requested.

Returns:
renderedstr

String that represents the quantum. May contain newlines, but an additional newline will automatically be added after the string, before the next node or edge.

write_bipartite(qg: _G, stream: IO[str]) None

Write a visualization for graph with both quantum and dataset nodes.

Parameters:
qgBaseQuantumGraph

Quantum graph to visualize.

streamtyping.IO

File-like object to write to.

write_quantum_only(qg: _G, stream: IO[str]) None

Write a visualization for graph with only quantum nodes.

Parameters:
qgBaseQuantumGraph

Quantum graph to visualize.

streamtyping.IO

File-like object to write to.