"Not all data fits in a grid or a sentence. Friendships, molecules, and road maps are networks — and GNNs are how AI learns from them."
Level: Intermediate · Time: ~4 days · Prerequisites: basic neural networks
Learning Objectives
By the end of this module, you will be able to:
- Explain what a graph is and why it needs special models
- Describe "message passing" in plain terms
- Recognize tasks GNNs are good at
- Understand where GNNs are used in the real world
1. When Data Is a Network
A graph is just nodes (things) connected by edges (relationships): people and friendships, atoms and bonds, cities and roads, web pages and links. Regular neural networks expect fixed grids (images) or sequences (text) — graphs have neither fixed size nor order, so they need a different approach.
Why can't we just use a normal network? Two reasons. First, no fixed size or order: one molecule has 10 atoms, another has 40, and there's no natural "first atom" — but a standard network expects inputs of a fixed shape in a fixed order. Second, the connections carry the meaning. Flatten a friendship network into a spreadsheet and you keep the people but lose who knows whom — which was the whole point. Graphs demand a model that consumes structure directly.
Concept: The magic of a graph is that a node's meaning depends on its neighbors. Your interests are shaped by your friends; an atom's role depends on what it's bonded to. GNNs are built to use that structure.
2. Message Passing: The Core Idea
A Graph Neural Network works by letting each node gather information from its neighbors, update itself, and repeat. After a few rounds, each node "knows" about its local neighborhood.
Explain like I'm new: Imagine gossip spreading in a friend group. Each round, everyone tells their neighbors what they know; after a few rounds, information has traveled across the network. GNNs pass "messages" between connected nodes the same way.
Concept: A GNN doesn't care which node is "first" or how many neighbors a node has — it treats neighbors as an unordered set and combines their messages the same way regardless. This is why GNNs handle graphs of any size and shape, where a normal fixed-input network simply couldn't.
| Step | What happens |
|---|---|
| Gather | Each node collects messages from neighbors |
| Update | It combines them to refresh its own representation |
| Repeat | After k rounds, nodes reflect their k-hop neighborhood |
The "k rounds" detail is important. After one round, a node knows about its direct neighbors. After two, it indirectly hears from neighbors-of-neighbors (they passed along what they learned in round one). So the number of message-passing rounds sets how far across the graph information can travel — two or three rounds is common, since going too deep can blur every node into looking the same.
3. What GNNs Can Do
Depending on the task, GNNs make predictions about:
- Nodes — "Is this user a bot?" (node classification)
- Edges — "Will these two people become friends?" (link prediction)
- Whole graphs — "Is this molecule toxic?" (graph classification)
The difference is just what you read out after message passing. For a node task, you look at one node's final representation. For an edge task, you combine two nodes' representations and ask "should these be connected?" For a whole-graph task, you pool every node's representation into one summary and predict from that. Same message-passing engine underneath; the three task types simply differ in the final step.
Try this: Sketch your own social circle as dots and lines. Now imagine predicting who should know each other but doesn't yet — that's link prediction, exactly what powers "people you may know."
4. Real-World Uses
GNNs quietly power a lot: recommendation systems (users ↔ products), drug discovery (molecular graphs), fraud detection (transaction networks), traffic and maps (road networks), and knowledge graphs.
Real-world use case: A mapping app models the road network as a graph — intersections are nodes, roads are edges — and a GNN predicts travel times by letting each road segment "listen" to congestion on neighboring segments. This kind of graph model has been used to improve arrival-time estimates for millions of routes. The insight it captures is one a table never could: your traffic depends on the roads connected to yours.
Common mistake: Forcing graph data into a table and losing the connections. If relationships carry meaning — and in networks they usually do — flattening them throws away the most valuable signal. That's precisely what GNNs preserve.
✅ Checkpoint
- What are the two ingredients of a graph?
- In one sentence, what is message passing?
- Give one example each of a node-level and a graph-level task.
Answers: 1) Nodes (things) and edges (relationships). 2) Each node repeatedly gathers information from its neighbors and updates itself. 3) Node-level: "is this user a bot?"; graph-level: "is this molecule toxic?"
Key Takeaway: Many important datasets are graphs — nodes connected by edges — where meaning comes from relationships. Graph Neural Networks learn from this structure via message passing: nodes repeatedly gather and combine information from neighbors. GNNs handle node, edge, and whole-graph predictions, powering recommendations, drug discovery, fraud detection, and maps.
Further Learning
Part of "Research & Advanced AI." Original content for this learning platform.