Parallel Branches
Fan out, fan in.
Some steps don't depend on each other. Checking stock in Bath, and in Bristol, can happen at the same time. In LangGraph, if one node has edges to several nodes, they all run together. Then a later node can wait for all of them.

- Independent steps
- Run at the same time
- Then wait for all
Fan out, fan in
Start has edges to two nodes, so they run in parallel. Both write to found, which has operator add, so their results are combined, not overwritten. The edge from a list of nodes to summary means, wait for both. Run it. Both shops report, and the summary sees everything.
import operator
from typing import Annotated, TypedDict
from langgraph.graph import StateGraph, START, END
class State(TypedDict):
title: str
found: Annotated[list[str], operator.add]
summary: str
def bath(s): return {"found": ["Bath: 2 copies"]}
def bristol(s): return {"found": ["Bristol: 1 copy"]}
def summary(s): return {"summary": f"{s['title']} -> " + "; ".join(sorted(s["found"]))}
b = StateGraph(State)
for fn in [bath, bristol, summary]: b.add_node(fn)
b.add_edge(START, "bath"); b.add_edge(START, "bristol")
b.add_edge(["bath", "bristol"], "summary"); b.add_edge("summary", END)
print(b.compile().invoke({"title": "Dune", "found": []})["summary"])Dune -> Bath: 2 copies; Bristol: 1 copy
Parallel rules
Nodes that run together are in the same step. If they write the same key, it needs a reducer, or LangGraph raises an error, because it can't know which value wins. Parallel branches make slow work, like model calls, much faster.
| key | value |
|---|---|
| Same step | run together |
| Shared key | needs a reducer |
| Wait for all | edge from a list |
| Faster | for slow calls |
Summary
Edges to several nodes run them in parallel, and an edge from a list waits for all of them. Shared keys need a reducer. Next, controlling what goes in and out of a graph.
Key takeaways- Fan out from one node
- Reducer for shared keys
- Fan in from a list