Bases: Visualization
Graphviz DOT visualization.
This visualization stores a raw DOT source string plus the selected layout engine. It is useful when you already have DOT output (for example from graphviz.Digraph) and want to render it directly.
Attributes:
| Name | Type | Description |
type | Literal['dot'] | Fixed discriminator "dot". |
dot_str | str | |
layout_engine | GraphvizLayoutEngineName | Graphviz layout engine used for layouting. |
Source code in src/ocelescope/src/ocelescope/visualization/default/dot.py
| class DotVis(Visualization):
"""Graphviz DOT visualization.
This visualization stores a raw DOT source string plus the selected layout engine.
It is useful when you already have DOT output (for example from `graphviz.Digraph`)
and want to render it directly.
Attributes:
type: Fixed discriminator `"dot"`.
dot_str: The DOT source string.
layout_engine: Graphviz layout engine used for layouting.
"""
type: Literal["dot"] = "dot"
dot_str: str
layout_engine: GraphvizLayoutEngineName = "dot"
@classmethod
def from_graphviz(
cls, graph: Digraph | Graph, layout_engine: GraphvizLayoutEngineName = "dot"
) -> Self:
"""Create a `DotVis` from a Graphviz graph object.
This helper extracts the DOT source from a `graphviz.Digraph` or `graphviz.Graph`
instance and stores it in `dot_str`.
Args:
graph: A Graphviz `Digraph` or `Graph`.
layout_engine: Graphviz layout engine name (for example `"dot"`).
Returns:
A `DotVis` instance containing the DOT source and the selected layout engine.
"""
return cls(dot_str=graph.source, layout_engine=layout_engine)
|
from_graphviz classmethod
from_graphviz(graph, layout_engine='dot')
Create a DotVis from a Graphviz graph object.
This helper extracts the DOT source from a graphviz.Digraph or graphviz.Graph instance and stores it in dot_str.
Parameters:
| Name | Type | Description | Default |
graph | Digraph | Graph | A Graphviz Digraph or Graph. | required |
layout_engine | GraphvizLayoutEngineName | Graphviz layout engine name (for example "dot"). | 'dot' |
Returns:
| Type | Description |
Self | A DotVis instance containing the DOT source and the selected layout engine. |
Source code in src/ocelescope/src/ocelescope/visualization/default/dot.py
| @classmethod
def from_graphviz(
cls, graph: Digraph | Graph, layout_engine: GraphvizLayoutEngineName = "dot"
) -> Self:
"""Create a `DotVis` from a Graphviz graph object.
This helper extracts the DOT source from a `graphviz.Digraph` or `graphviz.Graph`
instance and stores it in `dot_str`.
Args:
graph: A Graphviz `Digraph` or `Graph`.
layout_engine: Graphviz layout engine name (for example `"dot"`).
Returns:
A `DotVis` instance containing the DOT source and the selected layout engine.
"""
return cls(dot_str=graph.source, layout_engine=layout_engine)
|