graphs and their words
shapes of data
what it is
A map here is places joined by roads. This page names its parts, counts its roads, and finds how few roads hold it together.
Books call a map a graph: a place is a vertex or a node, and a road is an edge. Here two places have at most one road between them. No road runs from a place to itself. The map below has 6 places and 7 roads.
A road runs both ways unless it is drawn with a head. Then it runs one way only, toward its head. Roads that run one way make a directed graph. There, two places may have one road each way.
A place's degree is the number of roads that end at it. Above, B has degree 3: roads to A, D and E. On one-way roads, count the roads in and the roads out apart. Question 1 below adds the degrees up.
A path is places one after another, each joined to the next by a road, with no place twice. Its length is its roads, not its places. When roads carry lengths, numbers such as kilometres written on them, a path's length is those numbers added up instead. A cycle comes back to its first place at the end, with no other place twice and no road twice. A, B, A is no cycle: it takes the road A to B twice.
On two-way roads, a piece is all the places you can travel between, so no road leads out of it. A map in one piece is connected. Books call a piece a connected component. Question 3 below finds how few roads one piece needs.
A map is dense when it holds nearly every road it could, and sparse when it has only a few times as many roads as places. Question 2 below counts the most it could hold. On small maps the two words overlap: 5 places with every road have 10 roads, only 2 times the places. They tell big maps apart, as the table below shows.
| places | most roads | 3 times the places |
|---|---|---|
| 5 | 10 | 15 |
| 7 | 21 | 21 |
| 50 | 1,225 | 150 |
| 1,000 | 499,500 | 3,000 |
where the formulas come from
Each question is worked out one numbered line at a time. A line shows the move it makes, the line itself, and why the move is allowed. A line either follows from the lines above it, or brings in something the question needs, such as how the method works, a small fact about , or a result from another page, with its own reason. Press 'hide the lines, then guess each one' to cover the lines and uncover them one by one, guessing each before you see it.
the move: count each road at both ends
the line:The map of 6 places, each place's degree written above it. why it is allowed: Let be the degrees added up. Every road has two ends, and it counts once at the place on each end, 2 in all. So roads give twos, the dots standing for the twos not written. For 7 roads, 7 twos.
the move: add the twos
the line:why it is allowed: twos make twice .
guess it, thenthe move: read it
the line:place degree A 2 B 3 C 2 D 2 E 3 F 2 all 14 The degrees of the 6 places, added. 14 is twice the 7 roads. why it is allowed: The map has 7 roads, and its degrees add to 14, twice 7.
guess it, thenthe move: odd degrees come in pairs
the line:why it is allowed: Line 2's total is twice , so it is even. In line 3's table, 14 is 8 from the even degrees and 6 from the odd ones, B's and E's. 14 and 8 are even, so 6 is too. Odd numbers add to an even number only in pairs. 3 + 3 is 6, but 3 + 3 + 1 is 7.
guess it, then
try it with a small : at , line 1 gives , which you can work out by hand
the move: count place by place
the line:Every two of 5 places joined. A has 4 roads, B 3 more, C 2 more, D 1 more, E none new. 4 + 3 + 2 + 1 = 10. why it is allowed: Let be the roads, for 2 places or more. List the places. The first has roads to the after it. The next adds one fewer new road, as its road to the first is counted already. Each adds one fewer, and the last adds none.
the move: use adding up 1 to n
the line:place new roads A 4 B 3 C 2 D 1 E 0 all 10 The new roads each place adds on line 1's map, in turn. 4 + 3 + 2 + 1 + 0 = 10. where does this come from?
question 1 of the page adding up Fit two staircases of squares together. What shape do they make? the move: draw the sum as a staircase
the line:why it is allowed: Let be the sum of the whole numbers from 1 to . Draw it as a staircase, a column for each number: 1 square, then 2, and so on up to . For 5, columns of 1, 2, 3, 4 and 5 hold 15 squares.
the move: take two staircases
the line:why it is allowed: Two staircases hold twice the squares. Doubling both sides of line 1 keeps it true.
the move: fit them into a rectangle
the line:Blue stands, yellow hangs. Two staircases of 1 to 5 squares fill a rectangle 5 wide and 6 tall, 30 squares. So 1 + 2 + 3 + 4 + 5 is 5 times 6, halved, which is 15. why it is allowed: Stand one staircase with its tallest column on the left. Hang the other upside down from the top, its tallest column on the right, as in the picture. The first column holds standing and 1 hanging. Each column to the right, the standing one loses a square and the hanging one gains one. So every column holds , and the columns fill a rectangle wide and tall.
the move: halve both sides
the line:why it is allowed: Halving both sides of line 3 keeps it true and leaves one . For 5, half of 30 is 15.
why it is allowed: Read from right to left, line 1 is 1 + 2 + up to . The box under this line adds 1 up to a last number with two staircases, that number times one more, halved. Here the last number is . One more than it is , so is times , halved. For 5, 1 + 2 + 3 + 4 is 4 times 5, halved, which is 10.
guess it, thenthe move: one way, each pair holds two
the line:why it is allowed: Let be the most one-way roads. A to B and B to A are two roads, one each way, so each pair holds two.
guess it, thenthe move: double line 2
the line:why it is allowed: Line 3 says is , and twice line 2 is . For 5 places, 20.
guess it, thenthe move: read it
the line:why it is allowed: 1,000 times 999, halved, is 499,500. A map of 1,000 places with 3,000 roads has 3 times as many roads as places, a few, so it is sparse. It holds 3,000 of the 499,500 it could.
guess it, then
try it with a small : at , line 1 gives , which you can work out by hand
the move: start with no roads
the line:why it is allowed: With no roads, each place is a piece on its own.
the move: a road joins two pieces at most
the line:7 places and 6 roads, yet two pieces. Laid after A to B, A to C and B to D, the road C to D joins two places already in one piece, so it joins nothing new. why it is allowed: A road between two pieces makes them one. A road inside one piece joins nothing new.
guess it, thenthe move: count the pieces left
the line:roads laid road pieces 0 none yet 7 1 A to B 6 2 A to C 5 3 B to D 4 4 C to D 4 5 E to F 3 6 E to G 2 The 7 places above, their 6 roads laid one at a time. The fourth, C to D, takes no piece away. 6 roads leave 2 pieces. why it is allowed: Lay the roads one at a time, and let be how many are laid. Start at pieces and take off at most 1 for each road.
guess it, thenthe move: ask for one piece
the line:why it is allowed: Line 3's pieces can be 1 only if is 1 or less.
guess it, thenthe move: turn it round
the line:why it is allowed: When is at most 1, falls short of by at most 1. So fewer than roads always leave two pieces or more. For 6 places, 4 roads take off at most 4 of the 6 pieces, so at least 2 are left.
guess it, thenthe move: a line of places is enough
the line:6 places, each joined to the next, drawn heavy. 5 roads hold them in one piece. why it is allowed: Each place after the first has one road back to the one before it. That is roads, and every place reaches the first.
guess it, thenthe move: the fewest
the line:why it is allowed: Let be the fewest roads. Line 5 says no fewer than will do, and line 6 that do.
guess it, then
try it with a small : at , line 7 gives , which you can work out by hand
a worked example
Read a map of 5 places.
- Its roads: V to X, V to Y, V to Z, W to X, W to Y and W to Z. That is 6 roads.
- Degrees: V 3, W 3, X 2, Y 2, Z 2. They add to 12, twice 6, as question 1 says.
- V and W have odd degree: two places, an even number.
- A path from V to W: V, X, W. It is 2 roads long.
- A cycle: V, X, W, Y and back to V. It is 4 roads long.
- Every place reaches every other, so the map is one piece. It has 6 roads, more than the 4 one piece needs.
the trap
check yourself
A map has 8 places, every two joined by a road. How many roads does it have?
the answer
By question 2, 8 times 7, halved, which is 28. Each place has degree 7, and the 8 degrees add to 56, twice 28.
Can a map have places of degrees 3, 3, 2, 2 and 1?
the answer
No. They add to 11, which is odd. By question 1, the degrees always add to twice the roads, an even number.
A map has 9 places and 7 roads. Can it be in one piece?
the answer
No. By question 3, one piece of 9 places needs at least 8 roads. With 7, at least two pieces are left.