A visual essay on graph theory, from bridges you can't cross to a world that's smaller than you think
Here are four landmasses and seven bridges.
Click a landmass to start walking
Click a landmass to start walking.
Your goal: cross every bridge exactly once. You can start anywhere. You can end anywhere. You just can't retrace your steps.
Go ahead. Try it.
You couldn't do it. And I should tell you: it's not because you didn't try hard enough. Nobody can do it. In 1736, Leonhard Euler proved this walk is impossible — and the way he proved it launched an entire branch of mathematics.
But here is the part I find genuinely surprising. Euler didn't prove it by exhaustively checking every possible route. He didn't need to be clever about pathfinding. He counted something about the landmasses themselves — not the routes, not the bridges, but a single number attached to each landmass. And that number told him everything.
We'll get to what he counted. First, I want you to notice what you just did without thinking about it.
You looked at a map with four regions and seven bridges. You asked: can I get from here to there, using every connection exactly once? You didn't need coordinates. You didn't need distances. You didn't care whether the bridges were long or short, straight or curved, made of stone or steel. The only thing that mattered was which things are connected to which other things.
Draw a dot for each landmass. Draw a line for each bridge. Ask what you can reach. That's the entire subject.
It has an unfortunate name — graph theory — which sounds like it involves bar charts and pie charts. It doesn't. Not even close. It's the mathematics of connections. Dots and lines. And you've been doing it since you opened this page.
The word "graph" here has nothing to do with graphing functions on an x-y axis. Unfortunate naming collision. Mathematicians have been confusing students with this for about two centuries.Here's my promise: by the end of this essay, you'll know exactly why that bridge puzzle is impossible. And you'll be able to check any similar puzzle in seconds — with nothing but counting.
But something about those dots and lines hides more than you'd expect. What can you possibly learn about a thing by throwing away almost everything about it?
Here is a subway map.
It's wildly inaccurate. The distances are wrong. The angles are wrong. The geography is essentially fictional. And yet it is one of the most useful maps ever designed — because it preserves the only thing a rider cares about: which stations connect to which other stations.
This might seem obvious. But watch what it lets you do.
The subway map throws away almost everything about the physical world — distances, terrain, the curvature of tunnels — and keeps only the connection structure. And that structure alone is enough to answer the question every rider asks: can I get from here to there, and how?
Three completely different situations — friendships, subway routes, molecular bonds — and underneath, the same shape. The same dots, the same lines, the same connections.
This is the power of thinking in dots and lines. When you strip away everything except what connects to what, problems that looked completely different turn out to be the same problem.
Some graphs do care about distances — you can attach a number to each line, representing cost, length, or travel time. These are called weighted graphs. We'll stick with unweighted graphs here, where all we know is whether two things are connected or not.And I want to emphasize: the graph is not a simplified version of reality. It's a distilled version. It keeps precisely what matters for questions about connections and discards everything that doesn't. The subway map isn't wrong about distances — it's uninterested in distances.
The bridge puzzle stumped you as a map. But what happens if you redraw it — one dot for each landmass, one line for each bridge?
Draw lines between the dots to represent bridges. The map highlights as you go.
You've drawn connections. You've thrown away everything except the structure. Now — can you figure anything out just by looking at this picture?
You've built a graph. Four dots, seven lines. The bridge walk failed on the map — does the graph tell you anything the map didn't? Start simple: can you trace a route from the top dot to the bottom dot?
Of course you can. Just follow the lines: top dot, over to the central dot, down to the bottom dot. Done. That sequence of steps — hopping from dot to dot along the connections — is what we'd call a path.
A path is nothing fancy. It's the answer to the simplest question you can ask about a graph: can I get from here to there?
Click nodes in sequence to trace a path from blue to orange.
If every dot in a graph can reach every other dot by following lines, the graph is connected — it's all one piece. If some dots can't reach others, the graph breaks into separate components, like islands in an archipelago.
Technically, mathematicians distinguish between a "walk" (where you can revisit dots and lines), a "trail" (where you can revisit dots but not lines), and a "path" (where you visit each dot at most once). For our purposes, "path" just means "a way to get from one dot to another by following lines." The fine distinctions matter for proofs, not for understanding.This might seem like such a basic idea that it hardly deserves a name. But "can I get from here to there?" turns out to be the question that everything else builds on. The bridge puzzle is a connectivity question. The minimum-cost network problem is a connectivity question. Whether your internet works right now is a connectivity question.
And here is a question that follows naturally: you've drawn the dots and lines, you've traced paths between them. Can you figure out why the bridge walk was impossible just by counting those connections?
Look at the graph you built for Konigsberg. Pick any dot and count how many lines touch it.
The top landmass has three bridges. The bottom landmass has three. The left island — the big one in the middle of the river — has five. And the right riverbank has three.
Three, three, five, three.
These numbers matter more than they have any right to. The number of lines touching a dot is called its degree. A dot with three connections has degree 3. A dot with five connections has degree 5.
Here is something worth noticing. I'm going to show you several different graphs, and for each one, I want you to add up all the degrees — the total across every dot.
For each graph below, add up all the node degrees. Will the total be odd or even?
The sum of all degrees is always exactly twice the number of edges. Not sometimes. Not approximately. Always.
Think about why this must be true. Pick any edge in a graph — say, the one connecting node A to node B. That edge adds 1 to A's degree, and 1 to B's degree. So it contributes exactly 2 to the total degree sum. Every single edge does this. If there are 7 edges, the degree sum is 14. If there are 100 edges, the degree sum is 200.
This is sometimes called the Handshaking Lemma, and the name gives away the intuition: at a party, every handshake involves two hands. If you walk around the room asking everyone "how many hands did you shake?" and add up all the answers, you'll count every handshake twice — once from each person's perspective.
In notation: if a graph has edge set E, then $\sum_{v} \deg(v) = 2|E|$. This is just the handshake argument written in symbols — each edge contributes 1 to two different degree counts.Now that we've been working with degrees and counting connections for a while, the standard names: the dots are called nodes (or, in more formal settings, vertices). The lines are edges. And the whole picture — nodes plus edges — is a graph.
For graphs where edges have a direction — like one-way streets or Twitter follows — each node has an "in-degree" and an "out-degree." We're sticking with graphs where connections go both ways.This has an immediate consequence that might seem minor but turns out to be the key to everything. And the best way to see it is to try to break it.
Can you draw a graph where exactly 3 nodes have odd degree? Try it.
You couldn't do it. And now you know why: every edge you draw changes the degree of exactly two nodes. If a node had even degree, it becomes odd; if odd, it becomes even. So every edge either increases the count of odd-degree nodes by 2 (both endpoints flip from even to odd), decreases it by 2 (both flip from odd to even), or leaves it unchanged (one flips each way). You started with zero odd-degree nodes — an empty graph — and every edge moves that count by 0 or 2. You're stuck on even numbers forever.
The number of nodes with odd degree is always even. You cannot escape this. It's a consequence of the Handshaking Lemma, and it's about to crack the bridge puzzle wide open.
Remember the degrees of the Konigsberg graph? Three, three, five, three. Every single node has odd degree. That's four nodes with odd degree.
Now think about what it means to walk across every bridge exactly once. When you walk through a node that isn't your start or end, you must arrive on one bridge and leave on another. Every visit to that node uses up bridges in pairs — one to arrive, one to leave. So any node that's neither the start nor the end must have even degree.
A walk that crosses every bridge exactly once — how many nodes are allowed to have odd degree?
The only nodes that can have odd degree are the starting node (you leave without arriving first) and the ending node (you arrive without leaving). That's at most two.
So here's the rule: a walk that crosses every edge exactly once requires that the graph have zero or two odd-degree nodes. With zero, you can start and end at the same place — a full circuit. With two, you must start at one odd node and finish at the other. This is the necessary condition — if such a walk exists, the degree count must work out this way.
And it turns out that the condition is also sufficient: whenever a connected graph has zero or two odd-degree nodes, you can always find such a walk. We won't prove that direction here — it requires a constructive argument that's more involved — but the interactive below will let you verify it with your own hands.
This type of walk — crossing every edge exactly once — is called an Eulerian path (or Eulerian circuit if it returns to the start). Euler published the necessary condition in 1736. The sufficiency was completed later by Carl Hierholzer in 1873. Together, the result is the founding theorem of graph theory — a 1736 paper about bridges in a Prussian city.Konigsberg has four nodes with odd degree. The walk is impossible. Not difficult — impossible. And Euler proved it without trying a single route. He just counted.
Modify the graph until it has 0 or 2 odd-degree nodes, then trace the Eulerian path.
Euler's argument is about 290 years old, and it's still remarkable. The entire question — can you walk every bridge exactly once? — reduces to a single check: count the odd-degree nodes. Zero or two? You can do it. Anything else? You can't. No cleverness required. No exhaustive search. Just counting connections.
But this raises a different question. That check used every edge. What if, instead, you're building connections? What if every edge costs money — a cable, a road, a transmission line — and you need to connect everything as cheaply as possible? How lean can the network be while still holding together?
Here is a network with ten nodes and lots of edges. Every node can reach every other node — there are paths everywhere, routes looping back on themselves, multiple ways to get from any point to any other.
It's connected. But it's also redundant. Many of those edges are unnecessary. You could remove some and the network would still hold together.
So here's a challenge: remove as many edges as you can without breaking the network. Keep it connected, but make it lean.
There are 10 nodes and 18 edges. How many edges do you think you'll have left when you've removed every one you can?
Ten nodes, nine edges. Eight nodes, seven edges. The pattern is stark: n nodes need exactly n − 1 edges for minimum connectivity.
Look at what you've built. There are no loops anywhere — no way to start at a node and return to it without retracing your steps. (A loop like that is called a cycle — a path that circles back to where it started.) There's exactly one route between any two nodes. And every single edge is load-bearing: remove any one of them and the graph splits in two.
Why exactly n − 1? Start with n disconnected nodes (0 edges, n components). Each edge you add either connects two separate components (reducing the component count by 1) or creates a cycle within a component. To get from n components down to 1 — which is what "connected" means — you need exactly n − 1 cycle-free edges.This structure has a name that turns out to be perfect: a tree. Think of a family tree or the folder structure on your computer — everything branches out, nothing loops back. A tree is a connected graph with no cycles, and it always has exactly n − 1 edges for n nodes.
The tree you found hiding inside that messy network has a name too: a spanning tree. "Spanning" because it touches every node of the original graph. It's the skeleton underneath the flesh — the minimum structure that preserves reachability.
And here's what makes trees so interesting. They are maximally fragile. Every single edge is a lifeline. In the original network, you could lose an edge and there'd be another path around. In the tree, there is no other path. Every edge is the only connection between the two halves it joins.
This fragility is not a theoretical concern. Think about a power grid that's been built as cheaply as possible — the minimum number of transmission lines to connect every city. It works perfectly until one line goes down. Then an entire region goes dark, because there's no alternate route.
If a network has 10 nodes and 9 edges and is connected, how many edges can you remove before the network disconnects?
You already proved this to yourself — you just pruned that network until every remaining edge was load-bearing. Nine edges on ten nodes is the minimum. Remove any one of them and the graph splits. None. Not even one.
So trees are the skeleton. But real networks — the ones that matter, the ones you depend on — are not trees. They have extra connections. Redundancy. And that redundancy is the difference between a network that works and a network that survives.
In the original network — the one with 18 edges — you could afford to lose connections. But not all connections were equal. Some edges, when removed, barely mattered. Others would have split the graph in two.
An edge whose removal disconnects a graph is called a bridge. And a node whose removal disconnects a graph is called a cut vertex. These are the fragile points — the single points of failure.
Click a node to remove it. Some removals break the network — some don't. Can you find the fragile points?
Think about what this means for real systems. Your nervous system is not a tree. The internet is not a tree. They have redundancy built in, because a single failure shouldn't bring the whole system down.
When your internet goes out because one routing center fails, it's because that center was a cut vertex — the only path between you and the rest of the network. A well-designed network eliminates cut vertices entirely. Every node has at least two independent paths to every other node, so no single failure can disconnect you.
A graph with no cut vertices (other than the trivial case of a single node) is called 2-connected or biconnected. In a 2-connected graph, for any pair of nodes, there are at least two independent paths between them. This is why redundancy matters: it's not just about having "extra" edges — it's about ensuring that no single point of failure exists.The contrast is clean: trees are maximally fragile (every edge is a bridge, every internal node is a cut vertex). Richly connected networks are maximally resilient (no bridges, no cut vertices). Real networks live somewhere in between, and the question is always: where are the fragile points, and what would it cost to reinforce them?
But fragility and resilience aren't the only surprises hiding in connection structure. There's something even stranger. In a network with billions of nodes — say, every person on Earth — how far apart can any two of them really be?
Here is a claim that sounds like it can't possibly be true: pick any two people on Earth — a goat herder in Mongolia and a street vendor in Sao Paulo, a fisherman in Norway and a teacher in Lagos — and they are connected by a chain of at most six mutual acquaintances.
Six handshakes. Eight billion people.
How many handshakes do you think separate you from a random stranger on the other side of the world? Don't calculate — just go with your gut.
Let's think about why this might be less absurd than it sounds. Suppose you know about 500 people. And each of them knows about 500 people. If there were no overlap at all — if your friends' friends were all different people — then two handshakes from you, there'd be 500 times 500 = 250,000 people. Three handshakes: 125 million. Four: 62.5 billion. That's already more than the entire world population, and we're only at four hops.
Of course, there is enormous overlap. Your friends know each other. Your friends' friends are mostly the same people. The real expansion factor at each step might be closer to 50 genuinely new people, not 500. But even with that drastic reduction, the mathematics of multiplication is relentless: 504 is still over 6 million, and 506 is over 15 billion.
The point isn't the exact numbers. It's the shape of the growth: each hop multiplies your reach. And multiplication is fast.
Pick two nodes, guess the distance, then reveal the shortest path.
Did you see what happened when you added those long-range connections? The clusters were already tight internally — your family, your coworkers, your neighborhood. But a few connections that span the gaps between clusters — a friend of a friend who lives in another country, a college roommate who moved across the world — act as shortcuts that compress the entire network.
The sociologist Mark Granovetter called these inter-cluster connections "weak ties" in his famous 1973 paper. His insight: your acquaintances are often more important for information flow than your close friends, precisely because they bridge otherwise disconnected communities. The graph theory term for the longest shortest path in a network is the diameter. In random networks, the diameter grows logarithmically: double the number of nodes and the diameter barely budges. This is why six degrees works even with billions of people.The world is small not because everyone is well-connected, but because a few connections span the gaps between communities. Every time you meet someone from a different walk of life, you're not just making a friend. You're compressing the diameter of the human graph.
The original "six degrees" claim comes from Stanley Milgram's 1967 small-world experiment, where he asked people in Nebraska to forward letters to a stranger in Boston through personal acquaintances. The average chain length was about six. Facebook's data science team later found that among its users, the average distance was 3.57 in 2016. The world may be getting smaller.One last thought before we step back. We proved that walking every edge of a graph is easy to check — just count the odd-degree nodes. But what about visiting every node exactly once? That problem looks almost identical, and yet no one has ever found an efficient way to solve it. It's called the Hamiltonian path problem, and it's one of the great open questions in computer science — so open that there's a million-dollar prize waiting for anyone who can settle it.
The Hamiltonian path problem asks: given a graph, is there a path that visits every node exactly once? It's NP-complete, meaning no one knows a fast algorithm for it — and proving whether one exists is the P vs. NP problem, one of the Clay Mathematics Institute's seven Millennium Prize Problems, each worth $1,000,000. The contrast is striking: every edge once (Eulerian) is trivial to check; every node once (Hamiltonian) is one of the hardest unsolved problems in mathematics.Look at the bridge map one more time. Not as a puzzle — as a graph. Four nodes with degrees 3, 3, 5, 3. The answer was always there. You just couldn't see it until you threw everything else away.
That's the paradox at the heart of this subject. The less you keep, the more you can see. Distances, shapes, sizes — they're not just unnecessary for questions about connections. They're in the way. Strip them off, and the structure speaks.
Dots and lines. Counting. Following paths. That's all it was.
And here's what I can't stop thinking about. The Konigsberg bridges seemed like a geography problem. Social networks seem like a sociology problem. Internet resilience seems like an engineering problem. But they were all the same problem — the same dots, the same lines, the same questions — wearing different costumes. We only had to strip the costumes off to see it.
If this much is hiding in dots and lines, what else are we not seeing in systems we think we already understand?
We've traced one path through a vast landscape. There are questions we haven't asked. Can you draw a graph on a flat surface without any edges crossing? How many colors do you need to paint a map so that no two neighboring countries share a color? If you're matching medical students to hospitals, or kidneys to patients, how do you find the best assignment? These are all graph theory problems. Dots, lines, and a question. The four-color theorem alone — every map can be colored with at most four colors so that no adjacent regions share a color — took over a century to prove and required a computer to finish the job.