Home / Class/ Edge Class — langchain Architecture

Edge Class — langchain Architecture

Architecture documentation for the Edge class in graph.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  2beebca5_04a9_fb02_6662_6a2b98ab5e76["Edge"]
  81a6280b_4752_84db_f1fa_1a3b8040d481["graph.py"]
  2beebca5_04a9_fb02_6662_6a2b98ab5e76 -->|defined in| 81a6280b_4752_84db_f1fa_1a3b8040d481
  f87c1ed6_b569_98a8_6084_9f7857a4fa39["copy()"]
  2beebca5_04a9_fb02_6662_6a2b98ab5e76 -->|method| f87c1ed6_b569_98a8_6084_9f7857a4fa39

Relationship Graph

Source Code

libs/core/langchain_core/runnables/graph.py lines 63–90

class Edge(NamedTuple):
    """Edge in a graph."""

    source: str
    """The source node id."""
    target: str
    """The target node id."""
    data: Stringifiable | None = None
    """Optional data associated with the edge. """
    conditional: bool = False
    """Whether the edge is conditional."""

    def copy(self, *, source: str | None = None, target: str | None = None) -> Edge:
        """Return a copy of the edge with optional new source and target nodes.

        Args:
            source: The new source node id.
            target: The new target node id.

        Returns:
            A copy of the edge with the new source and target nodes.
        """
        return Edge(
            source=source or self.source,
            target=target or self.target,
            data=self.data,
            conditional=self.conditional,
        )

Frequently Asked Questions

What is the Edge class?
Edge is a class in the langchain codebase, defined in libs/core/langchain_core/runnables/graph.py.
Where is Edge defined?
Edge is defined in libs/core/langchain_core/runnables/graph.py at line 63.

Analyze Your Own Codebase

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

Try Supermodel Free