# The LangGraph Model: State, Nodes, Edges — LangGraph Agents & Multi-Agent Systems

Source: https://www.geekswithgeeks.com/en/langgraph-agents/i-model

> Learn the three building blocks and what compiling does.

## Shared state, small functions, explicit transitions

**LangGraph** is a library (from the LangChain team, usable without LangChain models) for building stateful, controllable agents as graphs. **State** is a typed structure (a `TypedDict`, dataclass or Pydantic model) that all nodes read and update. A **node** is a function that takes the state and returns a partial update. **Edges** connect nodes: normal edges (always go next), **conditional edges** (a function picks the next node) and the special `START` and `END`. You build a `StateGraph`, add nodes and edges, then **`compile()`** it into a runnable app that supports `invoke`, `stream`, checkpointing and interrupts. Because every transition is explicit, you can draw, test and debug the flow.

## The pieces

A map of the vocabulary used in the rest of the course.

```text
State          typed data shared by all nodes            {"messages": [...], "route": "..."}
Node           function(state) -> partial update          def classify(state): return {"route": "billing"}
Edge           fixed transition                           add_edge("a", "b")
Conditional    function(state) -> name of next node       add_conditional_edges("classify", pick)
START / END    entry and exit markers
compile()      validates the graph, returns a runnable app (invoke / stream / checkpoint)
```

## Draw the graph before coding it

Sketch nodes and arrows on paper first. If the picture is hard to explain, the code will be harder.

**Quiz:** What does a node return?

- [x] A partial update to the state
- [ ] A new graph
- [ ] A trained model
- [ ] Nothing ever

*Answer:* A partial update to the state. Nodes return only the keys they change; LangGraph merges them into the state.
