Home / Function/ reid() — langchain Function Reference

reid() — langchain Function Reference

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

Function python LangChainCore Runnables calls 2 called by 1

Entity Profile

Dependency Diagram

graph TD
  9f553f07_a134_96b2_5d30_cde7bee5fd6f["reid()"]
  646f3bb5_a594_563e_cfbf_e18bdc9efb90["Graph"]
  9f553f07_a134_96b2_5d30_cde7bee5fd6f -->|defined in| 646f3bb5_a594_563e_cfbf_e18bdc9efb90
  b9f04a0f_6507_1a21_7a91_357a589c2c3a["draw_mermaid()"]
  b9f04a0f_6507_1a21_7a91_357a589c2c3a -->|calls| 9f553f07_a134_96b2_5d30_cde7bee5fd6f
  06f839e9_c953_ef45_72b3_7929f39522ed["is_uuid()"]
  9f553f07_a134_96b2_5d30_cde7bee5fd6f -->|calls| 06f839e9_c953_ef45_72b3_7929f39522ed
  3db09069_0f77_1402_7f96_14d549abbd03["copy()"]
  9f553f07_a134_96b2_5d30_cde7bee5fd6f -->|calls| 3db09069_0f77_1402_7f96_14d549abbd03
  style 9f553f07_a134_96b2_5d30_cde7bee5fd6f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/runnables/graph.py lines 422–455

    def reid(self) -> Graph:
        """Return a new graph with all nodes re-identified.

        Uses their unique, readable names where possible.
        """
        node_name_to_ids = defaultdict(list)
        for node in self.nodes.values():
            node_name_to_ids[node.name].append(node.id)

        unique_labels = {
            node_id: node_name if len(node_ids) == 1 else f"{node_name}_{i + 1}"
            for node_name, node_ids in node_name_to_ids.items()
            for i, node_id in enumerate(node_ids)
        }

        def _get_node_id(node_id: str) -> str:
            label = unique_labels[node_id]
            if is_uuid(node_id):
                return label
            return node_id

        return Graph(
            nodes={
                _get_node_id(id_): node.copy(id=_get_node_id(id_))
                for id_, node in self.nodes.items()
            },
            edges=[
                edge.copy(
                    source=_get_node_id(edge.source),
                    target=_get_node_id(edge.target),
                )
                for edge in self.edges
            ],
        )

Domain

Subdomains

Called By

Frequently Asked Questions

What does reid() do?
reid() is a function in the langchain codebase, defined in libs/core/langchain_core/runnables/graph.py.
Where is reid() defined?
reid() is defined in libs/core/langchain_core/runnables/graph.py at line 422.
What does reid() call?
reid() calls 2 function(s): copy, is_uuid.
What calls reid()?
reid() is called by 1 function(s): draw_mermaid.

Analyze Your Own Codebase

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

Try Supermodel Free