LangGraph · Lesson 115 of 120
Cheat Sheet: Graph Basics
State, nodes, edges.
Here's the first of three reminder pages. The basics. State, nodes, edges, routing, and reducers. Pause the video, and keep it handy.

- Reminder page one
- The basics
- Pause and keep it
Basics cheat sheet
State is a typed dictionary, and annotated adds a reducer. Nodes are functions that return updates. Add node, add edge, and add sequence build the graph. Add conditional edges routes with a function. Compile makes it runnable, and invoke runs it.
cheatsheet_basics.pypython
import operator
from typing import Annotated, TypedDict
from langgraph.graph import StateGraph, START, END
class State(TypedDict):
title: str
log: Annotated[list[str], operator.add] # reducer: append
def step(state): return {"log": ["step ran"]} # return only changes
b = StateGraph(State)
b.add_node(step) # or b.add_sequence([a, b, c])
b.add_edge(START, "step")
b.add_conditional_edges("step", lambda s: END) # route by returning a name
graph = b.compile()
graph.invoke({"title": "Dune", "log": []}) # also batch, streamRemember
A few more basics. Send creates parallel branches at run time. Command updates and routes at once. The recursion limit stops runaway loops. And draw mermaid shows the graph's shape.
| key | value |
|---|---|
| Send | dynamic branches |
| Command | update + goto |
| recursion_limit | safety net |
| draw_mermaid | see the shape |
Summary
State with reducers, nodes that return updates, edges and conditional edges, then compile and invoke. Next, the cheat sheet for agents and memory.
Key takeaways- TypedDict + Annotated
- add_node, add_edge
- compile, invoke
Next up: Cheat Sheet: Agents and Memory — tools, checkpoints