You have met the four switches (D irection, W eight, S elf-loop, P arallel) in the parent note . Knowing the definitions is not the same as being able to classify and count in every situation. This page hunts down every case — every switch combination, the degenerate graphs (no edges, one vertex, everything self-loops), the limiting sizes, a word problem, and an exam twist — and works each one out from zero.
Intuition What "every scenario" means here
A graph question almost always asks one of two things: "classify this" (which switches are on?) or "count this" (how many edges / what degrees?). The answers change depending on the switch settings and on weird inputs like an empty graph or a single lonely dot. We are going to build a grid of those cases and fill in every cell.
Before working examples, let us list every case class this topic can throw at you. Each row is a "type of situation"; the last column names the worked example that lands in that cell.
#
Case class
What makes it tricky
Covered by
1
Undirected + simple, counting
divide-by-2 handshake
Ex 1
2
Directed + simple, counting
do not divide by 2
Ex 2
3
Multigraph (parallel edges) classify + degree
duplicates count separately
Ex 3
4
Self-loops present
a loop adds +2 to degree
Ex 4
5
Directed in-degree / out-degree split
two degrees per vertex
Ex 5
6
Weighted, real-world shortest path
picking BFS vs Dijkstra
Ex 6
7
Degenerate: empty edge set / single vertex / self-loops only
m = 0 , n = 1 , limiting behaviour
Ex 7
8
Limiting size: densest possible (complete graph)
m hits its maximum
Ex 8
9
Word problem mixing switches
translate English → ( V , E )
Ex 9
10
Exam twist: "is this degree sequence possible?"
Handshaking parity check
Ex 10
Every switch combination (directed?, weighted?, self-loop?, parallel?) and every degenerate/limiting input appears in at least one row. Now we clear the grid.
WHY these three and not others? Almost every counting question reduces to one of them. "How dense can it get?" → the max-edge formulas. "Do these degrees add up?" → the handshake. If you internalise why the 2 appears (an edge touches two endpoints; an unordered pair is one handshake between two people) you never memorise — you re-derive. The link Complete graph $K_n$ and dense vs sparse graphs pushes the first formula further; Handshaking lemma and degree sequences pushes the third.
Look at the figure above: the left panel is one undirected edge — one handshake, touched at two dots (blue). The right panel splits it into two directed arcs (orange). Same picture, but the edge count differs: 1 vs 2. Hold this image; it explains every divide-by-2 below.
Worked example Example 1 (Cell 1)
A group of n = 6 people. Everyone shakes hands with everyone else exactly once . Model as a simple undirected graph. How many edges (handshakes)?
Forecast: Guess before reading — is it 6 × 5 = 30 , or half of that? Write your guess.
Each handshake is an unordered pair of two distinct people. Why this step? "Simple" forbids duplicates and self-loops, so each pair is counted at most once and nobody shakes their own hand.
Count ordered picks first: first person 6 ways, second (different) 5 ways ⇒ 6 ⋅ 5 = 30 . Why? Easier to count ordered, then correct.
Divide by 2. Why? The pick "Alice then Bob" and "Bob then Alice" are the same handshake — look at the left panel of the figure, one line, two endpoints. So 30/2 = 15 .
m m a x = ( 2 6 ) = 2 6 ⋅ 5 = 15
Verify: Plug n = 6 into 2 n ( n − 1 ) = 2 6 ⋅ 5 = 15 . ✓ Sanity: 15 < 30, and the "/2" matched the mnemonic "a handshake needs two people but is one handshake".
Worked example Example 2 (Cell 2)
On Twitter, n = 6 users. What is the maximum number of follow relationships, where a follow is one-way and nobody follows themselves?
Forecast: Same n = 6 as Example 1. More edges or fewer? Guess.
A follow is an ordered pair ( u , v ) meaning "u follows v ". Why this step? Direction matters — Alice→Bob is a different fact from Bob→Alice (right panel of the figure).
Count picks: first (follower) 6 ways, second (followee, different) 5 ways ⇒ 30 . Why? Ordered pairs of distinct vertices.
Do NOT divide by 2. Why? ( u , v ) = ( v , u ) now — they are two genuinely different arcs, so no double-counting occurred.
m m a x = n ( n − 1 ) = 6 ⋅ 5 = 30
Verify: 6 ⋅ 5 = 30 . ✓ Exactly double Example 1's 15 — consistent with the figure (each undirected line = two directed arcs).
Worked example Example 3 (Cell 3)
V = { A , B , C } . Edges (undirected): A − B , A − B , B − C , A − C . Classify it, and give every degree.
Forecast: Simple or multi? And will ∑ deg = 2 m still hold with a duplicate?
Spot the duplicate: A − B appears twice . Why this matters? Two edges between the same pair = parallel edges , so the graph is a multigraph , not simple.
Count edges honestly: parallel edges are still separate edges, so m = 4 .
Degrees — count edge-endpoints at each vertex:
deg ( A ) : two A − B edges + one A − C = 3 .
deg ( B ) : two A − B + one B − C = 3 .
deg ( C ) : one B − C + one A − C = 2 .
Why count each parallel edge? A degree counts edges touching the vertex, and both parallel edges touch it.
Verify (Handshaking): ∑ deg = 3 + 3 + 2 = 8 and 2 m = 2 ⋅ 4 = 8 . ✓ Equal — the lemma survives parallel edges.
Worked example Example 4 (Cell 4)
V = { P , Q } . Undirected edges: P − Q , and a self-loop P − P . Give m and all degrees.
Forecast: Does the loop add 1 or 2 to deg ( P ) ?
Count edges: the loop is an edge, so m = 2 (one P − Q , one P − P ).
Degree of P : the edge P − Q contributes 1 ; the self-loop contributes 2 . Why + 2 ? A loop touches P at both of its endpoints — both ends land on P . Look at the figure below: the loop is a lasso whose two ends both attach to P .
deg ( P ) = 1 + 2 = 3
Degree of Q : just P − Q , so deg ( Q ) = 1 .
Verify (Handshaking): ∑ deg = 3 + 1 = 4 and 2 m = 2 ⋅ 2 = 4 . ✓ If you had wrongly counted the loop as + 1 , you'd get ∑ deg = 3 = 4 — the lemma catches the mistake.
Worked example Example 5 (Cell 5)
A directed graph V = { X , Y , Z } , arcs: ( X → Y ) , ( X → Z ) , ( Y → Z ) , ( Z → X ) . Give in-degree and out-degree of each vertex, and check a directed handshake law.
Forecast: In directed graphs, ∑ deg = 2 m splits into two separate sums. Guess what each equals.
Out-degree = arrows leaving. Why? It counts what a vertex points to .
out ( X ) = 2 (to Y , Z ), out ( Y ) = 1 (to Z ), out ( Z ) = 1 (to X ).
In-degree = arrows arriving. Why? Counts arcs pointing at the vertex.
in ( X ) = 1 (from Z ), in ( Y ) = 1 (from X ), in ( Z ) = 2 (from X , Y ).
Directed handshake: every arc leaves exactly one vertex and enters exactly one, so
∑ v out ( v ) = ∑ v in ( v ) = m .
Verify: ∑ out = 2 + 1 + 1 = 4 ; ∑ in = 1 + 1 + 2 = 4 ; and m = 4 . All three equal ✓ (see Topological sort , which relies on in-degrees being computed correctly).
Worked example Example 6 (Cell 6)
Four cities with roads (undirected, weighted by km):
A − B : 4 , A − C : 1 , C − B : 2 , B − D : 5 , C − D : 8 .
Find the shortest distance from A to D , and say which algorithm you'd use.
Forecast: The direct-looking route A − B − D is 4 + 5 . Is there something cheaper?
Weights are non-negative distances , and we want minimum total cost. Why this fixes the tool? Non-negative weights + shortest path ⇒ Dijkstra's algorithm . (Plain BFS — breadth first search would be wrong here because it ignores the numbers, treating every road as length 1.)
Enumerate simple routes A → D :
A − B − D = 4 + 5 = 9
A − C − B − D = 1 + 2 + 5 = 8
A − C − D = 1 + 8 = 9
Why enumerate? Small graph — direct check confirms Dijkstra's answer.
Take the minimum: min ( 9 , 8 , 9 ) = 8 , via A − C − B − D .
Verify: The green path in the figure sums 1 + 2 + 5 = 8 , beating the "obvious" A − B − D = 9 . ✓ Units: kilometres throughout — consistent.
Worked example Example 7 (Cell 7 — three degenerate sub-cases)
Handle each edge case with the formulas.
(a) Empty edge set: n = 4 , m = 0 . Degrees?
No edges touch anything, so every deg ( v ) = 0 . Why? Degree counts touching edges; there are none.
Verify: ∑ deg = 0 = 2 ⋅ 0 = 2 m . ✓
(b) Single vertex, simple undirected: n = 1 . Max edges?
( 2 1 ) = 2 1 ⋅ 0 = 0 . Why zero? A simple graph forbids self-loops, and there is no other vertex to connect to — a lonely dot.
Verify: 2 1 ⋅ ( 1 − 1 ) = 0 . ✓ Limiting sanity: the formula gracefully returns 0 , no special-casing needed.
(c) All self-loops, multigraph: n = 3 , each vertex has exactly one self-loop, no other edges. Degrees and m ?
m = 3 (three loops). Each loop adds + 2 to its vertex, so every deg = 2 .
Verify: ∑ deg = 2 + 2 + 2 = 6 = 2 ⋅ 3 = 2 m . ✓ Even a graph made only of loops obeys handshaking.
Worked example Example 8 (Cell 8)
A simple undirected graph on n = 10 vertices where every pair is joined — the complete graph K 10 . How many edges, and what is each degree?
Forecast: This is the maximum-density case. Guess m before computing.
Max edges = ( 2 n ) because "complete" means every allowed edge is present. Why? Density hits the ceiling from our first formula.
m = ( 2 10 ) = 2 10 ⋅ 9 = 45
Each vertex connects to all n − 1 others , so deg ( v ) = 9 for every v . Why? In K n everyone touches everyone except itself.
Verify (Handshaking): ∑ deg = 10 × 9 = 90 and 2 m = 2 × 45 = 90 . ✓ (See Complete graph $K_n$ and dense vs sparse graphs — this is the "dense" extreme; the empty graph of Ex 7a is the "sparse" extreme.)
Worked example Example 9 (Cell 9)
"A one-way road network of 5 intersections. Between intersection 2 and intersection 3 there are two separate one-way alleys, both 2 → 3 , with tolls $1 and $3. Other one-way roads: 1 → 2 ($5), 3 → 4 ($2), 4 → 5 ($4), 2 → 4 ($7)."
Classify all four switches, then find the cheapest 1 → 5 trip.
Forecast: Which switches are ON here?
Directed? Yes — every road is one-way (ordered pairs). Weighted? Yes — tolls. Self-loops? No road goes to its own intersection. Parallel edges? Yes — two 2 → 3 alleys ⇒ directed weighted multigraph . Why classify first? It tells you the model: parallel arcs must both be stored (adjacency list has both, see Graph representations — adjacency list vs matrix ).
Cheapest routes 1 → 5 : the only path to 5 is via 4 → 5 . Reach 4 either by 2 → 4 ($7) or 3 → 4 ($2) after 2 → 3 (cheapest alley $1).
1 → 2 → 3 → 4 → 5 = 5 + 1 + 2 + 4 = 12
1 → 2 → 4 → 5 = 5 + 7 + 4 = 16
Why take the $1 alley? Among parallel 2 → 3 arcs, shortest-path always uses the cheaper — the $3 one is dominated.
Minimum: min ( 12 , 16 ) = 12 .
Verify: 5 + 1 + 2 + 4 = 12 and 5 + 7 + 4 = 16 ; cheapest = 12 via the $1 alley. ✓ Units: dollars.
Worked example Example 10 (Cell 10)
Exam claim: "There exists a simple undirected graph on 5 vertices with degrees ( 3 , 3 , 3 , 3 , 1 ) ." True or false — and why, in one line?
Forecast: Try the handshake parity check before drawing anything.
Sum the degrees: 3 + 3 + 3 + 3 + 1 = 13 . Why sum? Handshaking says ∑ deg = 2 m , which must be even .
13 is odd ⇒ it cannot equal 2 m for any integer m . Why fatal? 2 m is always even; an odd total is impossible. (Corollary: the count of odd-degree vertices — here four 3's plus one 1 = five odd-degree vertices — is odd, but that count must always be even.)
Conclusion: the graph is impossible . Why so quick? No drawing needed — parity kills it instantly.
Verify: 3 + 3 + 3 + 3 + 1 = 13 , and 13 mod 2 = 1 = 0 , so no integer m gives 2 m = 13 . ✓ Also: number of odd-degree vertices = 5 , which is odd — violating the even-count corollary. (More in Handshaking lemma and degree sequences .)
Recall Quick self-test (reveal after guessing)
Max edges of simple undirected K n on n = 6 ? ::: ( 2 6 ) = 15 .
Same but directed, no self-loops, n = 6 ? ::: 6 ⋅ 5 = 30 .
A self-loop adds how much to a vertex's degree? ::: + 2 (both endpoints land on it).
Why is ( 3 , 3 , 3 , 3 , 1 ) impossible on 5 vertices? ::: Sum = 13 is odd, but ∑ deg = 2 m must be even.
Weighted non-negative shortest path — which algorithm? ::: Dijkstra (BFS ignores weights).
Mnemonic The whole page in one line
"Classify with DWSP, count with ( 2 n ) / n ( n − 1 ) , always sanity-check ∑ deg = 2 m ." The handshake check caught mistakes in Ex 3, 4, 7, 8 and proved impossibility in Ex 10 — make it your reflex.
Back to the parent topic . See also Trees as special graphs for the sparsest connected case (m = n − 1 ).