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_pngPngDrawer
    Class●Since v0.1

    PngDrawer

    Helper class to draw a state graph into a PNG file.

    It requires graphviz and pygraphviz to be installed.

    Copy
    PngDrawer(
      self,
      fontname: str | None = None,
      labels: LabelsDict | None = None
    )

    Example:

    drawer = PngDrawer()
    drawer.draw(state_graph, "graph.png")

    Parameters

    NameTypeDescription
    fontnamestr | None
    Default:None

    The font to use for the labels. Defaults to "arial".

    labelsLabelsDict | None
    Default:None

    A dictionary of label overrides. The dictionary should have the following format: { "nodes": { "node1": "CustomLabel1", "node2": "CustomLabel2", "end": "End Node" }, "edges": { "continue": "ContinueLabel", "end": "EndLabel" } } The keys are the original labels, and the values are the new labels.

    Constructors

    constructor
    __init__
    NameType
    fontnamestr | None
    labelsLabelsDict | None

    Attributes

    attribute
    fontname
    attribute
    labels

    Methods

    method
    get_node_label

    Returns the label to use for a node.

    method
    get_edge_label

    Returns the label to use for an edge.

    method
    add_node

    Adds a node to the graph.

    method
    add_edge

    Adds an edge to the graph.

    method
    draw

    Draw the given state graph into a PNG file.

    Requires graphviz and pygraphviz to be installed.

    method
    add_nodes

    Add nodes to the graph.

    method
    add_subgraph

    Add subgraphs to the graph.

    method
    add_edges

    Add edges to the graph.

    method
    update_styles

    Update the styles of the entrypoint and END nodes.

    View source on GitHub