...

/

What Are the Main Components of LangGraph?

What Are the Main Components of LangGraph?

Explore LangGraph's nodes, edges, and state for dynamic workflows.

Let’s break this down in simple terms. LangGraph is built around graphs—and yeah, that’s obviously where the name comes from. Graphs have three main parts here: nodes, edges, and state. Imagine you’re planning a road trip. The nodes are the steps where something happens—like grabbing coffee or refueling the car. The edges are the roads that connect those stops, deciding which way to go next. And the state? That’s like your travel journal, keeping track of where you’ve been, where you are now, and what you’ve picked up along the way.

Press + to interact

In LangGraph, nodes do the heavy lifting, like processing user input or running a language model, edges decide the next step based on the state, and the state evolves as tasks are completed. It’s like having a smart GPS that doesn’t just follow a fixed route but adjusts in real time—making LangGraph perfect for workflows that need to adapt on the fly.

What is state in LangGraph?

Before we build anything fancy, let’s talk about state—the beating heart of our graph. If our workflow were a house, the state would be its foundation, keeping everything sturdy and organized right. We can also think of it as the memory of our graph for the sake of simplicity, keeping track of what’s happening, what’s changed, and what comes next. Every node and edge in our graph interacts with the state, reading from it, writing to it, and updating it as the workflow progresses.

The state is the shared memory of your workflow. Nodes and edges write to and read from it, ensuring everything stays organized. To make this notebook useful, you need to decide what information you want to store in it. That’s where the schema comes in. A schema is just a structured way to say, “Here’s what kind of information I want to keep track of.” For example:

  • If you’re building a chatbot, your schema might include fields like user_input (what the user said) or bot_response (what the chatbot replies).

  • If you’re creating a ticketing system, the schema might have ticket_status (e.g., “open” or “closed”) and assigned_agent.

The schema makes sure your state is predictable and consistent—like labeling sections in your notebook so you always know where to find things. To define the schema for our state in LangGraph, we typically use tools like TypedDict or Pydantic. If you’re new to these terms, don’t worry—they’re just ways to organize and validate the information in your graph’s shared notebook. ...

Access this course and 1400+ top-rated courses and projects.