Visual walkthrough — Graph definitions — directed, undirected, weighted, unweighted, simple, multigraph
This is the visual companion to the parent topic. Read that first for the vocabulary; here we slow the maths right down.
Step 1 — Draw the dots, name the counts
WHAT. Put down some dots. Each dot is a vertex. The whole collection of dots is the set . The whole collection of connecting lines is the set .
We give two counts their own letters so we never have to say the long words again:
- ::: the little bars mean "how many things are in this set", so = number of dots.
- ::: same bars around , so = number of lines (edges).
WHY. Every edge question is really "given dots, how big can get?" So we must fix these two symbols before anything else.
PICTURE. Below: five dots labelled –, no lines yet. This is , — the empty starting canvas.

Step 2 — What is ONE edge allowed to be?
WHAT. An edge joins two dots. Before counting, we pin down two rules from the parent note:
- No self-loop → the two dots must be different (a dot cannot connect to itself here).
- Simple → between any pair, at most one line.
So a candidate edge is a pair of two distinct dots.
WHY. Counting edges = counting allowed pairs of dots. If we allowed self-loops or duplicates, the count would balloon — those cases get their own steps (7 and 8). We start with the clean simple case.
PICTURE. One green line between and : the atom we are about to count. Notice the red "forbidden" mark on the self-loop .

Step 3 — Count pairs the naïve way:
WHAT. Build a pair in two moves.
- ::: pick the first endpoint — any of the dots is fine.
- ::: pick the second endpoint — any dot except the one already picked (that "" is the no-self-loop rule doing its job).
WHY. This "multiply the choices" idea is the basic counting move: independent decisions multiply. It answers how many ordered ways can I name two different dots?
PICTURE. A grid of all ordered pairs for . The diagonal (same dot twice) is crossed out — that is why we get cells, not .

Step 4 — Spot the double-count
WHAT. In an undirected graph the line is the same line as . But in Step 3 we counted " then " and " then " as two separate things.
- ::: curly braces mean an unordered set — order inside does not matter, so both writings are one object.
WHY. A handshake between two people is one handshake, even though both people are involved. Ordered counting listed each handshake from both sides.
PICTURE. The same grid as Step 3, now with matching cells paired by a violet arrow: . Every off-diagonal cell has exactly one partner.

Step 5 — Divide by 2 → the master formula
WHAT. Since every undirected edge was counted exactly twice, halve the count:
- ::: the ordered count from Step 3.
- ::: the double-count fix from Step 4.
- ::: read "n choose 2" — a shorthand meaning the number of 2-element subsets of things, which is literally what we just computed.
WHY. This is the parent's headline formula, now earned rather than memorised. It is the edge count of the complete graph $K_n$ — the densest simple graph possible.
PICTURE. The complete graph on 5 dots. Count the green lines by hand: . And . ✓

Step 6 — The Handshaking Lemma falls out for free
WHAT. The degree of a dot is the number of line-ends touching it. Add degrees over all dots:
- ::: "add up the following, once for each dot ".
- ::: how many line-ends stick into dot .
- ::: twice the number of edges.
WHY. Every edge has two ends. When we walk from dot to dot totting up how many ends we see, we meet each edge once at each of its two dots — so each edge contributes to the grand total. Hence the sum equals , always.
Corollary (why it's useful): since the left side is (an even number), the dots with odd degree must pair up — the number of odd-degree vertices is always even. This is exactly the reasoning behind degree sequences.
PICTURE. A small graph where each edge is coloured, and each edge's two ends are ticked. Adding the ticks per dot gives the degrees; the grand total of ticks is visibly .

Step 7 — Edge case: allow self-loops
WHAT. Drop the "distinct dots" rule. Now an edge from a dot to itself is legal.
- For max simple-edge counting this changes nothing (self-loops were excluded on purpose), but it changes degree: a self-loop adds to that dot's degree (it has two ends, both at the same dot).
WHY. The Handshaking Lemma must still read . A self-loop is one edge with two ends — counting it as keeps the "every edge contributes 2" bookkeeping exact.
PICTURE. A single dot with a self-loop; both ends of the loop are marked at , showing from one edge.

Step 8 — Edge case: allow parallel edges (multigraph) & the tiny graphs
WHAT. Drop the "at most one line per pair" rule → a multigraph. Now has no upper bound at all: you can lay down 2, 5, 100 lines between the same two dots.
Degenerate small graphs — always sanity-check these:
| meaning | ||
|---|---|---|
| no dots, no edges | ||
| one lonely dot, nothing to connect to | ||
| one pair, one possible edge | ||
| a triangle |
WHY. The formula must survive its smallest inputs. At the factor kills the count — correct, a single dot cannot have a simple edge. At everything is empty. A multigraph escapes the bound entirely, which is precisely why is a simple-graph statement only.
PICTURE. Left: two dots with three parallel violet lines (, unbounded idea). Right: the lonely dot with the annotation .

The one-picture summary
Everything on one canvas: start with ordered pairs (directed answer), fold pairs together to halve into (undirected / ), and read the same edges as degree-ends summing to (handshake). The three big results are three views of one counting picture.

Recall Feynman retelling — say it to a 12-year-old
Put down some dots. To make a line I pick a dot ( ways), then a different dot ( ways) — that's ways to name a line. But if arrows don't matter, " then " is the very same line as " then ", so I counted every line twice — divide by 2, giving . That's the most lines a neat ("simple") drawing can have. Now flip it around: each line has two ends, so if I count all the ends poking into every dot, I've counted every line twice again — so all those degree-numbers add up to . A loop from a dot back to itself pokes both its ends into the same dot, so it counts as . And if I'm allowed to draw a bundle of lines between the same two dots (a multigraph), then there's no limit at all. That's the whole story — the same "two ends, count twice" idea, seen from three sides.
Where this leads
- The count vs an actual small is the whole story of dense vs sparse graphs.
- How you store those edges is adjacency list vs matrix — and note the " entries" warning for undirected lists comes straight from Step 6.
- Once you can walk edges: BFS, Dijkstra, Topological sort, and the acyclic special case, trees.