langchain-ai/langchain · error · ValueError

Not enough points to draw an edge

Error message

Not enough points to draw an edge

What it means

While drawing edges on the ASCII canvas, each edge must carry at least 2 points (start and end) from the sugiyama layout. If edge.view.pts has 0 or 1 points, there is no segment to draw and draw_ascii() raises this ValueError. It indicates the layout engine returned a degenerate route for an edge.

Source

Thrown at libs/core/langchain_core/runnables/graph_ascii.py:330

        for x, y in edge.view.pts:
            xlist.append(x)
            ylist.append(y)

    minx = min(xlist)
    miny = min(ylist)
    maxx = max(xlist)
    maxy = max(ylist)

    canvas_cols = math.ceil(math.ceil(maxx) - math.floor(minx)) + 1
    canvas_lines = round(maxy - miny)

    canvas = AsciiCanvas(canvas_cols, canvas_lines)

    # NOTE: first draw edges so that node boxes could overwrite them
    for edge in sug.g.sE:
        if len(edge.view.pts) <= 1:
            msg = "Not enough points to draw an edge"
            raise ValueError(msg)
        for index in range(1, len(edge.view.pts)):
            start = edge.view.pts[index - 1]
            end = edge.view.pts[index]

            start_x = round(start[0] - minx)
            start_y = round(start[1] - miny)
            end_x = round(end[0] - minx)
            end_y = round(end[1] - miny)

            if start_x < 0 or start_y < 0 or end_x < 0 or end_y < 0:
                msg = (
                    "Invalid edge coordinates: "
                    f"start_x={start_x}, "
                    f"start_y={start_y}, "
                    f"end_x={end_x}, "
                    f"end_y={end_y}"
                )
                raise ValueError(msg)

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Use graph.draw_mermaid() or draw_mermaid_png() instead of draw_ascii() for this graph
  2. Check for and remove self-loop edges or duplicate edges before rendering
  3. Upgrade grandalf and langchain-core to the latest versions in case the layout bug is fixed
  4. Report to langchain with the graph structure that triggers it
Defensive patterns

Strategy: try-catch

Try / catch

try:
    graph.draw_ascii()
except ValueError as e:
    if "Not enough points" in str(e):
        art = graph.draw_mermaid()

Prevention

When it happens

Trigger: graph.draw_ascii() on a graph where grandalf's layout assigns an edge a single point (e.g. self-loops or zero-length edges in certain graph shapes).

Common situations: Graphs containing self-looping nodes or unusual topologies; version mismatches between langchain-core and grandalf. Almost never caused by user code, since pts come from the internal layout.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/9bfeb816cde0680b. Report an issue: GitHub.