Home / Function/ _build_sugiyama_layout() — langchain Function Reference

_build_sugiyama_layout() — langchain Function Reference

Architecture documentation for the _build_sugiyama_layout() function in graph_ascii.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  8e2d21bc_e6f4_f21a_c769_7c8767bfdb7c["_build_sugiyama_layout()"]
  bd48fe30_3177_b41c_8c8f_66e31a6b4ecb["graph_ascii.py"]
  8e2d21bc_e6f4_f21a_c769_7c8767bfdb7c -->|defined in| bd48fe30_3177_b41c_8c8f_66e31a6b4ecb
  89ad4f5d_065c_e8f6_983b_d18b7460b090["draw_ascii()"]
  89ad4f5d_065c_e8f6_983b_d18b7460b090 -->|calls| 8e2d21bc_e6f4_f21a_c769_7c8767bfdb7c
  ec70c8d9_4454_4221_ac85_d75695eb85fc["draw()"]
  8e2d21bc_e6f4_f21a_c769_7c8767bfdb7c -->|calls| ec70c8d9_4454_4221_ac85_d75695eb85fc
  style 8e2d21bc_e6f4_f21a_c769_7c8767bfdb7c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/graph_ascii.py lines 201–244

def _build_sugiyama_layout(
    vertices: Mapping[str, str], edges: Sequence[LangEdge]
) -> Any:
    if not _HAS_GRANDALF:
        msg = "Install grandalf to draw graphs: `pip install grandalf`."
        raise ImportError(msg)

    #
    # Just a reminder about naming conventions:
    # +------------X
    # |
    # |
    # |
    # |
    # Y
    #

    vertices_ = {id_: Vertex(f" {data} ") for id_, data in vertices.items()}
    edges_ = [Edge(vertices_[s], vertices_[e], data=cond) for s, e, _, cond in edges]
    vertices_list = vertices_.values()
    graph = Graph(vertices_list, edges_)

    for vertex in vertices_list:
        vertex.view = VertexViewer(vertex.data)

    # NOTE: determine min box length to create the best layout
    minw = min(v.view.w for v in vertices_list)

    for edge in edges_:
        edge.view = _EdgeViewer()

    sug = SugiyamaLayout(graph.C[0])
    graph = graph.C[0]
    roots = list(filter(lambda x: len(x.e_in()) == 0, graph.sV))

    sug.init_all(roots=roots, optimize=True)

    sug.yspace = VertexViewer.HEIGHT
    sug.xspace = minw
    sug.route_edge = route_with_lines

    sug.draw()

    return sug

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does _build_sugiyama_layout() do?
_build_sugiyama_layout() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/graph_ascii.py.
Where is _build_sugiyama_layout() defined?
_build_sugiyama_layout() is defined in libs/core/langchain_core/runnables/graph_ascii.py at line 201.
What does _build_sugiyama_layout() call?
_build_sugiyama_layout() calls 1 function(s): draw.
What calls _build_sugiyama_layout()?
_build_sugiyama_layout() is called by 1 function(s): draw_ascii.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free