draw_mermaid#
- langchain_core.runnables.graph_mermaid.draw_mermaid(nodes: dict[str, Node], edges: list[Edge], *, first_node: str | None = None, last_node: str | None = None, with_styles: bool = True, curve_style: CurveStyle = CurveStyle.LINEAR, node_styles: NodeStyles | None = None, wrap_label_n_words: int = 9, frontmatter_config: dict[str, Any] | None = None) str [source]#
Draws a Mermaid graph using the provided graph data.
- Parameters:
nodes (dict[str, str]) – List of node ids.
edges (List[Edge]) – List of edges, object with a source, target and data.
first_node (str, optional) – Id of the first node. Defaults to None.
last_node (str, optional) – Id of the last node. Defaults to None.
with_styles (bool, optional) – Whether to include styles in the graph. Defaults to True.
curve_style (CurveStyle, optional) – Curve style for the edges. Defaults to CurveStyle.LINEAR.
node_styles (NodeStyles, optional) – Node colors for different types. Defaults to NodeStyles().
wrap_label_n_words (int, optional) – Words to wrap the edge labels. Defaults to 9.
frontmatter_config (dict[str, Any], optional) –
Mermaid frontmatter config. Can be used to customize theme and styles. Will be converted to YAML and added to the beginning of the mermaid graph. Defaults to None.
See more here: https://mermaid.js.org/config/configuration.html.
- ”config”: {
“theme”: “neutral”, “look”: “handDrawn”, “themeVariables”: { “primaryColor”: “#e2e2e2”},
}
- Returns:
Mermaid graph syntax.
- Return type:
str