LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-corerunnablesgraphGraphdraw_mermaid
    Method●Since v0.1

    draw_mermaid

    Draw the graph as a Mermaid syntax string.

    Copy
    draw_mermaid(
      self,
      *,
      with_styles: bool = True,
      curve_style: CurveStyle = CurveStyle.LINEAR,
      node_colors: NodeStyles | None = None,
      wrap_label_n_words: int = 9,
      frontmatter_config: dict[str, Any] | None = None
    ) -> str

    Returns: The Mermaid syntax string.

    Parameters

    NameTypeDescription
    with_stylesbool
    Default:True

    Whether to include styles in the syntax.

    curve_styleCurveStyle
    Default:CurveStyle.LINEAR

    The style of the edges.

    node_colorsNodeStyles | None
    Default:None

    The colors of the nodes.

    wrap_label_n_wordsint
    Default:9

    The number of words to wrap the node labels at.

    frontmatter_configdict[str, Any] | None
    Default:None

    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.

    See more here: https://mermaid.js.org/config/configuration.html.

    Example config:

    {
        "config": {
            "theme": "neutral",
            "look": "handDrawn",
            "themeVariables": {"primaryColor": "#e2e2e2"},
        }
    }
    View source on GitHub