Subgraphs bring software engineering principles — encapsulation, reuse, separation of concerns — to LangGraph. A child graph is compiled as an independent `CompiledGraph` and then called as a regular node inside any parent graph. The parent's state flows in, the child's final state flows back out, and the parent continues.
In this example, a `search_subgraph` runs a full ReAct loop against a database and returns raw results. A `summary_subgraph` then polishes those raw results into a human-friendly report. The parent graph simply calls them in sequence — it doesn't know or care about their internal complexity.
Subgraphs are especially powerful when the same retrieval or processing logic is needed in multiple parent workflows. They can also simplify testing: each subgraph can be run and unit-tested independently before integration into the larger pipeline.