
Edges as Decisions
How edges control the flow of execution.
Edges as Decisions
If Nodes are the "What", Edges are the "When".
Types of Edges
1. Normal Edge (Deterministic)
"After Node A finishes, always go to Node B."
graph.add_edge("node_a", "node_b")
2. Conditional Edge (Probabilistic)
"After Node A finishes, check the state. If X, go to Node B. If Y, go to Node C."
graph.add_conditional_edges(
"node_a",
should_continue,
{
"continue": "node_b",
"stop": "end"
}
)
The Router Function
The logic for a conditional edge lives in a Router Function. This function must be purely logical. It reads the state and returns a string matching one of the destination keys.
graph TD
A[Start] --> Router{Decision}
Router -- "Path 1" --> B[Node B]
Router -- "Path 2" --> C[Node C]