AI Hints
Home›Agentic AI Tutorial›LangGraph Basics
Agentic AI · Lesson 36 of 100

Why Graphs?

From loops to LangGraph.

⏱ 2 min read▶ Video at 1:03:50🎓 Free
Watch this lesson in the Agentic AI courseWatch on YouTube ↗Full Agentic AI course

Our loop works. But the boss asks for more. Pause for approval on big refunds. Resume after a server restart. Roll back to an earlier step. Send one part down a different path. Suddenly, our twenty lines look like two thousand lines of messy code. That's the problem that graphs solve.

Why Graphs?
From the video: Why Graphs?
  • Pause for approval
  • Resume after a restart
  • Twenty lines become two thousand

An agent as a graph

Think of your agent as a flow chart. Each box is a step, called a node. Each arrow is a connection, called an edge. Some arrows depend on a decision. And a shared notebook, called the state, travels along with the work. That's LangGraph, and the loop is just an arrow that points back.

Loop versus graph

Why not stick with a loop? A plain loop is great for simple agents, and you should keep using them. A graph pays off when you need to pause, resume, branch, or combine several agents. You're not giving up control. In fact, you can see the entire flow, and each transition is explicit.

Plain loop

  • Simple to write
  • Hard to pause or resume
  • Flow hidden in code

Graph

  • More to set up
  • Pause, resume, roll back
  • Flow is explicit

The three concepts

There are just three concepts. State is a typed dictionary holding everything that the agent knows. A node is a Python function that reads the state, and returns an update. And an edge decides where to go next. You already know all three of them. Our messages list was state, and our if statement was an edge.

Statea shared notebook
Nodesfunctions that update it
Edgeswhat happens next

Summary

State, nodes, and edges. That's the whole framework. Next, you'll build your first graph.

Key takeaways
  • Graphs make flow explicit
  • Use them for pause and resume
  • State, nodes, edges
Next up: Your First Graph — state, nodes, and edges