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-corerunnablesgraph_mermaiddraw_mermaid
    Function●Since v0.1

    draw_mermaid

    Copy
    draw_mermaid(
      nodes: dict[str, Node],
      edges: list[Edge
    View source on GitHub
    ]
    ,
    *
    ,
    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

    Parameters

    NameTypeDescription
    nodes*dict[str, Node]

    List of node ids.

    edges*list[Edge]

    List of edges, object with a source, target and data.

    first_nodestr | None
    Default:None
    last_nodestr | None
    Default:None
    with_stylesbool
    Default:True
    curve_styleCurveStyle
    Default:CurveStyle.LINEAR
    node_stylesNodeStyles | None
    Default:None
    wrap_label_n_wordsint
    Default:9
    frontmatter_configdict[str, Any] | None
    Default:None

    Draws a Mermaid graph using the provided graph data.

    Id of the first node.

    Id of the last node.

    Whether to include styles in the graph.

    Curve style for the edges.

    Node colors for different types.

    Words to wrap the edge labels.

    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"},
        }
    }