Home / Function/ first_node() — langchain Function Reference

first_node() — langchain Function Reference

Architecture documentation for the first_node() function in graph.py from the langchain codebase.

Function python LangChainCore Runnables calls 1 called by 3

Entity Profile

Dependency Diagram

graph TD
  202074c8_de09_73dd_415c_edea3bae12f1["first_node()"]
  646f3bb5_a594_563e_cfbf_e18bdc9efb90["Graph"]
  202074c8_de09_73dd_415c_edea3bae12f1 -->|defined in| 646f3bb5_a594_563e_cfbf_e18bdc9efb90
  6764536f_15b8_5436_aa1a_53ff3f1956c2["extend()"]
  6764536f_15b8_5436_aa1a_53ff3f1956c2 -->|calls| 202074c8_de09_73dd_415c_edea3bae12f1
  600fa640_4465_baee_3ef3_0c1fda5bf94b["trim_first_node()"]
  600fa640_4465_baee_3ef3_0c1fda5bf94b -->|calls| 202074c8_de09_73dd_415c_edea3bae12f1
  b9f04a0f_6507_1a21_7a91_357a589c2c3a["draw_mermaid()"]
  b9f04a0f_6507_1a21_7a91_357a589c2c3a -->|calls| 202074c8_de09_73dd_415c_edea3bae12f1
  c2fe47ba_c1ff_8826_55de_cd87be044850["_first_node()"]
  202074c8_de09_73dd_415c_edea3bae12f1 -->|calls| c2fe47ba_c1ff_8826_55de_cd87be044850
  style 202074c8_de09_73dd_415c_edea3bae12f1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/graph.py lines 457–467

    def first_node(self) -> Node | None:
        """Find the single node that is not a target of any edge.

        If there is no such node, or there are multiple, return `None`.
        When drawing the graph, this node would be the origin.

        Returns:
            The first node, or None if there is no such node or multiple
            candidates.
        """
        return _first_node(self)

Domain

Subdomains

Frequently Asked Questions

What does first_node() do?
first_node() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/graph.py.
Where is first_node() defined?
first_node() is defined in libs/core/langchain_core/runnables/graph.py at line 457.
What does first_node() call?
first_node() calls 1 function(s): _first_node.
What calls first_node()?
first_node() is called by 3 function(s): draw_mermaid, extend, trim_first_node.

Analyze Your Own Codebase

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

Try Supermodel Free