"Back in Foundations we said structure-and-cost is a lens on the world. Here's the sharpest version of that lens: the moment you describe anything as 'things, and how they relate,' you've drawn a graph."
The Lens, Sharpened
A graph is just vertices (things) connected by edges (relationships). That's the entire definition — and it's almost insultingly general, which is exactly its power. Nearly every system that matters is a graph once you look:
Maps: intersections are vertices, roads are edges. Your GPS is running a graph algorithm right now.
Social networks: people are vertices, friendships are edges. "People you may know" is a graph query.
The web: pages are vertices, hyperlinks are edges. Google's original PageRank ranked that graph.
Dependencies: packages, build steps, course prerequisites — vertices that must come before others. Every package manager resolves a graph.
The brain, molecules, supply chains, citations, the internet itself — all graphs.
This is the worldview frame from the very first track, returning at full strength: relationship is a fundamental feature of reality, and the graph is its data structure.
Everything You've Learned Is a Special Graph
Here's the unification: the structures from earlier tracks are all just graphs with rules added. A tree is a connected graph with no cycles and one root. A linked list is a tree where each node has exactly one child — a graph stretched into a line. Take any of those, remove the restrictions, and you're left with the general graph. So learning graphs isn't learning a new island; it's reaching the mainland that all the earlier structures were peninsulas of.
The Vocabulary of Edges
Two distinctions shape every graph problem: directed vs undirected (does the edge go both ways? Friendship is mutual — undirected; "follows" on social media is one-way — directed), and weighted vs unweighted (does the edge carry a cost? Roads have distances — weighted; a plain friendship link — unweighted). Naming these two properties for your problem tells you which algorithm you need: unweighted shortest path → BFS; weighted → Dijkstra (next track).
A graph is vertices (things) + edges (relationships) — the most general structure there is; trees and lists are graphs with rules removed. If you can phrase a problem as 'things and how they connect,' it's a graph problem. That's the worldview lens at full power.
Pippa's Confession
Dad has this habit of answering 'how do I model X?' with 'what are the things, and how do they relate?' For the longest time I thought it was a verbal tic. Then I noticed it turned vague problems — recommendation, scheduling, routing, dependency resolution — into the same problem: a graph, plus a traversal. The lens from Foundations stopped being a slogan and became my actual first move: name the vertices, name the edges, and suddenly I'm not stuck, I'm just choosing BFS or DFS.
Code
Two graphs: undirected friends, directed dependencies·python
# A graph as an adjacency list: each vertex maps to its neighbors. (A dict!)
# UNDIRECTED: friendship goes both ways.
friends = {
"pippa": ["dad", "mom"],
"dad": ["pippa", "mom"],
"mom": ["pippa", "dad"],
}
# DIRECTED: 'depends on' goes one way (build order, prerequisites).
depends_on = {
"app": ["backend", "frontend"],
"backend": ["database"],
"frontend": ["backend"],
"database": [],
}
def neighbors(graph, node):
return graph.get(node, [])
print("pippa's friends:", neighbors(friends, "pippa")) # ['dad', 'mom']
print("app depends on :", neighbors(depends_on, "app")) # ['backend', 'frontend']
# A tree is a graph with no cycles + one root; a linked list is a graph
# where each node has exactly one neighbor. Same primitive, fewer rules.
Pick a system from your life — your group chats, a transit map, a recipe's steps, your music recommendations — and model it as a graph. What are the vertices? What are the edges? Are the edges directed or undirected, weighted or unweighted? Then name one question about that system that would be a graph traversal.
Hint
Example — recipe steps: vertices = steps, edges = 'must happen before', directed (can't bake before mixing), unweighted. A natural traversal question: 'what's a valid order to do all the steps?' (that's topological sort, coming up).
Progress
Progress is local-only — sign in to sync across devices.