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) 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.

Returns:

Mermaid graph syntax.

Return type:

str