graphcat.diagram module¶
Functionality for drawing diagrams of computational graphs.
-
graphcat.diagram.
draw
(graph, hide=None, rankdir='LR')[source]¶ Create a diagram of a computational graph.
This is extremely useful for understanding and debugging computational graphs. The structure and current state is converted to a PyGraphviz graph. By default, each task is rendered as a box with the task label. Arrows are drawn between tasks, pointing from upstream producers of data to downstream consumers. Arrows are labelled to show named inputs, if any. The color of each box shows its state: white for unfinished tasks, red for tasks that are failed, and black for tasks that are finished.
Callers can customize the appearance of the graph by modifying the result before rendering it to an image or Jupyter notebook.
Parameters: - graph (
graphcat.graph.Graph
derivative orpygraphviz.AGraph
, required) – The graph to be visualized. - hide (Python callable, optional) – Python callable that can be used to hide tasks in the displayed figure.
If
None
(the default), all tasks will be displayed. Ignored if graph is an instance ofpygraphviz.AGraph
. - rankdir (
str
, optional) – Graphviz rankdir attribute that determines the direction of data flow within the diagram. Default:"LR"
, which is left-to-right flow. Ignored if graph is an instance ofpygraphviz.AGraph
.
Returns: diagram – Diagrammatic representation of graph. Callers can modify diagram as needed before using its layout and drawing methods to produce a final image.
Return type: See also
- graph (
-
graphcat.diagram.
leaves
(graph, node)[source]¶ Filter function that hides all leaf nodes when displaying a graph using
draw()
.
-
graphcat.diagram.
none
(graph, node)[source]¶ Do-nothing filter function used to display an entire graph using
draw()
.
-
graphcat.diagram.
performance
(agraph, monitor)[source]¶ Add performance monitor information to a graph diagram.
Parameters: - agraph (
pygraphviz.AGraph
, required) – Diagram originally created usingdraw()
. - monitor (
graphcat.common.PerformanceMonitor
, required) – Performance monitor object containing performance results to be added to agraph
Returns: diagram – Input diagram supplemented with performance results from monitor.
Return type: - agraph (