PrettyGraphDrawer#
qualtran.drawing.PrettyGraphDrawer
View source on GitHub
|
A class to encapsulate methods for displaying a CompositeBloq as a graph using graphviz.
Inherits From: GraphDrawer
Graphviz has nodes, edges, and ports. Nodes are HTML tables representing bloq instances. Each cell in the table has a graphviz port and represents a soquet. Edges connect node:port tuples representing connections between soquets.
Each node and port has a string identifier. We use the _IDBuilder helper class
to assign unique, readable IDs to each object.
Users should call GraphDrawer.get_graph() as the primary entry point. Other methods
can be overridden to customize the look of the resulting graph.
To display a graph in a jupyter notebook consider using the SVG utilities:
>>> dr = GraphDrawer(cbloq)
>>> dr.get_svg()
Args
Methods#
get_binst_table_attributes
get_binst_table_attributes() -> str
Overridable method to configure the desired table attributes for the bloq.
get_binst_header_text
get_binst_header_text(
binst: qualtran.BloqInstance
)
Overridable method returning the text used for the header cell of a bloq.
soq_label
soq_label(
soq: qualtran.Soquet
)
Overridable method for getting label text for a Soquet.
get_default_text
get_default_text(
reg: qualtran.Register
) -> str
cxn_edge
cxn_edge(
left_id: str,
right_id: str,
cxn: qualtran.Connection
) -> pydot.Edge
Overridable method to style a pydot.Edge for connecionts.
View source on GitHub