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

    draw_ascii

    Build a DAG and draw it in ASCII.

    Copy
    draw_ascii(
        vertices: Mapping[str, str],
        edges: Sequence[LangEdge],
    ) -> str

    Example:

    from langchain_core.runnables.graph_ascii import draw_ascii
    
    vertices = {1: "1", 2: "2", 3: "3", 4: "4"}
    edges = [
        (source, target, None, None)
        for source, target in [(1, 2), (2, 3), (2, 4), (1, 4)]
    ]
    
    print(draw_ascii(vertices, edges))
    
             +---+
             | 1 |
             +---+
             *    *
            *     *
           *       *
        +---+       *
        | 2 |       *
        +---+**     *
          *    **   *
          *      ** *
          *        **
        +---+     +---+
        | 3 |     | 4 |
        +---+     +---+

    Parameters

    NameTypeDescription
    vertices*Mapping[str, str]

    list of graph vertices.

    edges*Sequence[LangEdge]

    list of graph edges.

    View source on GitHub