qewton.visualization.plots.graph package¶
Module contents¶
Plot of computation graphs: GraphPlot.
- class qewton.visualization.plots.graph.GraphPlot(graph, depth: int = 0, show_port_names: bool = False, show_configs: bool = False, title: str | None = None)[source]¶
Bases:
PlotA computation graph as a node-link diagram, drawn left to right in a 2D cell whose axes it hides.
- Parameters:
graph (Graph) – The graph to draw; must already be sorted (
graph.sort()orgraph.setup()).depth – How many levels of composite nodes (
GraphNodesubclasses) are expanded inline as a labeled cluster instead of drawn as a single box. 0 collapses every composite.show_port_names – Whether the ports of multi-port nodes are named next to the node title.
show_configs – Whether every edge is labeled with the axes of its matched data configuration; otherwise they are shown on hover.
title – Heading of the plot’s cell.
- depth¶
Number of expanded composite levels.
- Type:
int
- show_port_names¶
Whether port names are drawn.
- Type:
bool
- show_configs¶
Whether every edge is labeled.
- Type:
bool
- dim = 2¶
- margin: float = 0.0¶
- property scaled_channels: tuple[str, ...]¶
- evaluate() list[GraphLayoutResult][source]¶
The layout of the graph.
- Returns:
- One Result with the positioned
nodes, ports, edges and clusters.
- Return type:
list of GraphLayoutResult
See also
Submodules¶
qewton.visualization.plots.graph.layout module¶
Renderer-agnostic layered layout of a computation graph for
GraphPlot.
- class qewton.visualization.plots.graph.layout.GraphLayout[source]¶
Bases:
objectComputes renderer-agnostic node, port, edge and cluster positions for a graph.
A layered DAG layout drawn left to right: a node’s rank (column) is the longest path from a source, then a few barycenter passes reorder each rank to reduce edge crossings, followed by a pass that moves unrelated nodes out of the way of edges skipping ranks. Expanded composites are laid out recursively inside a cluster.
Notes
Layout runs in two passes: first every node, port and cluster is placed (recursing into expanded composites), then every edge is built from the collected port positions, since a composite’s boundary ports are only positioned once its content has been measured.
- static compute(graph, depth: int = 0) GraphLayoutResult[source]¶
Compute the layout of graph.
- Parameters:
- Returns:
- All nodes, ports, edges and clusters in one
global frame.
- Return type:
- Raises:
AssertionError – If the graph has not been sorted.
- qewton.visualization.plots.graph.layout.NODE_CATEGORIES = ((<class 'qewton.constraints.base.Constraint'>, NodeCategory.CONSTRAINT), (<class 'qewton.data.dataloaders.base.DataNode'>, NodeCategory.DATA))¶
Constraint before GraphNode, since some constraints (e.g. MSEConstraint) are GraphNodes too. Any other node is a model.
- Type:
The category of the nodes of each class, checked in order