Combinat or Ics
Combinat or Ics
by
Joy Morris
University of Lethbridge
c 2014–2017 by Joy Morris. Some rights reserved.
You are free to copy this book, to distribute it, to display it, and to make derivative works, under the
following conditions: (1) Attribution. You must give the original author credit. (2) Noncommercial.
You may not use this work for commercial purposes. (3) Share Alike. If you alter, transform, or build
upon this work, you may distribute the resulting work only under a license identical to this one. — For
any reuse or distribution, you must make clear to others the license terms of this work. Any of these
conditions can be waived if you get permission from the copyright holder. Your fair use and other rights
are in no way affected by the above. — This is a human-readable summary of the full license, which is
available on-line at
http://creativecommons.org/licenses/by-nc-sa/2.0/legalcode
Contents
Chapter 1. What is Combinatorics? 1
§1A. Enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
§1B. Graph Theory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 2
§1C. Ramsey Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
§1D. Design Theory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 4
§1E. Coding Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Summary - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5
Part I. Enumeration
Chapter 2. Basic Counting Techniques 8
§2A. The product rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
§2B. The sum rule - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 11
§2C. Putting them together . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
§2D. Summing up - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
i
ii
Index 202
What is
Combinatorics?
Combinatorics is a subfield of “discrete mathematics,” so we should begin by asking what
discrete mathematics means. The differences are to some extent a matter of opinion, and
various mathematicians might classify specific topics differently.
“Discrete” should not be confused with “discreet,” which is a much more commonly-used
word. They share the same Latin root, “discretio,” which has to do with wise discernment or
separation. In the mathematical “discrete,” the emphasis is on separateness, so “discrete” is
the opposite of “continuous.” If we are studying objects that can be separated and treated as
a (generally countable) collection of units rather than a continuous structure, then this study
falls into discrete mathematics.
In calculus, we deal with continuous functions, so calculus is not discrete mathematics. In
linear algebra, our matrices often have real entries, so linear algebra also does not fall into
discrete mathematics.
Text books on discrete mathematics often include some logic, as discrete mathematics is
often used as a gateway course for upper-level math. Elementary number theory and set theory
are also sometimes covered. Algorithms are a common topic, as algorithmic techniques tend to
work very well on the sorts of structures that we study in discrete mathematics.
In Combinatorics, we focus on combinations and arrangements of discrete structures. There
are five major branches of combinatorics that we will touch on in this course: enumeration,
graph theory, Ramsey Theory, design theory, and coding theory. (The related topic of cryptog-
raphy can also be studied in combinatorics, but we will not touch on it in this course.) We will
focus on enumeration, graph theory, and design theory, but will briefly introduce the other two
topics.
1A. Enumeration
Enumeration is a big fancy word for counting. If you’ve taken a course in probability and
statistics, you’ve already covered some of the techniques and problems we’ll be covering in
this course. When a statistician (or other mathematician) is calculating the “probability” of a
particular outcome in circumstances where all outcomes are equally likely, what they usually do
is enumerate all possible outcomes, and then figure out how many of these include the outcome
they are looking for.
EXAMPLE 1.1. What is the probability of rolling a 3 on a 6-sided die?
SOLUTION. To figure this out, a mathematician would count the sides of the die (there are
six) and count how many of those sides display a three (one of them). She would conclude that
the probability of rolling a 3 on a 6-sided die is 1/6 (one in six).
1
2 1. What is Combinatorics?
That was an example that you could probably figure out without having studied enumera-
tion or probability, but it nonetheless illustrates the basic principle behind many calculations
of probability. The object of enumeration is to enable us to count outcomes in much more
complicated situations. This sometimes has natural applications to questions of probability,
but our focus will be on the counting, not on the probability.
After studying enumeration in this course, you should be able to solve problems such as:
• If you are playing Texas Hold’em poker against a single opponent, and the two cards
in your hand are a pair, what is the probability that your opponent has a higher pair?
• How many distinct Shidokus (4-by-4 Sudokus) are there?
• How many different orders of five items can be made from a bakery that makes three
kinds of cookies?
• Male honeybees come from a queen bee’s unfertilised eggs, so have only one parent
(a female). Female honeybees have two parents (one male, one female). Assuming
all ancestors were distinct, how many ancestors does a male honeybee have from 10
generations ago?
Although all of these questions (and many others that arise naturally) may be of interest
to you, the reason we begin our study with enumeration is because we’ll be able to use many
of the techniques we learn, to count the other structures we’ll be studying.
be scheduled at the same time, or some nodes might represent students and others classes, with
a line between a student and each of the classes he or she is taking).
After studying graph theory in this course, you should be able to solve problems such as:
• How can we find a good route for garbage trucks to take through a particular city?
• Is there a delivery route that visits every city in a particular area, without repetition?
• Given a collection of project topics and a group of students each of whom has expressed
interest in some of the topics, is it possible to assign each student a unique topic that
interests him or her?
• A city has bus routes all of which begin and end at the bus terminal, but with different
schedules, some of which overlap. What is the least number of buses (and drivers)
required in order to be able to complete all of the routes according to the schedule?
• Create a schedule for a round-robin tournament that uses as few time slots as possible.
Some of these questions you may only be able to answer for particular kinds of graphs.
Graph theory is a relatively “young” branch of mathematics. Although some of the problems
and ideas that we will study date back a few hundred years, it was not until the 1930s that
these individual problems were gathered together and a unified study of the theory of graphs
began to develop.
We will touch lightly on Ramsey Theory in this course, specifically on Ramsey’s Theorem
itself, in the context of graph theory.
Codes are used for many purposes in which the information is not intended to be secret. For
example, computer programs are transformed into long strings of binary data, that a computer
reinterprets as instructions. When you text a photo to a friend, the pixel and colour information
are converted into binary data to be transmitted through radio waves. When you listen to an
.mp3 file, the sound frequencies of the music have been converted into binary data that your
computer decodes back into sound frequencies.
Electronic encoding is always subject to interference, which can cause errors. Even when
a coded message is physically etched onto a device (such as a dvd), scratches can make some
parts of the code illegible. People don’t like it when their movies, music, or apps freeze, crash,
or skip over something. To avoid this problem, engineers use codes that allow our devices to
automatically detect, and correct, minor errors that may be introduced.
In coding theory, we learn how to create codes that allow for error detection and correction,
without requiring excessive memory or storage capacity. Although coding theory is not a focus
of this course, designs can be used to create good codes. We will learn how to make codes from
designs, and what makes these codes “good.”
EXAMPLE 1.5. Suppose we have a string of binary information, and we want the computer to
store it so we can detect if an error has arisen. There are two symbols we need to encode: 0
and 1. If we just use 0 for 0 and 1 for 1, we’ll never know if a bit has been flipped (from 0 to 1
or vice versa). If we use 00 for 0 and 01 for 1, then if the first bit gets flipped we’ll know there
was an error (because the first bit should never be 1), but we won’t notice if the second was
flipped. If we use 00 for 0 and 11 for 1, then we will be able to detect an error, as long as at
most one bit gets flipped, because flipping one bit of either code word will result in either 01 or
10, neither of which is a valid code word. Thus, this code allows us to detect an error. It does
not allow us to correct an error, because even knowing that a single bit has been flipped, there
is no way of knowing whether a 10 arose from a 00 with the first bit flipped, or from a 11 with
the second bit flipped. We would need a longer code to be able to correct errors.
After our study of coding theory, you should be able to solve problems such as:
• Given a code, how many errors can be detected?
• Given a code, how many errors can be corrected?
• Construct some small codes that allow detection and correction of small numbers of
errors.
EXERCISES 1.6. Can you come up with an interesting counting problem that you wouldn’t
know how to solve?
SUMMARY:
• enumeration
• graph theory
• Ramsey theory
• design theory
• coding theory
Part I
Enumeration
Chapter 2
Basic Counting
Techniques
When we are trying to count the number of ways in which something can happen, sometimes the
answer is very obvious. For example, if a doughnut shop has five different kinds of doughnuts
for sale and you are planning to buy one doughnut, then you have five choices.
There are some ways in which the situation can become slightly more complicated. For
example, perhaps you haven’t decided whether you’ll buy a doughnut or a bagel, and the store
also sells three kinds of bagels. Or perhaps you want a cup of coffee to go with your doughnut,
and there are four different kinds of coffee, each of which comes in three different sizes.
These particular examples are fairly small and straightforward, and you could list all of the
possible options if you wished. The goal of this chapter is to use simple examples like these to
demonstrate two rules that allow us to count the outcomes not only in these situations, but in
much more complicated circumstances. These rules are the product rule, and the sum rule.
(that is, the number of columns in our table). This is an example of what we’ll call the product
rule.
We’re now ready to state the product rule in its full generality.
THEOREM 2.2. Product Rule Suppose that when you are determining the total number of
outcomes, you can identify two different aspects that can vary. If there are n1 possible outcomes
for the first aspect, and for each of those possible outcomes, there are n2 possible outcomes for
the second aspect, then the total number of possible outcomes will be n1 n2 .
In the above example, we can think of the aspects that can change as being the variety of
coffee, and the size. There are four outcomes (choices) for the first aspect, and three outcomes
(choices) for the second aspect, so the total number of possible outcomes is 4 · 3 = 12.
Sometimes it seems clear that there are more than two aspects that are varying. If this
happens, we can apply the product rule more than once to determine the answer, by first
identifying two aspects (one of which may be “all the rest”), and then subdividing one or both
of those aspects. An example of this is the problem posed earlier of buying a doughnut to go
with your coffee.
EXAMPLE 2.3. Kyle wants to buy coffee and a doughnut. The local doughnut shop has five
kinds of doughnuts for sale, and sells four varieties of coffee in three sizes (as in Example 2.1).
How many different orders could Kyle make?
SOLUTION. A natural way to divide Kyle’s options into two aspects that can vary, is to
consider separately his choice of doughnut, and his choice of coffee. There are five choices for
the kind of doughnut he orders, so n1 = 5. For choosing the coffee, we have already used the
product rule in Example 2.1 to determine that the number of coffee options is n2 = 12.
Thus the total number of different orders Kyle could make is n1 n2 = 5 · 12 = 60.
Let’s go through an example that more clearly involves repeated applications of the product
rule.
EXAMPLE 2.4. Chloë wants to manufacture children’s t-shirts. There are generally three
sizes of t-shirts for children: small, medium, and large. She wants to offer the t-shirts in eight
different colours (blue, yellow, pink, green, purple, orange, white, and black). The shirts can
have an image on the front, and a slogan on the back. She has come up with three images, and
five slogans.
To stock her show room, Chloë wants to produce a single sample of each kind of shirt that
she will be offering for sale. The shirts cost her $4 each to produce. How much are the samples
going to cost her (in total)?
SOLUTION. To solve this problem, observe that to determine how many sample shirts Chloë
will produce, we can consider the size as one aspect, and the style (including colour, image, and
slogan) as the other. There are n1 = 3 sizes. So the number of samples will be three times n2 ,
where n2 is the number of possible styles.
We now break n2 down further: to determine how many possible styles are available, you
can divide this into two aspects: the colour, and the decoration (image and slogan). There are
n2,1 = 8 colours. So the number of styles will be eight times n2,2 , where n2,2 is the number of
possible decorations (combinations of image and slogan) that are available.
We can break n2,2 down further: to determine how many possible decorations are available,
you divide this into the two aspects of image and slogan. There are n2,2,1 = 3 possible images,
and n2,2,2 = 5 possible slogans, so the product rule tells us that there are n2,2 = 3 · 5 = 15
possible combinations of image and slogan (decorations).
10 2. Basic Counting Techniques
Putting all of this together, we see that Chloë will have to create 3(8(3 · 5)) = 360 sample
t-shirts. As each one costs $4, her total cost will be $1440.
Notice that finding exactly two aspects that vary can be quite artificial. Example 2.4 serves
as a good demonstration for a generalisation of the product rule as we stated it above. In that
example, it would have been more natural to have considered from the start that there were
four apparent aspects to the t-shirts that can vary: size; colour; image; and slogan. The total
number of t-shirts she needed to produce was the product of the number of possible outcomes
of each of these aspects: 3 · 8 · 3 · 5 = 360.
THEOREM 2.5. Product Rule for many aspects Suppose that when you are determining the
total number of outcomes, you can identify k different aspects that can vary. If for each i
between 1 and k there are ni possible outcomes for the ith aspect, then the total number of
possible outcomes will be ki=1 ni (that is, the product as i goes from 1 to k of the ni ).
Q
Now let’s look at an example where we are trying to evaluate a probability. Since this
course is about counting rather than probability, we’ll restrict our attention to examples where
all outcomes are equally likely. Under this assumption, in order to determine a probability, we
can count the number of outcomes that have the property we’re looking for, and divide by the
total number of outcomes.
EXAMPLE 2.6. Peter and Mary have two daughters. What is the probability that their next
two children will also be girls?
SOLUTION. To answer this, we consider each child as a different aspect. There are two possible
sexes for their third child: boy or girl. For each of these, there are two possible choices for their
fourth child: boy or girl. So in total, the product rule tells us that there are 2 · 2 = 4 possible
combinations for the sexes of their third and fourth children. This will be the denominator of
the probability.
To determine the numerator (that is, the number of ways in which both children can be
girls), we again consider each child as a different aspect. There is only one possible way for
the third child to be a girl, and then there is only one possible way for the fourth child to be
a girl. So in total, only one of the four possible combinations of sexes involves both children
being girls.
The probability that their next two children will also be girls is 1/4.
Notice that in this example, the fact that Peter and Mary’s first two children were girls was
irrelevant to our calculations, because it was already a known outcome, over and done with, so
is true no matter what may happen with their later children. If Peter and Mary hadn’t yet had
any children and we asked for the probability that their first four children will all be girls, then
our calculations would have to include both possible options for the sex of each of their first two
children. In this case, the final probability would be 1/16 (there are 16 possible combinations
for the sexes of four children, only one of which involves all four being female).
EXERCISES 2.7. Use only the product rule to answer the following questions:
1) The car Jack wants to buy comes in four colours; with or without air conditioning;
with five different options for stereo systems; and a choice of none, two, or four floor
mats. If the dealership he visits has three cars in the lot, each with different options,
what is the probability that one of the cars they have in stock has exactly the options
he wants?
2) Candyce is writing a “Choose your own adventure” book in which she wants every
possible choice to result in a different ending. If there are four points at which choices
2. Basic Counting Techniques 11
must be made in every storyline, and there are three choices the first time but two
every time after that, how many endings does Candyce need to write?
3) William is buying five books. For each book he has a choice of version: hardcover,
paperback, or electronic. In how many different ways can he make his selection?
SOLUTION. To answer this question, we’ll break the problem into cases. First we’ll divide the
problem into two possibilities: Mary and Peter have no children; or they have at least one child.
If Mary and Peter have no children, this can happen in only one way (no boys and no girls). If
12 2. Basic Counting Techniques
Mary and Peter have at least one child, then they have between one and three children. We’ll
have to break this down further to find how many outcomes are involved.
We break the case where Mary and Peter have between one and three children down into
two cases: they might have one child, or they might have more than one child. If they have
one child, that child might be a boy or a girl, so there are two possible outcomes. If they have
more than one child, again we’ll need to further subdivide this case.
The case where Mary and Peter have either two or three children naturally breaks down into
two cases: they might have two children, or they might have three children. If they have two
children, the number of girls they have might be zero, one, or two, so there are three possible
outcomes (the remaining children, if any, must all be boys). If they have three children, the
number of girls they have might be zero, one, two, or three, so there are four possible outcomes
(again, any remaining children must be boys).
Now we put all of these outcomes together with the sum rule. We conclude that in total,
there are 1 + (2 + (3 + 4)) = 10 different combinations of girls and boys that Mary and Peter
might end up with.
Notice that it was artificial to repeatedly break this example up into two cases at a time.
Thus, Example 2.10 serves as a good demonstration for a generalisation of the sum rule as we
stated it above. It would have been more natural to have broken the problem of Mary and
Peter’s kids up into four cases from the beginning, depending on whether they end up with
zero, one, two, or three kids. The total number of combinations of girls and boys that Mary
and Peter might end up with, is the sum of the combinations they can end up with in each of
these cases; that is, 1 + 2 + 3 + 4 = 10.
THEOREM 2.11. Sum Rule for many cases Suppose that when you are determining the total
number of outcomes, you can identify k distinct cases with the property that every possible
outcome lies in exactly one of the cases. If for each i between 1 and k there are ni possible
outcomes in the ith case, then the total number of possible outcomes will be ki=1 ni (that is,
P
the sum as i goes from 1 to k of the ni ).
There is one other important way to use the sum rule. This application is a bit more
subtle. Suppose you know the total number of outcomes, and you want to know the number
of outcomes that don’t include a particular event. The sum rule tells us that the total number
of outcomes is comprised of the outcomes that do include that event, together with the ones
that don’t. So if it’s easy to figure out how many outcomes include the event that interests
you, then you can subtract that from the total number of outcomes to determine how many
outcomes exclude that event. Here’s an example.
EXAMPLE 2.12. There are 216 different possible outcomes from rolling a white die, a red die,
and a yellow die. (You can work this out using the product rule.) How many of these outcomes
involve rolling a one on two or fewer of the dice?
SOLUTION. Tackling this problem directly, you might be inclined to split it into three cases:
outcomes that involve rolling no ones, those that involve rolling exactly one one, and those that
involve rolling exactly two ones. If you try this, the analysis will be long and fairly involved,
and will include both the product rule and the sum rule. If you are careful, you will be able to
find the correct answer this way.
We’ll use a different approach, by first counting the outcomes that we don’t want: those
that involve getting a one on all three of the dice. There is only one way for this to happen: all
three of the dice have to roll ones! So the number of outcomes that involve rolling ones on two
or fewer of the dice, will be 216 − 1 = 215.
2. Basic Counting Techniques 13
EXERCISES 2.13. Use only the sum rule to answer the following questions:
1) I have four markers on my desk: one blue and three black. Every day on my way to
class, I grab three of the markers without looking. There are four different markers
that could be left behind, so there are four combinations of markers that I could take
with me. What is the probability that I take the blue marker?
2) Maple is thinking of either a letter, or a digit. How many different things could she be
thinking of?
3) How many of the 16 four-bit binary numbers have at most one 1 in them?
Menu
Mains Sides Beverages
pancakes fruit cup coffee
oatmeal toast tea
omelette orange juice
waffles
Pancakes, waffles, and toast come with butter.
Coffee and tea come with milk and sugar.
Optional extras:
marmalade, lemon curd, or blackberry jam for toast;
maple syrup for pancakes or waffles.
SOLUTION. We see that the number of choices Grace has available depends partly on whether
or not she orders an item or items that include optional extras. We will therefore divide our
consideration into four cases:
1) Grace does not order any pancakes, waffles, or toast.
2) Grace orders pancakes or waffles, but does not order toast.
3) Grace does not order pancakes or waffles, but does order toast.
4) Grace orders toast, and also orders either pancakes or waffles.
In the first case, Grace has three possible choices for her main dish (oatmeal, omelette, or
nothing). For each of these, she has two choices for her side dish (fruit cup, or nothing). For
each of these, she has four choices for her beverage (coffee, tea, orange juice, or nothing). Using
the product rule, we conclude that Grace could order 3 · 2 · 4 = 24 different breakfasts that do
not include pancakes, waffles, or toast.
In the second case, Grace has two possible choices for her main dish (pancakes, or waffles).
For each of these, she has two choices for her side dish (fruit cup, or nothing). For each of
these, she has four choices for her beverage. In addition, for each of her choices of pancakes or
14 2. Basic Counting Techniques
waffles, she can choose to have maple syrup, or not (two choices). Using the product rule, we
conclude that Grace could order 2 · 2 · 4 · 2 = 32 different breakfasts that include pancakes or
waffles, but not toast.
In the third case, Grace has three possible choices for her main dish (oatmeal, omelette, or
nothing). For each of these, she has only one possible side dish (toast), but she has four choices
for what to put on her toast (marmalade, lemon curd, blackberry jam, or nothing). For each of
these choices, she has four choices of beverage. Using the product rule, we conclude that Grace
could order 3 · 4 · 4 = 48 different breakfasts that include toast, but do not include pancakes or
waffles.
In the final case, Grace has two possible choices for her main dish (pancakes, or waffles).
She has two choices for what to put on her main dish (maple syrup, or only butter). She is
having toast, but has four choices for what to put on her toast. Finally, she again has four
choices of beverage. Using the product rule, we conclude that Grace could order 2 · 2 · 4 · 4 = 64
different breakfasts that include toast as well as either pancakes or waffles.
Using the sum rule, we see that the total number of different breakfasts Grace could order
is 24 + 32 + 48 + 64 = 168.
SOLUTION. To answer this question, there is a natural division into four cases: regular car
plates with three digits; regular car plates with four digits; veteran plates; and motorcycle
plates.
For a regular car plate with three digits, there are 24 choices for the first letter, followed by
24 choices for the second letter, and 24 choices for the third letter. There are 10 choices for the
first digit, 10 choices for the second digit, and 10 choices for the third digit. Using the product
rule, the total number of license plates in this category is 243 · 103 = 13, 824, 000.
For a regular car plate with four digits, there are 20 choices for the first letter, followed by
20 choices for the second letter, and 20 choices for the third letter. There are 10 choices for
the first digit, 10 choices for the second digit, 10 choices for the third digit, and 10 choices for
the fourth digit. Using the product rule, the total number of license plates in this category is
203 · 104 = 80, 000, 000.
For a veteran plate, there are 24 choices for the first letter, followed by 24 choices for the
second letter. There are 10 choices for the first digit, and 10 choices for the second digit. Using
the product rule, the total number of license plates in this category is 242 · 102 = 57, 600.
Finally, for a motorcycle plate, there are 24 choices for the first letter, followed by 24 choices
for the second letter. There are 10 choices for the first digit, 10 choices for the second digit,
and 10 choices for the third digit. Using the product rule, the total number of license plates in
this category is 242 · 103 = 576, 000.
2. Basic Counting Techniques 15
Using the sum rule, we see that the total number of license plates is
13, 824, 000 + 80, 000, 000 + 57, 600 + 576, 000
which is 94, 457, 600.
It doesn’t always happen that the sum rule is applied first to break the problem down into
cases, followed by the product rule within each case. In some problems, these might occur in
the other order. Sometimes there may seem to be one “obvious” way to look at the problem,
but often there is more than one equally effective analysis, and different analyses might begin
with different rules.
In Example 2.14, we could have begun by noticing that no matter what else she may choose,
Grace has four possible options for her beverage. Thus, the total number of possible breakfast
orders will be four times the number of possible orders of main and side (with optional extras).
Then we could have proceeded to analyse the number of possible choices for her main dish and
her side dish (together with the extras). Breaking down the choices for her main and side dishes
into the same cases as before, we could see that there are 3 · 2 = 6 choices in the first case;
2 · 2 · 2 = 8 choices in the second case; 3 · 4 = 12 choices in the third case; and 2 · 2 · 4 = 16
choices in the fourth case. Thus she has a total of 6 + 8 + 12 + 16 = 42 choices for her main
and side dishes. The product rule now tells us that she has 4 · 42 = 168 possible orders for her
breakfast.
Let’s run through one more (simpler) example of using both the sum and product rules,
and work out the answer in two different ways.
EXAMPLE 2.16. Kathy plans to buy her Dad a shirt for his birthday. The store she goes to
has three different colours of short-sleeved shirts, and six different colours of long-sleeved shirts.
They will gift-wrap in her choice of two wrapping papers. Assuming that she wants the shirt
gift-wrapped, how many different options does she have for her gift?
SOLUTION. Let’s start by applying the product rule first. There are two aspects that she can
vary: the shirt, and the wrapping. She has two choices for the wrapping, so her total number
of options will be twice the number of shirt choices that she has. For the shirt, we break her
choices down into two cases: if she opts for a short-sleeved shirt then she has three choices
(of colour), while if she opts for a long-sleeved shirt then she has six choices. In total she has
3 + 6 = 9 choices for the shirt. Using the product rule, we see that she has 2 · 9 = 18 options
for her gift.
Alternatively, we could apply the sum rule first. We will consider the two cases: that she
buys a short-sleeved shirt; or a long-sleeved shirt. If she buys a short-sleeved shirt, then she
has three options for the shirt, and for each of these she has two options for the wrapping,
making (by the product rule) 3 · 2 = 6 options of short-sleeved shirts. If she buys a long-sleeved
shirt, then she has six options for the shirt, and for each of these she has two options for the
wrapping, making (by the product rule) 6 · 2 = 12 options of long-sleeved shirts. Using the sum
rule, we see that she has 6 + 12 = 18 options for her gift.
EXERCISES 2.17. How many passwords can be created with the following constraints:
1) The password is three characters long and contains two lowercase letters and one digit,
in some order.
2) The password is eight or nine characters long and consists entirely of digits.
3) The password is five characters long and consists of lowercase letters and digits. All
of the letters must come before all of the digits in the password, but there can be any
number of letters (from zero through five).
16 2. Basic Counting Techniques
4) The password is four characters long and consists of two characters that can be either
digits or one of 16 special characters, and two lowercase letters. The two letters can
be in any two of the four positions.
5) The password is eight characters long and must include at least one letter and at least
one digit.
6) The password is eight characters long and cannot include any character more than
once.
EXERCISES 2.18.
1) There are 8 buses a day from Toronto to Ottawa, 20 from Ottawa to Montreal, and 9
buses directly from Toronto to Montreal. Assuming that you do not have to complete
the trip in one day (so the departure and arrival times of the buses is not an issue), how
many different schedules could you use in travelling by bus from Toronto to Montreal?
2) How many 7-bit ternary strings (that is, strings whose only entries are 0, 1, or 2) begin
with either 1 or 01?
2D. Summing up
Very likely you’ve used the sum rule or the product rule when counting simple things, without
even stopping to think about what you were doing. The reason we’re going through each of
them very slowly and carefully, is because whsen we start looking at more complicated problems,
our uses of the sum and product rules will become more subtle. If we don’t have a very clear
understanding in very simple situations of what we are doing and why, we’ll be completely lost
when we get to more difficult examples.
It’s dangerous to try to come up with a simple guideline for when to use the product rule
and when to use the sum rule, because such a guideline will often go wrong in complicated
situations. Nonetheless, a good question to ask yourself when you are trying to decide which
rule to use is, “Would I describe this with the word ‘and,’ or the word ‘or’ ?” The word “and”
is generally used in situations where it’s appropriate to use the product rule, while “or” tends
to go along with the sum rule.
Let’s see how this applies to each of the examples we’ve looked at in this chapter.
In Example 2.1, you needed to choose the size and the variety for your coffee. In Example 2.3,
Kyle wanted to choose a doughnut and coffee. In Example 2.4, Chloë needed to determine the
size and the colour and the image and the slogan for each t-shirt. In Example 2.6, we wanted
to know the sex of Peter and Mary’s third and fourth children. So in each of these examples,
we used the product rule.
In Example 2.8, you needed to choose a bagel or a doughnut. In Example 2.10, Mary and
Peter could have zero or one or two or three children. So in each of these examples, we used
the sum rule.
You definitely have to be careful in applying this guideline, as problems can be phrased in a
misleading way. We could have said that in Example 2.8, we want to know how many different
kinds of doughnuts and of bagels there are, altogether. The important point is that you aren’t
choosing both of these things, though; you are choosing just one thing, and it will be either a
doughnut, or a bagel.
In Example 2.14, Grace was choosing a main dish and a side dish and a beverage, so we used
the product rule to put these aspects together. Whether or not she had extra options available
for her main dish depended on whether she chose pancakes or waffles or oatmeal or omelette
or nothing, so the sum rule applied here. (Note that we didn’t actually consider each of these
four things separately, since they naturally fell into two categories. However, we would have
2. Basic Counting Techniques 17
reached the same answer if we had considered each of them separately.) Similarly, whether or
not she had extra options available for her side dish depended on whether she chose toast or
not, so again the sum rule applied.
In Example 2.15, the plates can be regular (in either of two ways) or veteran or motorcycle
plates, so the sum rule was used. In each of these categories, we had to consider the options
for the first character and the second character (and so on), so the product rule applied.
Finally, in Example 2.16, the shirt Kathy chooses can be short-sleeved or long-sleeved, so
the sum rule applies to that distinction. Since she wants to choose a shirt and gift wrap, the
product rule applies to that combination.
EXERCISES 2.19. For each of the following problems, do you need to use the sum rule, the
product rule, or both?
1) Count all of the numbers that have exactly two digits, and the numbers that have
exactly four digits.
2) How many possible outcomes are there from rolling a red die and a yellow die?
3) How many possible outcomes are there from rolling three dice, if you only count the
outcomes that involve at most one of the dice coming up as a one?
SUMMARY:
• Product rule.
• Sum rule.
• Combining the product and sum rules.
Chapter 3
Permutations,
Combinations, and
the Binomial
Theorem
The examples we looked at in Chapter 2 involved drawing things from an effectively infinite
population – they couldn’t run out. When you are making up a password, there is no way you’re
going to “use up” the letter b by including it several times in your password. In Example 2.4,
Chloë’s suppliers weren’t going to run out of blue t-shirts after printing some of her order,
and be unable to complete the remaining blue t-shirts she’d requested. The fact that someone
has already had one daughter doesn’t mean they’ve used up their supply of X chromosomes so
won’t have another daughter.
In this chapter, we’ll look at situations where we are choosing more than one item from a
finite population in which every item is uniquely identified – for example, choosing people from
a family, or cards from a deck.
3A. Permutations
We begin by looking at permutations, because these are a straightforward application of the
product rule. The word “permutation” means a rearrangement, and this is exactly what a
permutation is: an ordering of a number of distinct items in a line. Sometimes even though
we have a large number of distinct items, we want to single out a smaller number and arrange
those into a line; this is also a sort of permutation.
DEFINITION 3.1. A permutation of n distinct objects is an arrangement of those objects into
an ordered line. If 1 ≤ r ≤ n (and r is a natural number) then an r-permutation of n objects
is an arrangement of r of the n objects into an ordered line.
So a permutation involves choosing items from a finite population in which every item is
uniquely identified, and keeping track of the order in which the items were chosen.
Since we are studying enumeration, it shouldn’t surprise you that what we’ll be asking in
this situation is how many permutations there are, in a variety of circumstances. Let’s begin
with an example in which we’ll calculate the number of 3-permutations of ten objects (or in
this case, people).
18
3. Permutations, Combinations, and the Binomial Theorem 19
EXAMPLE 3.2. Ten athletes are competing for Olympic medals in women’s speed skating
(1000 metres). In how many ways might the medals end up being awarded?
SOLUTION. There are three medals: gold, silver, and bronze, so this question amounts to
finding the number of 3-permutations of the ten athletes (the first person in the 3-permutation
is the one who gets the gold medal, the second gets the silver, and the third gets the bronze).
To solve this question, we’ll apply the product rule, where the aspects that can vary are the
winners of the gold, silver, and bronze medals. We begin by considering how many different
athletes might get the gold medal. The answer is that any of the ten athletes might get that
medal. No matter which of the athletes gets the gold medal, once that is decided we move our
consideration to the silver medal. Since one of the athletes has already been awarded the gold
medal, only nine of them remain in contention for the silver medal, so for any choice of athlete
who wins gold, the number of choices for who gets the silver medal is nine. Finally, with the
gold and silver medalists out of contention for the bronze, there remain eight choices for who
might win that medal. Thus, the total number of ways in which the medals might be awarded
is 10 · 9 · 8 = 720.
We can use the same reasoning to determine a general formula for the number of r-
permutations of n objects:
THEOREM 3.3. The number of r-permutations of n objects is n(n − 1) . . . (n − r + 1).
PROOF. There are n ways in which the first object can be chosen (any of the n objects). For
each of these possible choices, there remain n − 1 objects to choose for the second object, etc.
It will be very handy to have a short form for the number of permutations of n objects.
NOTATION 3.4. We use n! to denote the number of permutations of n objects, so
n! = n(n − 1) . . . 1.
By convention, we define 0! = 1.
DEFINITION 3.5. We read n! as “n factorial,” so n factorial is n(n − 1) . . . 1.
Thus, the number of r-permutations of n objects can be re-written as n!/(n − r)!. When n = r
this gives n!/0! = n!, making sense of our definition that 0! = 1.
EXAMPLE 3.6. There are 36 people at a workshop. They are seated at six round tables of six
people each for lunch. The Morris family (of three) has asked to be seated together (side-by-
side). How many different seating arrangements are possible at the Morris family’s table?
SOLUTION. First, there are 3! = 6 ways of arranging the order in which the three members of
the Morris family sit at the table. Since the tables are round, it doesn’t matter which specific
seats they take, only the order in which they sit matters. Once the Morris family is seated, the
three remaining chairs are uniquely determined by their positions relative to the Morris family
(one to their right, one to their left, and one across from them). There are 33 other people
at the conference; we need to choose three of these people and place them in order into the
three vacant chairs. There are 33!/(33 − 3)! = 33!/30! ways of doing this. In total, there are
6(33!/30!) = 196, 416 different seating arrangements possible at the Morris family’s table.
By adjusting the details of the preceding example, it can require some quite different thought
processes to find the answer.
20 3. Permutations, Combinations, and the Binomial Theorem
EXAMPLE 3.7. At the same workshop, there are three round dinner tables, seating twelve
people each. The Morris family members (Joy, Dave, and Harmony) still want to sit at the
same table, but they have decided to spread out (so no two of them should be side-by-side) to
meet more people. How many different seating arrangements are possible at the Morris family’s
table now?
SOLUTION. Let’s begin by arbitrarily placing Joy somewhere at the table, and seating everyone
else relative to her. This effectively distinguishes the other eleven seats. Next, we’ll consider
the nine people who aren’t in Joy’s family, and place them (standing) in an order clockwise
around the table from her. There are 33!/(33 − 9)! ways to do this. Before we actually assign
seats to these nine people, we decide where to slot in Dave and Harmony amongst them.
9 J 1
8 2
7 3
6 4
5
(In the above diagram, the digits 1 through 9 represent the nine other people who are sitting
at the Morris family’s table, and the J represents Joy’s position.) Dave can sit between any
pair of non-Morrises who are standing beside each other; that is, in any of the spots marked by
small black dots in the diagram above. Thus, there are eight possible choices for where Dave
will sit. Now Harmony can go into any of the remaining seven spots marked by black dots.
Once Dave and Harmony are in place, everyone shifts to even out the circle (so the remaining
black dots disappear), and takes their seats in the order determined.
We have shown that there are 33!/24! · 8 · 7 possible seating arrangements at the Morris
table. That’s a really big number, and it’s quite acceptable to leave it in this format. However,
in case you find another way to work out the problem and want to check your answer, the total
number is 783, 732, 837, 888, 000.
EXERCISES 3.8. Use what you have learned about permutations to work out the following
problems. The sum and/or product rule may also be required.
1) Six people, all of whom can play both bass and guitar, are auditioning for a band.
There are two spots available: lead guitar, and bass player. In how many ways can the
band be completed?
2) Your friend Garth tries out for a play. After the auditions, he texts you that he got
one of the parts he wanted, and that (including him) nine people tried out for the five
roles. You know that there were two parts that interested him. In how many ways
might the cast be completed (who gets which role matters)?
3) You are creating an 8-character password. You are allowed to use any of the 26 lower-
case characters, and you must use exactly one digit (from 0 through 9) somewhere in
3. Permutations, Combinations, and the Binomial Theorem 21
the password. You are not allowed to use any character more than once. How many
different passwords can you create?
4) How many 3-letter “words” (strings of characters, they don’t actually have to be words)
can you form from the letters of the word STRONG? How many of those words contain
an s? (You may not use a letter more than once.)
5) How many permutations of {0, 1, 2, 3, 4, 5, 6} have no adjacent even digits? For example,
a permutation like 5034216 is not allowed because 4 and 2 are adjacent.
3B. Combinations
Sometimes the order in which individuals are chosen doesn’t matter; all that matters is whether
or not they were chosen. An example of this is choosing a set of problems for an exam. Although
the order in which the questions are arranged may make the exam more or less intimidating,
what really matters is which questions are on the exam, and which are not. Another example
would be choosing shirts to pack for a trip (assuming all of your shirts are distinguishable from
each other). We call a choice like this a “combination,” to indicate that it is the collection of
things chosen that matters, and not the order.
DEFINITION 3.9. Let n be a positive natural number, and 0 ≤ r ≤ n. Assume that we have
n distinct objects. An r-combination of the n objects is a subset consisting of r of the objects.
So a combination involves choosing items from a finite population in which every item is
uniquely identified, but the order in which the choices are made is unimportant.
Again, you should not be surprised to learn (since we are studying enumeration) that what
we’ll be asking is how many combinations there are, in a variety of circumstances. One signifi-
cant difference from permutations is that it’s not interesting to ask how many n-combinations
there are of n objects; there is only one, as we must choose all of the objects.
Let’s begin with an example in which we’ll calculate the number of 3-combinations of ten
objects (or in this case, people).
EXAMPLE 3.10. Of the ten athletes competing for Olympic medals in women’s speed skating
(1000 metres), three are to be chosen to form a committee to review the rules for future
competitions. How many different committees could be formed?
SOLUTION. We determined in Example 3.2 that there are 10!/7! ways in which the medals
can be assigned. One easy way to choose the committee would be to make it consist of the
three medal-winners. However, notice that if (for example) Wong wins gold, Šajna wins silver,
and Andersen wins bronze, we will end up with the same committee as if Šajna wins gold,
Andersen wins silver, and Wong wins bronze. In fact, what we’ve learned about permutations
tells us that there are 3! different medal outcomes that would each result in the committee
being formed of Wong, Šajna, and Andersen.
In fact, there’s nothing special about Wong, Šajna, and Andersen – for any choice of three
people to be on the committee, there are 3! = 6 ways in which those individuals could have
been awarded the medals. Therefore, when we counted the number of ways in which the medals
could be assigned, we counted each possible 3-member committee exactly 3! = 6 times. So the
number of different committees is 10!/(7!3!) = 10 · 9 · 8/6 = 120.
We can use the same reasoning to determine a general formula for the number of r-
combinations of n objects:
THEOREM 3.11. The number of r-combinations of n objects is
n!
.
r!(n − r)!
22 3. Permutations, Combinations, and the Binomial Theorem
PROOF. By Theorem 3.3, there are n!/(n − r)! r-permutations of n objects. Suppose that we
knew there are k unordered r-subsets of n objects (i.e. r-combinations). For each of these k
unordered subsets, there are r! ways in which we could order the elements. This tells us that
k · r! = n!/(n − r)!. Rearranging the equation, we obtain k = n!/(r!(n − r)!).
It will also prove extremely useful to have a short form for the number of r-combinations
of n objects.
NOTATION 3.12. We use nr to denote the number of r-combinations of n objects, so
n n!
= .
r r!(n − r)!
A common mistake in an example like this, is to divide the problem into the cases that
Jasmine is holding the Ace, or that she is holding the King, and to determine that each of these
cases includes 12 2 = 66 possible combinations of cards, for a total of 132. The problem with
this analysis is that we’ve counted the combinations that include both the Ace and the King
twice: once as a combination that includes the Ace, and once as a combination that includes
the King. If you do this, you need to compensate by subtracting at the end the number of
combinations that have been counted twice: that is, those that include the Ace and the King.
As we worked out in the example, there are 11 1 = 11 of these, making a total of 132 − 11 = 121
combinations.
EXERCISES 3.15. Use what you have learned about combinations to work out the following
problems. Permutations and other counting rules we’ve covered may also be required.
1) For a magic trick, you ask a friend to draw three cards from a standard deck of 52
cards. How many possible sets of cards might she have chosen?
2) For the same trick, you insist that your friend keep replacing her first draw until she
draws a card that isn’t a spade. She can choose any cards for her other two cards. How
many possible sets of cards might she end up with? (Caution: choosing 5♣, 6♦, 3♠ in
that order, is not different from choosing 6♦, 5♣, 3♠ in that order. You do not need
to take into account that some sets will be more likely to occur than others.)
3) How many 5-digit numbers contain exactly two zeroes? (We insist that the number
contain exactly 5 digits.)
4) Sandeep, Hee, Sara, and Mohammad play euchre with a standard deck consisting of
24 cards (A, K, Q, J, 10, and 9 from each of the four suits of a regular deck of playing
cards). In how many ways can the deck be dealt so that each player receives 5 cards,
with 4 cards left in the middle, one of which is turned face-up? The order of the 3 cards
that are left face-down in the middle does not matter, but who receives a particular
set of 5 cards (for example, Sara or Sandeep) does matter.
5) An ice cream shop has 10 flavours of ice cream and 7 toppings. Their megasundae
consists of your choice of any 3 flavours of ice cream and any 4 toppings. (A customer
must choose exactly three different flavours of ice cream and four different toppings.)
How many different megasundaes are there?
of a particular term ai b4−i will be the number of ways in which you can choose i of the factors
from which to take an a, taking a b from the other 4 − i factors (where 0 ≤ i ≤ 4).
Let’s go through each of these cases separately. By Theorem 3.11, there is 44 = 1 way to
choose four factors from which to take as. (Clearly, you must choose an a from every one of
the four factors.) Thus, the coefficient of a4 will be 1.
4
If you want to take as from three of the four factors, Theorem 3.11 tells us that there are
3 = 4 ways in which to choose the factors from which you take the as. (Specifically, these
four ways consist of taking the b from any one of the four factors, and the as from the other
three factors). Thus, the coefficient of a3 b will be 4.
If you want to take as from two of the four factors, and bs from the other two, Theorem 3.11
tells us that there are 42 = 6 ways in which to choose the factors from which you take the as
(then take bs from the other two factors). This is a small enough example that you could easily
work out all six ways by hand if you wish. Thus, the coefficient of a2 b2 will be 6.
4
If you want to take as from one of the four factors, Theorem 3.11 tells us that there are
1 = 4 ways in which to choose the factors from which you take the as. (Specifically, these
four ways consist of taking the a from any one of the four factors, and the bs from the other
three factors). Thus, the coefficient of ab3 will be 4.
Finally, by Theorem 3.11, there is 40 = 1 way to choose zero factors from which to take
as. (Clearly, you must choose a b from every one of the four factors.) Thus, the coefficient of
b4 will be 1.
Putting all of this together, we see that
(a + b)4 = a4 + 4a3 b + 6a2 b2 + 4ab3 + b4 .
In fact, if we leave the coefficients in the original form in which we worked them out, we
see that
4 4 4 3 4 2 2 4 4 4
(a + b)4 = a + a b+ a b + ab3 + b .
4 3 2 1 0
PROOF. As in Example 3.16, we see that the coefficient of ar bn−r in (a+b)n will be the number
of ways of choosing r of the n factors from which
we’ll take the a (taking the b from the other
n − r factors). By Theorem 3.11, there are nr ways of making this choice.
For the special case, begin by observing that (1 + x)n = (x + 1)n ; then take a = x and b = 1
in the general formula. Use the fact that 1n−r = 1 for any integers n and r.
n
Thus, the values
are the coefficients of the terms in the Binomial Theorem.
r
SUMMARY:
• The number of r-permutations of n objects is n!/(n − r)!.
• The number of r-combinations of n objects is nr = r!(n−r)!
n!
.
• The Binomial Theorem
• Important definitions:
◦ permutation, r-permutation
◦ n factorial
◦ r-combination
◦ n choose r
◦ binomial coefficients
• Notation:
◦ n!
n
◦ r
Chapter 4
Bijections and
Combinatorial
Proofs
You may recall that in Math 2000 you learned that two sets have the same cardinality if there is
a bijection between them. (A bijection is a one-to-one, onto function.) This leads us to another
important method for counting a set: we come up with a bijection between the elements of the
unknown set, and the elements of a set that we do know how to count. This idea is very closely
related to the concept of a combinatorial proof, which we will explore in the second half of this
chapter.
Aside: Although we won’t explore the concepts of P and NP at all in this course, those of
you who have studied these ideas in computer science courses may be interested to learn that
most of the techniques used to prove that a particular problem is in P or in NP are related
to the techniques discussed in this chapter. Usually a problem X is proven to be in NP (for
example) by starting with a problem Y that is already known to be in NP. Then the scientist
uses some clever ideas to show that problem Y can be related to problem X in such a way that
if problem X could be solved in polynomial time, that solution would produce a solution to
problem Y , still in polynomial time. Thus the fact that Y is in NP forces X to be in NP also.
The same ideas may sometimes relate the number of solutions of problem X to the number of
solutions of problem Y .
so many pieces involved that it is prone to error. Also, the value will not be easy to calculate
once n gets reasonably large.
Instead, we imagine creating a table. The columns are indexed by the elements of the set,
so there are n columns. We index the rows by the subsets of our set (one per row). In each
entry of the table, we place a 1 if the subset that corresponds to this row contains the element
that corresponds to this column. Here’s an example of such a table when the set is {x, y, z}:
x y z
∅ 0 0 0
{x} 1 0 0
{y} 0 1 0
{z} 0 0 1
{x, y} 1 1 0
{x, z} 1 0 1
{y, z} 0 1 1
{x, y, z} 1 1 1
As you can see, the pattern of 1s and 0s is different in each row of the table, since the elements
of each subset are different. Furthermore, any pattern of 1s and 0s that has length 3, appears
in some row of this table.
This is not a coincidence. In general, we can define a bijection between the binary strings of
length n, and the subsets of a set of n elements, as follows. We already know by the definition
of cardinality, that there is a bijection between our set of n elements, and the set {1, . . . , n},
so we’ll actually define a bijection between the subsets of {1, . . . , n} and the binary strings of
length n. Since the composition of two bijections is a bijection, this will indirectly define a
bijection between our original set, and the binary strings of length n.
Given a subset of {1, . . . , n}, the binary string that corresponds to this subset will be the
binary string that has 1s in the ith position if and only if i is in the subset. This tells us how to
determine the binary string from the subset. We can also reverse (invert) the process. Given
a binary string of length n, the corresponding subset of {1, . . . , n} will be the subset whose
elements are the positions of the 1s in the binary string.
Although we haven’t directly proven that this map from subsets to binary strings is both
one-to-one and onto, an invertible function must be a bijection, so the fact that we were able
to find an inverse function does prove that this map is a bijection. (You should check that you
agree that the function we’ve claimed as an inverse really does invert the original function.)
Now, our imaginary table wouldn’t be much use if we actually had to write it out. In order
to write it out, we would need to know all of the subsets of our set already; and if we knew
them all, we could certainly count them! Fortunately, we do not need to write it out. Instead,
we use the bijection we have just defined. Rather than count the number of subsets of an n-set,
we count the number of binary strings of length n. We can do this using just the multiplication
rule! In each position there is either a zero or a one, so there are 2 choices for each of the n
positions. Hence, there are 2n binary strings of length n.
We conclude that 2n subsets can be formed from a set of cardinality n.
In some ways, we’ve actually been using this idea pretty much every time we’ve come up
with more than one way to solve a problem. Implicitly, finding a different way of thinking of the
problem is equivalent to finding a bijection between the solutions to these different approaches.
EXAMPLE 4.2. How many ways are there to choose ten people from a group of 30 men and
30 women, if the group must include at least one woman?
4. Bijections and Combinatorial Proofs 29
SOLUTION. Attacking this problem directly will get ugly. We would have to consider sepa-
rately the cases of including one woman, two women, etc., all the way up to ten women, in our
group, and add all of the resulting terms together. Instead, we note that there is an obvious
bijection (the identity map) between groups that do include at least one woman, and groups
that do not include exactly zero women.
The latter is relatively easy to figure out: there are 60
10 possible groups of ten people that
could be chosen from the 60 people. Of these, there are 30 10 groups that include zero women
(since the members of any such group must be chosen entirely from the 30 men). Therefore,
the number of groups that do not include exactly zero women, is 60 30
10 − 10 .
Thanks to our bijection, we conclude that the number of groups that can be chosen, that
will include at least one woman, is also 60 10 − 30
10 .
EXERCISES 4.3. The following problems should help you in working with the bijective tech-
nique for counting.
1) We define a structure that is like a subset, except that any element of the original set
may appear 0, 1, or 2 times in the structure. How many of these structures can we
form from the set {1, . . . , n}?
2) Find a bijection between the coefficient of xr in (1 + x)n , and the number of r-
combinations of an n-set.
3) Find a bijection between the number of ways in which three different dolls can be put
into ten numbered cribs, and the number of ways in which ten Olympic contenders can
win the medals in their event.
THEOREM 4.4. Combinatorial Proofs If f (n) and g(n) are functions that count the number
of solutions to some problem involving n objects, then f (n) = g(n) for every n.
DEFINITION 4.5. Suppose that we count the solutions to a problem about n objects in one
way and obtain the answer f (n) for some function f ; and then we count the solutions to the
same problem in a different way and obtain the answer g(n) for some function g. This is a
combinatorial proof of the identity f (n) = g(n).
The equation f (n) = g(n) is referred to as a combinatorial identity.
In the statement of this theorem and definition, we’ve made f and g functions of a single
variable, n, but the same ideas hold if f and g are functions of more than one variable. Our
first example demonstrates this.
30 4. Bijections and Combinatorial Proofs
EXAMPLE 4.6. Prove that for every natural number n and every integer r between 0 and n,
we have
n n
= .
r n−r
COMBINATORIAL PROOF. By the definition of nr , this is the number of ways of choosing
r objects from a set of n distinct objects. Any time we choose r of the objects, the other n − r
objects are being left out of the set we are choosing. So equivalently, instead of choosing the r
objects to include in our set, we could choose the n − r objects to leave out of our set. By the
n
definition of the binomial coefficients, there are n−r ways of making this choice.
Therefore, it must be the case that for every natural number n and every integer r between
0 and n, we have
n n
= ,
r n−r
as desired.
n
Of course, this particular identity is also quite easy to prove directly, using the formula for
r , since
n n! n! n
= = = .
n−r (n − r)!(n − (n − r))! (n − r)!r! r
Many identities that can be proven using a combinatorial proof can also be proven directly, or
using a proof by induction. The nice thing about a combinatorial proof is it usually gives us
rather more insight into why the two formulas should be equal, than we get from many other
proof techniques.
In Example 4.1, we noted that one way to figure out the number of subsets of an n-element
set would be to count the number of subsets of each possible size, and add them all up. We
then followed a bijective approach to prove that the answer is in fact 2n . If we actually carry
through on the first idea, this leads to another combinatorial identity (one that we already
observed via the Binomial Theorem):
EXAMPLE 4.7. Prove that for every natural number n,
n
X n
= 2n .
r
r=0
COMBINATORIAL PROOF. We have seen in Example 4.1 that the number of subsets of a set
of n elements is 2n . We will count the same problem in a different way, to obtain the other side
of the equality.
To determine the number of subsets of a set of n elements, we break the problem down
into n + 1 cases, and use the sum rule. The cases into which we will divide the problem are
the different possible cardinalities for the subsets: everything from 0 through n. There are nr
ways to choose a subset of r elements from the set of n elements, so the number of subsets
that contain r elements is nr . Thus, the total number of subsets of our original set must be
Pn n
r=0 r .
Since we have counted the same problem in two different ways and obtained different for-
mulas, Theorem 4.4 tells us that the two formulas must be equal; that is,
n
X n
= 2n ,
r
r=0
as desired.
4. Bijections and Combinatorial Proofs 31
SOLUTION. Using the same reasoning that we applied in Example 4.2, we see that the number
of ways of choosing a group that includes at least one woman is the total number of ways of
choosing a groupof r people from these 2n people, less the number of ways that include only
men; that is: 2n n
r − r .
Alternatively, we can divide the problem up into r cases depending on how many women
are to be included in the group (there must be i women, for some 1 ≤ i≤ r). There are ni
n
ways to choose i women for the group, and for each of these, there are r−i ways to choose r − i
men to complete the group. Thus, the total number of ways of choosing a group that includes
at least one woman, is
r
X n n
.
i r−i
i=1
This argument yields the combinatorial identity
r
X n n 2n n
= − ,
i r−i r r
i=1
One context in which combinatorial proofs arise very naturally, is when we are counting
ordered pairs that have some property. That is, for some subset of X ×Y , we may wish to count
all of the ordered pairs (x, y), where x ∈ X and y ∈ Y , such that (x, y) has some property. We
can do this by first considering every possible value of x ∈ X, and for each such value, counting
the number of y ∈ Y such that (x, y) satisfies the desired property, or by first considering every
possible value of y ∈ Y , and for each such value, counting the number of x ∈ X such that (x, y)
satisfies the desired property.
Although this idea may not seem very practical, it is actually the context in which many of
the combinatorial proofs in later chapters will arise. We will be looking at a set X of elements,
and a set Y that is actually a collection of subsets of elements of X, and counting pairs (x, y)
for which the element x appears in the subset y. By counting these pairs in two ways, we will
find a combinatorial identity.
EXAMPLE 4.9. Let B be the set of city blocks in a small city, and let S be the set of street
segments in the city (where a street segment means a section of street that lies between two
intersections). Assume that each block has at least three sides. Count the number of pairs
(s, b) with s ∈ S and b ∈ B such that the street segment s is adjacent to the block b in two
ways. Use this to deduce a combinatorial inequality.
SOLUTION. Let |S| = t. Each street segment is adjacent to two blocks: the blocks that lie on
either side of the street. Therefore, for any given street segment s, there are two pairs (s, b) such
that s is adjacent to the block b. Multiplying this count by t (the number of street segments)
tells us that the total number of pairs (s, b) ∈ S × B with s adjacent to b is 2t.
Let |B| = c. Each block is adjacent to at least 3 street segments: the street segments that
surround the block. Therefore, for any given block b in the city, there are at least 3 pairs (s, b)
32 4. Bijections and Combinatorial Proofs
such that b is adjacent to the street segment s. Multiplying this count by c (the number of
blocks) tells us that the total number of pairs (s, b) ∈ S × B with s adjacent to b is at least 3c.
We deduce that 2t ≥ 3c.
EXERCISE 4.10. Let P be the set of people in a group, with |P | = p. Let C be a set of clubs
formed by the people in this group, with |C| = c. Suppose that each club contains exactly g
people, and each person is in exactly j clubs. Use two different ways to count the number of
pairs (b, h) ∈ P × C such that person b is in club h, and deduce a combinatorial identity.
EXERCISES 4.11. Prove the following combinatorial identities, using combinatorial proofs:
1) For any natural numbers r, n, with 1 ≤ r ≤ n, nr = n−1 n−1
r−1 + r .
[Hint: Consider the number of ways to form a team of r people from a group of n people. Then
break the problem into two cases depending on whether or not one specific person is chosen for
the team.]
n
r n
n−k
2) For any natural numbers k, r, n, with 0 ≤ k ≤ r ≤ n, r k = k r−k .
[Hint: Consider the number of ways to choose r dogs who will enter a competition, from a set
of n dogs, and to choose k of those r dogs to become the finalists. Then choose the finalists
first, followed by the other dogs who entered the competition.]
Pn n 2
= 2n
3) For any natural number n, r=0 r n .
n! (n−1)!
4) For n ≥ 1 and k ≥ 1, (n−k)! = n (n−1−(k−1))! .
1, 3n = nk=0 nk 2n−k .
P
5) For n ≥
EXERCISES 4.12. Sometimes the hardest part of a combinatorial proof can be figuring out
what problem the given formula provides a solution to. For each of the following formulas, state
a counting problem that can be solved by the formula.
1) n2n−1 .
2) nr=0 r nr .
P
3) nk=r nk kr .
P
4) 2n−r nr .
SUMMARY:
• Counting via bijections
• Combinatorial identities
• Combinatorial proofs
Chapter 5
Counting with
Repetitions
In counting combinations and permutations, we assumed that we were drawing from a set in
which all of the elements are distinct. Of course, it is easy to come up with a scenario in which
some of the elements are indistinguishable. We need to know how to count the solutions to
problems like this, also.
SOLUTION. Here, it matters who gets which bagel. We can model this by assuming that the
first bagel Chris orders will be for himself, the second for Jan, the third for Tom, and the last
for Olive. Thus, the order in which he asks for the bagels matters.
We actually saw back in Chapter 2 how to solve this problem. It’s just an application of the
product rule! Chris has eight choices for the first bagel; for each of these, he has eight choices
for the second bagel; for each of these, he has eight choices for the third bagel; and for each
of these, he has eight choices for the fourth bagel. So in total, he has 84 ways to choose the
bagels.
OK, so if the order in which we make the choice matters, we just use the multiplication
rule. What about if order doesn’t matter?
33
34 5. Counting with Repetitions
EXAMPLE 5.2. When Chris brought back the bagels, it turned out that he’d done a poor job
of figuring out what his friends wanted. They all traded around. Later that night, they sent
him to the doughnut store, but this time they told him to just bring back eight doughnuts and
they’d figure out who should get which. If the doughnut store has five varieties, how many
ways are there for Chris to fill this order?
SOLUTION. Let’s call the five varieties chocolate, maple, boston cream, powdered, and jam-
filled. One way to describe Chris’ order would be to make a list in which we first write one c
for each chocolate doughnut, then one m for each maple doughnut, then one b for each boston
cream doughnut, then one p for each powdered doughnut, and finally one j for each jam-filled
doughnut. Since Chris is ordering eight doughnuts, there will be eight letters in this list. Notice
that there’s more information provided by this list than we actually need. We know that all
of the first group of letters are cs, so instead of writing them all out, we could simply put a
dividing marker after all of the cs and before the first m. Similarly, we can put three more
dividing markers in to separate the ms from the bs, the bs from the ps, and the ps from the
js. Now we have a list that might look something like this:
cc||bbb|ppp|
(Notice in this possible list, Chris chose no maple or jam-filled doughnuts.)
Now, we don’t actually need to write down the letters c, m, b and so on, as long as we
know how many spaces they take up; we know that any letters that appear before the first
dividing marker are cs, for example. Thus, the following list gives us the same information as
the list above:
|| | |
Similarly, if we see the list
| | | |
we understand that Chris ordered no chocolate doughnuts; two maple doughnuts; two boston
cream doughnuts; three powdered doughnuts; and one jam-filled doughnut.
So an equivalent problem is to count the number of ways of arranging eight underlines and
four dividing markers in a line. This is something we already understand! We have twelve
positions that we need to fill, and the problem is: in how many ways can we fill eight of the
twelve positions with underlines (placing dividing markers in the other four positions). We
know that this can be done in 12 8 ways.
This technique can be used to give us a general formula for counting the number of ways of
choosing r objects from n types of objects, where we are allowed to repeatedly choose objects
of the same type.
THEOREM 5.3. The number of ways of choosing r objects from n types of objects (with re-
placement or repetition allowed) is
n+r−1
.
r
PROOF. We use the same idea as in the solution to Example 5.2, above. Since there are n
different types of objects, we will need n − 1 dividing markers to keep them apart. Since we
are choosing r objects, we will need r underlines, for a total of n + r − 1 positions to be filled.
We can choose the r positions in which the objects will go in n+r−1 r ways, and then (in each
case) put dividing markers into the remaining n − 1 positions. Thus, there are n+r−1
r ways to
choose r objects from n types of objects, if repetition or replacement of choices is allowed.
NOTATION 5.4. We use nr to denote the number of ways of choosing r objects from n types
The reason we say “replacement or repetition” is because there is another natural model for
this type of problem. Suppose that instead of choosing eight bagels from five varieties, Chris
is asked to put his hand into a bag that contains five different-coloured pebbles, and draw one
out; then replace it, repeatedly (with eight draws in total). If he keeps count of how many
times he draws each of the rocks, the number of possible tallies he’ll end up with is exactly the
same as the number of doughnut orders in Example 5.2.
The following table summarises some of the key things we’ve learned about counting so far:
Table 5.1. The number of ways to choose r objects from n objects (or types
of objects)
n!
order matters nr
(n − r)!
n n
order doesn’t matter
r r
SOLUTION. Initially, this looks a lot like a permutation question: we need to figure out the
number of ways to arrange the doughnuts in some order, and give the first doughnut to the
first student, the second doughnut to the second student, and so on.
The key new piece in this problem is that, unlike the permutations we’ve studied thus far,
the two chocolate doughnuts are indistinguishable (as are the three maple doughnuts and the
three boston cream doughnuts). This means that there is no difference between giving the
first chocolate doughnut to Tom and the second to Mohammed, and giving the first chocolate
doughnut to Mohammed and the second to Tom.
One way to solve this problem is to look at it as a series of combinations of the people, rather
than as a permutation question about the doughnuts. Instead of arranging the doughnuts,
we can first choose which two of the eight people will receive the two chocolate doughnuts.
Once that is done, from the remaining six people, we choose which three will receive maple
doughnuts. Finally, the remaining three people receive boston cream doughnuts. Thus, the
solution is 82 63 .
Another approach is more like the approach we used to figure out how many r-combinations
there are of n objects. In this approach, we begin by noting that we would be able to arrange
the eight doughnuts in 8! orders if all of them were distinct. For any fixed choice of two people
who receive the chocolate doughnuts, there are 2! ways in which those two chocolate doughnuts
could have been distributed to them, so in the 8! orderings of the doughnuts, each of these
choices for who gets the chocolate doughnuts has been counted 2! times rather than once.
Similarly, for any fixed choice of three people who receive the maple doughnuts, there are 3!
ways in which these three maple doughnuts could have been distributed to them, and each of
5. Counting with Repetitions 37
these choices has been counted 3! times rather than once. The same holds true for the three
boston cream doughnuts. Thus, the solution is 8!/(2!3!3!).
Since
8 6 8! 6! 8!
= · = ,
2 3 2!6! 3!3! 2!3!3!
we see that these solutions are in fact identical although they look different.
This technique can be used to give us a general formula for counting the number of ways
of arranging n objects some of which are indistinguishable from each other.
THEOREM 5.9. Suppose that:
• there are n objects;
• for each i with 1 ≤ i ≤ m, ri of them are of type i (indistinguishable from each other);
and
• r1 + . . . + rm = n.
Then the number of arrangements (permutations) of these n objects is
n!
.
r1 !r2 ! . . . rm !
PROOF. We use the same idea as in the solution to Example 5.8, above. Either approach will
work, but we’ll use the first. There will be n positions in the final ordering of the objects. We
begin by choosing r1 of these to hold the objects of type 1. Then we choose r2 of them to hold
the objects of type 2, and so on. Ultimately, we choose the final rm locations (in rrm m
= 1
possible way) to hold the objects of type m.
Using the product rule, the total number of arrangements is
n n − r1 n − r1 − . . . − rm−1
...
r1 r2 rm
n! (n − r1 )! (n − r1 − . . . − rm−1 )!
= · · ... ·
r1 !(n − r1 )! r2 !(n − r1 − r2 )! rm !0!
n!
= ,
r1 !r2 ! . . . rm !
since all of the other terms cancel.
SOLUTION. Even though all of the students in the class are distinct, the order in which they
get chosen for the group they end up in doesn’t matter. One way of making the selection would
be to put the names Cathy, Akos, and Dagmar into a hat (four times each) along with 18 blank
slips of paper. Each student could choose a slip of paper and would be assigned to the group
corresponding to the name they chose. The four slips with Cathy’s name on them are identical,
as are the four with Akos’ name, the four with Dagmar’s name, and the 18 blank slips.
Thus, the solution to this problem is
30 30!
= .
4, 4, 4, 18 4!4!4!18!
We could also work this out more directly, by allowing each of Cathy, Akos, and Dagmar to
choose four students; Cathy’s choice can be made in 30 26
4 ways; then Akos’ in 4 ways; then
Dagmar’s in 22
4 ways, and the product of these is 30!/(4!4!4!18!).
SUMMARY:
• The number of ways of choosing r objects from n types of objects (with replacement
or repetition allowed) is nr = n+r−1
r .
• The number of ways ofarranging n objects where ri of them are of type i (indistin-
guishable), is r1 ,r2n,...,rm .
• Notation:
◦ nr .
n
◦ r1 ,r2 ,...,rm .
Chapter 6
Induction and
Recursion
Some problems can most easily be solved (or counted) with the help of a recursively-defined
sequence. We’ll begin this chapter by introducing these sequences.
You should have seen basic proofs by induction in at least one previous course. Proofs by
induction are an important mathematical technique, and are often used in published papers.
We’ll do a quick review of basic proofs by induction, applying them to recursively-defined
sequences. Then we’ll touch on some slightly more sophisticated uses of induction. Proofs by
induction will be a technique we’ll use throughout the remainder of the course, in a variety of
contexts.
find the millionth term of a recursively-defined sequence directly, it will require a great deal of
computing time and might also require a lot of memory.
Every time you were asked in school to look at a sequence of numbers, find a pattern, and
give the next number in the sequence, you were probably working out a recurrence relation and
applying it.
EXAMPLE 6.3. Consider the sequence 5, 8, 11, 14. What number should come next?
This example shows that the recurrence relation can depend on n, as well as on the values
of the preceding terms. (Although we didn’t state this explicitly in our definition, it is implicit
because n − 1 is the number of previous terms on which rn depends; we could calculate n as
a01 + a02 + . . . + a0n−1 + 1.)
Let’s look at one more example.
EXAMPLE 6.5. Stavroula’s bank pays 1% interest (compounded annually), and charges her a
service fee of $10 per year to maintain the account. The fee is charged at the start of the year,
and the interest is calculated on the balance at the end of the year. If she starts with a balance
of $2000, is she making money or losing money? If this account is set up for her by her parents
and she’s not allowed to touch it, how much money will be in the account after seven years?
SOLUTION. We see that the initial term is r0 = 2000. We’re going to use r0 as the first term,
because then the value of her account after 1 year will be r1 ; after two years will be r2 ; and
after seven years will be r7 . This just makes it a little easier to keep track of what we’re aiming
to figure out.
If we unpack the financial language, it is telling us that every year, the bank takes $10 from
Stavroula’s account at the start of the year. Then at the end of the year, the bank adds 1% of
whatever is in Stavroula’s account, to her account. This can be represented by the following
recurrence relation: rn = rn−1 − 10 + .01(rn−1 − 10) for every n ≥ 1, which simplifies to
rn = 1.01(rn−1 − 10). Logically, she will be making money if the 1% that she earns in interest,
exceeds the service fee of $10, so if she makes money in the first year, she will continue to make
money; while if she loses money in the first year, she will continue to lose money after that. So
to answer the first question, we’ll work out r1 = 1.01(r0 − 10) = 1.01(1990) = 2009.9. Stavroula
is making money.
To answer the second question, unless we’ve managed to figure out an explicit formula for
rn (which we don’t yet know how to do), we need to calculate r2 , r3 , r4 , r5 , r6 , and r7 . It would
be reasonable to assume that the bank rounds its calculations to the nearest penny every year,
and carries forward with the rounded value, but because this will create an error that will be
6. Induction and Recursion 41
compounded in comparison with solving our recurrence relation explicitly (which we’ll learn
later how to do), we’ll keep track of the exact values instead. We have
r2 = 1.01(2009.9 − 10) = 2019.899;
r3 = 1.01(2009.899) = 2029.99799;
r4 = 1.01(2019.99799) = 2040.1979699;
r5 = 1.01(2030.1979699) = 2050.499949599;
r6 = 1.01(2040.499949599) = 2060.90494909499; and
r7 = 1.01(2050.90494909499) = 2071.4139985859399.
So at the end of seven years, Stavroula has $2071.41.
DEFINITION 6.8. In a proof by induction, determining that P (n0 ) is true for some particular
integer n0 is called the base case. Proving the conditional statement that P (k) ⇒ P (k + 1) for
every k ≥ n0 is called the inductive step. The assumption we make in the inductive step, that
P (k) is true for some arbitrary k ≥ n0 , is called the inductive hypothesis, and can be referred
to by (IH) when it is being used in the proof.
Now that we’ve gone through the formalities, let’s write a proper proof by induction for the
inequality we used to introduce this idea.
EXAMPLE 6.9. Prove by induction that n! ≥ 2n − 2, for every integer n ≥ 2. (This inequality
is actually true for every n ≥ 0, but the proof is considerably simpler if we restrict our attention
to n ≥ 2.)
Proofs by induction work very naturally with recursively-defined sequences, since the recur-
rence relation gives us information about the (k + 1)st term of the sequence, based on previous
terms.
EXAMPLE 6.10. Consider the sum of the first n integers. We can think about this as a
recursively-defined sequence, by defining s1 = 1, and sn = sn−1 + n, for every n ≥ 2. Thus,
s2 = 1 + 2;
s3 = s2 + 3 = 1 + 2 + 3,
and so on. Prove by induction that sn = n(n + 1)/2, for every n ≥ 1.
6. Induction and Recursion 43
Caution: the steps of a proof by induction are precisely defined, and if you leave any of
them out, or forget the conditions required, things can go badly wrong. The base case may
seem obvious, but can’t be left out; also, the hypothesis that k ≥ n0 may be critical to the
proof, as we saw in Example 6.9.
Let’s look at an example where, by forgetting to include the base case, we can give a “proof
by induction” of something that is clearly false.
EXAMPLE 6.11. Here is a “proof by induction” (without a base case) that every integer n is
at least 1000.
PROOF. Inductive step: We begin with the inductive hypothesis. Let k be arbitrary, and
suppose that k ≥ 1000.
Now we want to deduce that k + 1 ≥ 1000. But clearly,
k + 1 ≥ k ≥ 1000
(by our inductive hypothesis), which is what we wanted to deduce. This completes the proof
of the inductive step.
By the Principle of Mathematical Induction, n ≥ 1000 for every integer n.
Now it’s your turn to try a few, but don’t leave out any of the steps!
EXERCISES 6.12. Use the Principle of Mathematical Induction to prove the following:
1) For the recursively-defined sequence given by b1 = 5 and bn = bn−1 + 4 for all n ≥ 2,
prove that for every integer n ≥ 1, bn = 5 + 4(n − 1).
2) For the recursively-defined sequence given by c1 = 3 and cn = cn−1 + 3 · 2n−1 for all
n ≥ 2, prove that for every integer n ≥ 1, cn = 3(2n − 1).
3) Prove that for every integer n ≥ 0, n! ≥ n.
4) Prove that for every integer n ≥ 0, 4n − 1 is divisible by 3.
5) Starting with n = 2 and increasing n from there, calculate the first few values for the
product
n
Y 1
tn = (1 − ).
j
j=2
44 6. Induction and Recursion
Conjecture a closed formula for tn based on the values you have calculated, and use
induction to prove that your formula is correct.
6) Prove that for every integer n ≥ 1,
n
X 1
j! ≤ (n + 1)!
2
j=1
SOLUTION ATTEMPT. We begin with the base case: when n = 2, we have a2 = 2 = 22−1 ,
so the equality is true for the base case. Now for the inductive hypothesis, we let k ≥ 2 be
arbitrary, and suppose that the equality is true for n = k, so ak = 2k−1 . Now when n = k + 1,
we have
Xk
an = ak+1 = ai ,
i=1
by the recursive relation for this sequence. We know what a1 is, by our initial condition; we
know that ak = 2k−1 , but what about the values in between? The Principle of Mathematical
Induction as we’ve learned it so far, doesn’t allow us to assume anything about (for example)
ak−1 .
Actually, though, the way the concept of induction works, by the time we’re trying to
prove something about an , we’ve actually already deduced it for every value between n0 and
n − 1(inclusive). So there is nothing wrong with assuming that P (i) is true for every value
between n0 and k, rather than just for k, in order to deduce that P (k + 1) is true. More
concretely, this is saying the following. Suppose that by knowing P (0) we can deduce P (1),
and then by knowing P (0) and P (1) we can deduce P (2), and so on, so that eventually by
knowing that everything from P (0) through P (k) is true, we can deduce that P (k + 1) is true.
6. Induction and Recursion 45
Then P (n) is true for every integer n ≥ 0. Of course, we don’t have to start with 0; we can
start with any integer n0 . This is the strong form of mathematical induction:
THEOREM 6.14. Strong Induction Suppose we have a statement P (n) about the integer n. If
we know that
1) the statement P (n0 ) is true for some particular integer n0 ; and
2) for any integer k ≥ n0 , if every P (i) is true for n0 ≤ i ≤ k, then P (k + 1) must also
be true,
then P (n) is true for every integer n ≥ n0 .
Using this, we can complete the example we started above. We have a1 = 2 (by the initial
condition), and the strong induction hypothesis allows us to assume that ai = 2i−1 for every
integer i with 2 ≤ i ≤ k. So using the recursive relation
k
X
ak+1 = ai ,
i=1
we see that
k
X
ak+1 = 2 + 2i−1 .
i=2
You probably learned in high school how to add up geometric sequences like this; in particular,
that
Xk
2j = 2k+1 − 1,
j=0
to build the tower that contains j pieces, and k − j moves to build the tower that contains
k − j + 1 pieces. Together with her final move, then, it must take Shawna
(j − 1) + (k − j) + 1
moves in total to complete her tower of k + 1 pieces. Now,
(j − 1) + (k − j) + 1 = k,
so it takes Shawna k moves to complete the tower, which is what we wanted to deduce. This
completes the proof of the inductive step.
By Strong Induction, it will take Shawna n − 1 moves to complete a tower that contains n
blocks of lego, for every n ≥ 1.
This is pretty amazing. If we tried to go through the full argument for how many moves
it takes her to build a tower with four blocks, it would go something like this. First, to build
a tower with one block clearly takes 0 moves; to build a tower with two blocks clearly takes 1
move (stick the two blocks together). To build a tower with three blocks, we must use 1 move
to stick together a tower of two blocks (which took 1 move to create) with a tower of one block
(which took 0 moves to create), meaning that we use 2 moves altogether. Now, a tower of four
blocks can be built in two ways: by using 1 move to stick together two towers of two blocks,
each of which took 1 move to make, for a total of 3 moves; or by using 1 move to stick together
a tower of one block (which took 0 moves to make) with a tower of three blocks (which took
2 moves to make), for a total of 3 moves. So under either method, building a tower of four
blocks takes 3 moves. You can see that the argument will get more and more complicated as n
increases, but it will always continue to work.
We won’t need strong induction as such very much until later in the course, but the idea is
useful background for the next kind of induction we’ll look at, which is very important when
dealing with recurrence relations: induction with multiple base cases.
Induction with multiple base cases is very important for dealing with recursively-defined
sequences such as the Fibonacci sequence, where each term depends on more than one of the
preceding terms.
Suppose you were asked to prove that the nth term of the Fibonacci sequence, fn , is at
least 2n−2 . If we try to follow our basic inductive strategy, we’d begin by observing that this is
true for f0 :
f0 = 1 ≥ 2−2 = 1/4.
Then we’d make the inductive hypothesis that our inequality is true for some arbitrary k ≥ 0,
so fk ≥ 2k−2 . Now to deduce the inequality for n = k + 1, the natural approach is to use the
recursive relation, which tells us that
fk+1 = fk + fk−1 .
We can use our inductive hypothesis to make a substitution for fk , but what about fk−1 ? You
might (reasonably) argue at this point that we should use strong induction, which will allow us
to assume that the result is true for both fk and fk−1 , but actually, this doesn’t work! Why
not? Well, the trouble is that everything we know about the Fibonacci sequence starts with
f0 , but if k = 1 (which is the first time we try to use induction) then fk−1 = f−1 , which we
haven’t even defined! It is very important to ensure that in the inductive step, we never make
our assumption go back too far, i.e. to a value below n0 .
So, how can we deal with this problem? The solution is to add another base case, for n = 1.
When n = 1, we have
f1 = 1 ≥ 21−2 = 1/2.
6. Induction and Recursion 47
Now if we try induction, at the first step we will be using the fact that the statement is true
for f0 and f1 to prove it for f2 ; then the fact that it’s true for f1 and f2 will allow us to deduce
it for f3 , and so on. The final argument will look like the following.
EXAMPLE 6.16. Prove by induction that the nth term of the Fibonacci sequence, fn , is at
least (3/2)n−1 , for every n ≥ 0.
SOLUTION. Since the recursive relation for the Fibonacci sequence requires the two immedi-
ately preceding terms, we will require two base cases.
Proof. Base cases: When n = 0, we have
f0 = 1 ≥ (3/2)−1 = 2/3,
so the inequality holds for n = 0. When n = 1, we have
f1 = 1 ≥ (3/2)1−1 = 1,
so the inequality holds for n = 1. This completes the proof of the base cases.
Inductive step: We begin with the (strong) inductive hypothesis. Let k be an arbitrary
integer at least as big as our biggest base case, so k ≥ 1. Assume that for every integer i with
0 ≤ i ≤ k, we have fi ≥ (3/2)i−1 .
Now we want to deduce that
fk+1 ≥ (3/2)(k+1)−1 = (3/2)k .
Using the recursive relation, we know that fk+1 = fk + fk−1 . Since k ≥ 1, we have k − 1 ≥ 0, so
both k and k − 1 satisfy the bounds on i (that 0 ≤ i ≤ k), so that we can apply our inductive
hypothesis to both fk and fk−1 . We therefore have
k−1 k−2 k−2
5 3 k−2 5 3 3 k−2
k
3 3 3 3 3
fk+1 ≥ + = +1 = = · > ,
2 2 2 2 2 2 3 2 2 2
since 5/3 > 3/2. This is what we wanted to deduce. This completes the proof of the inductive
step.
By the Principle of Mathematical Induction, fn ≥ (3/2)n−1 for every n ≥ 0.
EXERCISES 6.17.
1) Prove by induction that for every n ≥ 0, the nth term of the Fibonacci sequence is no
greater than 2n .
2) The machine at the coffee shop isn’t working properly, and can only put increments of
$4 or $5 on your gift card. Prove by induction that you can get any amount of dollars
that is at least $12.
[Hint: You should have four base cases.]
3) Define a recurrence relation by a0 = a1 = a2 = 1, and an = an−1 + an−2 + an−3 for
n ≥ 3. Prove by induction that an ≤ 2n for all n ≥ 0.
48 6. Induction and Recursion
SUMMARY:
• Important definitions:
◦ recursively-defined sequence
◦ initial conditions
◦ recursive relation
◦ Fibonacci sequence
◦ proof by induction
◦ base case
◦ inductive step
◦ inductive hypothesis
◦ strong induction
◦ induction with multiple base cases
• Notation:
◦ (IH)
Chapter 7
Generating
Functions
Recall that the basic goal with a recursively-defined sequence, is to find an explicit formula for
the nth term of the sequence. Generating functions will allow us to do this.
1 + x + x2 + x3 + x4 + x5 .
49
50 7. Generating Functions
These generating functions can be manipulated. For example, if f (x) is as in Example 7.2(4),
suppose we take the product (1 − x)f (x). We have
(1 − x)f (x) = (1 − x)(1 + x + x2 + x3 + x4 + . . .)
= (1 + x + x2 + x3 + x4 + . . .) − (x + x2 + x3 + x4 + x5 + . . .)
= 1
Dividing through by 1 − x, we see that f (x) = 1/(1 − x).
This may seem artificial and rather nonsensical since the generating function was defined as
a formal object whose coefficients are a sequence that interests us. In fact, although we won’t
delve into the formalities in this course, algebraic manipulation of generating functions can be
formally defined, and gives us exactly these results.
A reasonable question at this point might be, what use is this? Even if we agree that
f (x) = 1/(1 − x), what we really want is the coefficient of xn (in order to retrieve an , the
nth term of our sequence). If we have an expression like 1/(1 − x), how can we work out the
coefficient of xn ?
EXERCISES 7.3. For each of the following sequences, give the corresponding generating func-
tion.
1) 1, 3, 5, 0, 0, 0, . . ..
2) 1, 2, 22 , 23 , 24 , . . ..
3) 1, 5, 10, 15, 10, 5, 1, 0, 0, 0, . . ..
4) 1, 5, 10, 10, 5, 1, 0, 0, 0, . . ..
EXAMPLE 7.5.
−2 (−2)(−3)(−4)(−5)(−6)
= = −6.
5 5!
−n
If n is a positive integer, then we can come up with a nice formula for r .
PROPOSITION 7.6. If n is a positive integer, then
−n r n+r−1
= (−1) .
r r
PROOF. We have
−n −n(−n − 1) . . . (−n − r + 1)
= .
r r!
Taking a factor of (−1) out of each term on the right-hand side gives
(−1)r n(n + 1) . . . (n + r − 1)/(r!).
Now,
(n + r − 1)(n + r − 2) . . . n = (n + r − 1)!/(n − 1)!,
so
r n(n + 1) . . . (n + r − 1) r (n + r − 1)! r n+r−1
(−1) = (−1) = (−1) ,
r! r!(n − 1)! r
as claimed.
With this definition, the binomial theorem generalises just as we would wish. We won’t
prove this.
THEOREM 7.7. Generalised Binomial Theorem For any n ∈ R,
∞
n
X n r
(1 + x) = x .
r
r=0
EXAMPLE 7.8. Let’s check that this gives us the correct values for the coefficients of f (x) in
Example 7.2(4), which we already know.
SOLUTION. We have
f (x) = (1 − x)−1 = (1 + y)−1 ,
where y = −x. The Generalised Binomial Theorem tells us that the coefficient of y r will be
−1 r 1+r−1
= (−1) = (−1)r ,
r r
since rr = 1. But we want the coefficient of xr , not of y r , and
y r = (−x)r = (−1)r xr ,
so we have
(−1)r y r = (−1)2r xr = 1r xr = xr .
Thus, the coefficient of xr in f (x) is 1. This is, indeed, precisely the sequence we started with
in Example 7.2(4).
in (1 − 2x)−5 and in x(1 − 2x)−5 , substitute n = k − 1, and add the two coefficients.
5) The coefficient of xk in 1/(1 − xj )n , where j and n are fixed positive integers.
Hint: Think about what conditions will make this coefficient zero.
for the binomial coefficients is (1 + x)n . In fact, the argument we used to prove the Binomial
Theorem explained why this works: if we want the coefficient of xr in (1 + x)n , it must be the
number of ways of choosing the x from r of the n factors, while choosing the 1 from the other
factors. We can use similar reasoning to solve other counting questions.
EXAMPLE 7.11. The grocery store sells paper plates in packages of 1, 5, 20, or 75. In how
many different ways can Jiping buy a total of 95 paper plates?
SOLUTION. We model this with generating functions. The exponent of x will represent the
number of paper plates, and the coefficient of xn will represent the number of ways in which
he can buy n paper plates.
We begin by considering the single paper plates that he buys. He could buy 0, or 1, or any
other number of these, so we represent this by the generating function
∞
X
2 3 4
1 + x + x + x + x + ... = xi = 1/(1 − x).
i=0
There is exactly one way of choosing any particular number of single paper plates (we are
assuming the plates are indistinguishable).
7. Generating Functions 53
Now, he could also buy any number of packages of 5 paper plates, but the difference is that
each package he buys contributes 5 to the exponent, since it represents 5 plates. We represent
this by the generating function
∞
X
5 10 15
1+x +x +x + ... = x5i = 1/(1 − x5 ),
i=0
The other advantage is that the generating function approach can help us solve problems
that we don’t see how to solve without it, such as finding an explicit formula for the nth term
of a recursively-defined sequence.
Here’s an example that involves working out the coefficient of a term in a generating function
in two different ways.
EXAMPLE 7.12. Consider the generating function (1/(1 − x))4 = (1 + x + x2 + x3 + . . .)4 . As
usual, we want to determine the coefficient of xr in this product.
SOLUTION. We must choose a power of x from each of the four factors, in such a way that
the sum of the powers we choose must be n. This is the same as choosing a total of r items,
when the items come in four distinct types (recall for example, Example 5.2). The types are
represented by the factor the term is chosen from, and the exponent chosen from that factor is
the number of items (xes) chosen of that type. So we know that the number of ways of doing
this is 4r .
We have another way of working this out. Our generating function is (1 − x)−4 , and the
Generalised Binomial Theorem tells us that the coefficient of (−x)r in this is −4 r , so the
coefficient of xr is
r r r+3 4
(−1) (−1) = .
r r
We’ll use the above example to work out a counting question, but first we need an obser-
vation.
PROPOSITION 7.13. For any positive integer k,
1 − xk+1
1 + x + x2 + · · · + xk = .
1−x
You can prove this by induction on k (this is one of the exercises below), or by multiplying
through by 1 − x.
EXAMPLE 7.14. Trent is playing a dice game, using 12-sided dice. How many ways are there
for him to roll a total of 24 on his four dice?
SOLUTION. Each die can roll any number between 1 and 12, and there are four dice, so the
appropriate generating function is
(x + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 + x12 )4 .
Rolling an i on one of the dice corresponds to choosing xi from the corresponding factor of this
generating function. We are looking for the coefficient of x24 , this will tell us the number of
ways of rolling a total of 24.
It turns out that by manipulating the generating function, we can work this out a bit more
easily than by multiplying this out. By taking a common factor of x out of each of the four
factors, our generating function can be re-written as
x4 (1 + x + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 )4 ,
and the coefficient of x24 in this, will be the same as the coefficient of x20 in
(1 + x + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9 + x10 + x11 )4 ,
Using Proposition 7.13, we see that this expression can be rewritten as
4
1 − x12
.
1−x
7. Generating Functions 55
EXERCISES 7.15.
1) Prove Proposition 7.13 by induction on k.
2) Find the number of ways Trent can roll a total of 16 on his four dice.
3) If Trent’s four dice are 10-sided dice instead of 12-sided, how many ways can he roll a
total of 24?
4) If Trent rolls five regular (6-sided) dice, how many ways can he roll a total of 11? What
is the probability that he will roll a total of 11?
SUMMARY:
• If n > 0 is an integer, then
−n r n+r−1
= (−1) .
r r
• The Generalised Binomial Theorem
• 1 + x + . . . + xk = (1 − xk+1 )/(1 − x)
• using generating functions for counting things
• Important definitions:
◦ generating function for a sequence
◦ generalised binomial coefficients
Chapter 8
Generating
Functions and
Recursion
We’ve seen how the Generalised Binomial Theorem can be used to extract coefficients from
a certain sort of generating function. Before we proceed with learning how to use generating
functions to find explicit formulas for the nth term of a recursively-defined sequence, we need
to know how to extract coefficients from some more complicated expressions.
SOLUTION. Well, if we could separate the factors of the denominator, we would know how to
deal with each separately. In fact, this is exactly what we do. We set
1+x A B
f (x) = = + .
(1 − 2x)(2 + x) 1 − 2x 2 + x
As we work this through, you’ll see that in working this out, we end up with two equations in
the two unknowns A and B, which we can therefore solve! So it is possible to “split up” the
original generating function, into two separate fractions, each of which has as its denominator
one of the factors of the original denominator. This is the method of partial fractions.
To solve for A and B, we add the fractions A/(1 − 2x) and B/(2 + x) over a common
denominator. This gives
A(2 + x) + B(1 − 2x) 1+x
= f (x) = .
(1 − 2x)(2 + x) (1 − 2x)(2 + x)
56
8. Generating Functions and Recursion 57
The method of partial fractions can be applied to any generating function that has a de-
nominator that can be factored into simpler terms. However, polynomials of degree 3 or higher
can become hard to factor, so we’ll mostly restrict our attention to applying this either with
denominators that are already factored, or with denominators that have degree at most two.
There is an extra trick that you should be aware of. This arises if the denominator is
divisible by a square. For example, if we are looking for the coefficient of xr in
1+x
g(x) =
(1 − 2x)2 (2 + x)
then it doesn’t make sense to separate all of the factors out as before, because
A B C A+B C
g(x) = + + = +
1 − 2x 1 − 2x 2 + x 1 − 2x 2 + x
and when we add this up, the denominator will be (1 − 2x)(2 + x) rather than (1 − 2x)2 (2 + x).
This can be dealt with in either of two ways. First, you can include both 1 − 2x and (1 − 2x)2
as denominators:
A B C
g(x) = + 2
+ .
1 − 2x (1 − 2x) 2+x
The second option is to include only (1 − 2x)2 as one of the denominators, but to include an x
in the corresponding numerator, in addition to the constant term:
Ax + B C
g(x) = 2
+ .
(1 − 2x) 2+x
58 8. Generating Functions and Recursion
Either of these methods can be generalised in natural ways to cases where the denominator is
divisible by some higher power.
We’ll see more examples of partial fractions applied to specific situations, so we’ll leave the
explanation there for now.
EXERCISES 8.2. Find the coefficient of xr in each of the following generating functions, using
the method of partial fractions and the Generalised Binomial Theorem.
1
1) (1+2x)(2−x)
x
2) (1+x)2 (1−x)
1+2x
3) (1−2x)(2+x)(1+x)
SOLUTION. We will use the formula given above. We have a = 3, b = −2, and c = 1. Then
√ √
2 2 + 4 − 12 2 − 4 − 12
3x − 2x + 1 = 1− x 1− x
2 2
√ √
= (1 − (1 + i 2)x)(1 − (1 − i 2)x).
It is always a good idea to check your result, by multiplying the factors back out.
When coefficients in the factorisation get ugly (even complex, as in the example above), you
might find the algebra involved in working out the coefficients hard to deal with. Let’s work
through an example of this, using the factorisation we’ve just completed.
8. Generating Functions and Recursion 59
You can see from this example that the algebra can get ugly, but the process of finding the
coefficient of xr is nonetheless straightforward.
60 8. Generating Functions and Recursion
EXERCISES 8.5. For each of the generating functions given, factor the denominator and use
the method of partial fractions to determine the coefficient of xr .
x
1) x2 +5x−1
2+x
2) 2x2 +x−1
x
3) x2 −3x+1
very likely that you’ve done the calculations correctly. Let’s check the first three terms of this
one. We know from our initial condition that a0 = 2, and our new formula gives
a0 = 1/2 + (3/2)30 = 1/2 + 3/2 = 2.
Using the recursive relation, we should have a1 = 3(2) − 1 = 5, and our formula gives
a1 = 1/2 + (3/2)31 = 1/2 = 9/2 = 5.
Finally, the recursive relation gives a2 = 3(5) − 1 = 14, while our formula gives
a2 = 1/2 + (3/2)32 = 1/2 + 27/2 = 14.
You can see the benefit to having an explicit formula if you were asked to work out a100 .
Clearly, it’s much easier to determine 1/2 + (3/2)3100 than to apply the recursive relation one
hundred times.
Let’s look at one more example, where the recursive relation involves more than one previous
term.
EXAMPLE 8.7. Consider the recursively-defined sequence: b0 = 1, b1 = 0, b2 = 1, and for
every n ≥ 3, bn = bn−1 − 2bn−3 . Find an explicit formula for bn in terms of n.
SOLUTION. The generating function for this sequence is
∞
X
b(x) = bi xi .
i=0
Again, we’ll use the recursive relation, which we rearrange as
bn − bn−1 + 2bn−3 = 0
for every n ≥ 3. We want to end up with a polynomial in which the coefficient of xm looks
like bm − bm−1 + 2bm−3 , so that we’ll be able to use the recursive relation to replace this by 0.
In order to do this, we’ll take b(x) (to get the bm xm piece), minus xb(x) (to get the −bm−1 xm
piece), plus 2x3 b(x) (to get the +2bm−3 xm piece).
The result looks like:
b(x) = b0 +b1 x +b2 x2 +b3 x3 + . . . +bm xm +...
−xb(x) = −b0 x −b1 x 2 −b2 x 3 − . . . −bm−1 x m −...
+2x3 b(x) = +2b0 x3 + . . . +2bm−3 xm + . . .
(1 − x + 2x3 )b(x) = b0 +(b1 − b0 )x +(b2 − b1 )x2 +0x3 + . . . +0xm +...
We see that this gives
(1 − x + 2x3 )b(x) = 1 + (−1)x + 1x2 .
Dividing through by 1 − x + 2x3 gives
1 − x + x2
b(x) = .
1 − x + 2x3
If we want to be able to do anything with this, we need to factor the denominator. Although
we don’t have a general method for factoring cubic polynomials, in this case it’s not hard to
see that −1 is a zero of the polynomial (because 1 − (−1) + 2(−1)3 = 0), and hence x + 1 is a
factor of the polynomial. You will not be expected to factor cubic polynomials yourself in this
course, so we won’t review polynomial long division, but if you recall polynomial long division,
you can use it to determine that
1 − x + 2x3 = (1 + x)(2x2 − 2x + 1).
In any case, you can multiply the right-hand side out to verify that it is true.
62 8. Generating Functions and Recursion
Now it’s time to use the factoring formula, with a = 2, b = −2, and c = 1, to factor
2x2 − 2x + 1. This gives
√ √
2 2+ 4−8 2− 4−8
2x − 2x + 1 = 1 1 − x 1− x = (1 − (1 + i)x) (1 − (1 − i)x) .
2 2
Having factored
1 − x + 2x3 = (1 + x)(1 − (1 + i)x)(1 − (1 − i)x),
we now apply the method of partial fractions to split this up into three separate pieces.
If
1 − x + x2 A B C
= + +
1 − x + 2x3 1 + x 1 − (1 + i)x 1 − (1 − i)x
A(2x2 − 2x + 1) + B(1 + x)(1 − (1 − i)x) + C(1 + x)(1 − (1 + i)x)
= ,
1 − x + 2x3
then this gives us three equations:
2A − B(1 − i) − C(1 + i) = 1
(from the coefficient of x2 );
−2A + B(1 − (1 − i)) + C(1 − (1 + i)) = −1
(from the coefficient of x); and A + B + C = 1 (from the constant term). The second of these
simplifies to −2A + iB − iC = −1.
The algebra can be done in different ways and gets a bit ugly, but these three equations
can be solved, resulting in A = 3/5, B = (2 − i)/10, C = (2 + i)/10.
Thus,
1 − x + x2 3/5 (2 − i)/10 (2 + i)/10
3
= + + .
1 − x + 2x 1 + x 1 − (1 + i)x 1 − (1 − i)x
The coefficient of xn in the first of these terms is (3/5)(−1)n ; in the second, it is ((2−i)/10))(1+
i)n , and in the third, it is ((2 + i)/10)(1 − i)n .
We conclude that for every n ≥ 0, we have
3 2−i 2+i
bn = (−1)n + (1 + i)n + (1 − i)n .
5 10 10
It is somewhat surprising that these formulas involving complex numbers will always work out
(when n is an integer) to be not only real numbers, but integers! Once again, we should check
this formula for several values of n to ensure we haven’t made errors in our calculations along
the way.
From the initial conditions, b0 = 1. Our formula gives
b0 = 3/5 + (2 − i)/10 + (2 + i)/10 = 1.
From the initial conditions, b1 = 0. Our formula gives
2−i 2+i
b1 = −3/5 + (1 + i) + (1 − i) = −3/5 + (3 + i)/10 + (3 − i)/10 = 0.
10 10
Finally, the initial conditions gave b2 = 1, and our formula gives
3 2−i 2+i 3 2i + 1 2i − 1
b2 = + (2i) + (−2i) = + − = 1.
5 10 10 5 5 5
We could continue, but this is sufficient verification to inspire reasonable confidence.
8. Generating Functions and Recursion 63
We now have a general method that we can apply to solve normal linear recursive relations:
Method
1) Rearrange the recurrence relation into the form
hn − a1 hn−1 − a2 hn−2 − . . . − ak hn−k = f (n),
for some function f (n). Let
a(x) = 1 − a1 x − a2 x2 − . . . − ak xk .
2) Define the generating function
h(x) = h0 + h1 x + h2 x2 + . . . .
3) Find a linear combination of the generating function so that the coefficient of xm is
f (m) for every m greater than or equal to some i ≥ k:
h(x) = h0 +h1 x +h2 x2 +h3 x3 + . . . +hi xi +...
−a1 xh(x) = −a1 h0 x −a1 h1 x2 −a1 h2 x − . . . −a1 hi−1 xi − . . .
3
5) Use partial fractions to get expressions that we can expand using the generalised bino-
mial theorem.
6) Make variable substitutions if necessary to get forms that look like
A
.
(1 + y)n
7) Use the generalised binomial theorem to find hn , the coefficient of xn in h(x).
EXERCISES 8.8. For each of the following recursively-defined sequences, use the method of
generating functions to find an explicit formula for the nth term of the sequence.
1) c0 = 2, c1 = 0, cn = cn−1 + 2cn−2 for every n ≥ 2.
2) d0 = 0, d1 = 1, dn = 2dn−2 + 1 for every n ≥ 2.
3) e0 = 2, en = 3en−1 − 2 for every n ≥ 1.
4) f0 = 1, f1 = 3, and fn = 4(fn−1 − fn−2 ) for every n ≥ 2.
5) g0 = 2, g1 = 0, and gn = 2gn−1 − 2gn−2 for every n ≥ 2.
6) h0 = 1/2 and hn = 3hn−1 − 1/2 for every n ≥ 1.
7) i0 = i1 = 2, i2 = 0, and in = 3in−1 − 3in−2 + in−3 for every n ≥ 3.
8) j0 = −1, j1 = 0, and jn = 2jn−1 + 3jn−2 for every n ≥ 2.
9) k0 = 10 and kn = 11kn−1 − 10 for every n ≥ 1.
64 8. Generating Functions and Recursion
SUMMARY:
• Method of partial fractions
• Formula for factoring quadratic polynomials into the required form
• Applying generating functions to recursively-defined sequences
Chapter 9
Some Important
Recursively-Defined
Sequences
9A. Derangements
DEFINITION 9.1. A derangement of a list of objects, is a permutation of the objects, in which
no object is left in its original position.
A classic example of this is a situation in which you write letters to ten people, address
envelopes to each of them, and then put them in the envelopes, but accidentally end up with
none of the letters in the correct envelope.
Another example might be a dance class in which five brother-sister pairs are enrolled. The
instructor mixes them up so that no one is dancing with a sibling.
Since we’re considering enumeration, it shouldn’t surprise you that the question we want
answered is: in how many ways can this happen? That is, given n objects, how many derange-
ments of the n objects are there? Let’s use Dn to denote the number of derangements of n
objects.
We can label the objects with the numbers {1, . . . , n}, and think of a derangement as a
bijection
f : {1, . . . , n} → {1, . . . , n},
such that f does not fix any value. There are n − 1 choices for f (n), since the only restriction
is f (n) 6= n. Say f (n) = i. We consider two possible cases.
Case 1 f (i) = n. Now, on the other n − 2 values between 1 and n that are neither i nor
n, f must map {1, . . . , n − 1} \ {i} to {1, . . . , n − 1} \ {i}, and must be a derangement. So there
are Dn−2 derangements that have f (n) = i and f (i) = n.
Case 2 f (j) = n for some j 6= i. In this case, we define another function
g : {1, . . . , n − 1} → {1, . . . , n − 1}
as follows. We set g(j) = i, and for every other value, g(a) = f (a) (that is, for every a ∈
{1, . . . , n − 1} \ {j}). We had f (j) = n and f (n) = i, and we are eliminating n from the
derangement while maintaining a bijection, by creating the shortcut f with g(j) = i but g(a) =
f (a) for every other a ∈ {1, . . . , n − 1}. Since f is a derangement and j 6= i, we see that g is
also a derangement (this time of n − 1 objects). So there are Dn−1 possible derangements g,
and for a fixed choice of i, these are in one-to-one correspondence with derangements f that
have f (j) = n and f (n) = i, so there are also Dn−1 of these.
65
66 9. Some Important Recursively-Defined Sequences
EXERCISES 9.3.
1) Use induction to prove Proposition 9.2.
2) Which kind of induction did you have to use to prove Proposition 9.2?
3) Calculate D5 using the explicit formula given in Proposition 9.2.
4) Calculate D5 using the recursive relation.
group of two terms; and the last two come from combining a single term with a group of three
terms.
([( · ) · ] · ), ([ · ( · )] · ), [( · ) · ( · )] ( · [( · ) · ]) ( · [ · ( · )]).
Thus,
C4 = C3 C1 + C2 C2 + C1 C3 = 2 + 1 + 2 = 5.
Now we want to use generating functions to figure out what we can about the Catalan
numbers. Unfortunately, there is a difficulty. Any time we want to use generating functions
to solve a recursively-defined sequence, the sequence must start with a 0th term, to be the
coefficient of x0 . With some recursively-defined sequences, we can simply use the recursive
relation “backwards” to solve previous terms, going down to n = 0, even if our initial conditions
began with much higher terms. For example, if a recursively-defined sequence is given by
h2 = 1, h3 = 5 and hn = 8hn−2 − hn−1 for every n ≥ 4, we can use n = 3 in this to get
h3 = 5 = 8h1 − h2 = 8h1 − 1.
Solving for h1 gives h1 = 3/4. Then using the recursive relation with n = 2 gives
h2 = 1 = 8h0 − h1 = 8h0 − 3/4.
Solving for h0 gives h0 = 7/32. This allows us to use generating functions on the sequence.
The recursive relation for the Catalan numbers doesn’t have a form that allows us to solve for
C0 by knowing other terms of the sequence, so we do what we have to, in order to make things
work. Instead of working with the generating function for the Catalan numbers themselves
(since we can’t), we work with the generating function for the sequence c0 , c1 , c2 , . . ., where
ci = Ci+1 for every i ≥ 0. In other words, the nth term of our new sequence will be the n + 1st
Catalan number.
Adjusting the recursive relation we’ve determined for the Catalan numbers to this new
sequence, gives
n−1
X
c0 = 1, and cn = ck cn−k−1 for every n ≥ 1.
k=0
Notice that
c(x)c(x) = (c0 + c1 x + c2 x2 + c3 x3 + . . .)(c0 + c1 x + c2 x2 + c3 x3 + . . .)
= c0 c0 + (c1 c0 + c0 c1 )x + (c2 c0 + c1 c1 + c0 c2 )x2 + (c0 c3 + c1 c2 + c2 c1 + c3 c0 )x3 + . . .
and in general, the coefficient of xm in (c(x))2 , is
m
X
ck cm−k .
k=0
This should look familiar! In fact, you can see that the coefficient of xm in (c(x))2 , is the same
as the coefficient of xm+1 in c(x), since the latter is
m
X
ck cm−k
k=0
also.
Thus, we have an expression for c(x) in terms of (c(x))2 , since multiplying (c(x))2 by x
gives all of the terms of c(x) except c0 : c(x) = x(c(x))2 + c0 . We can rearrange this equation,
to see that
x[c(x)]2 − c(x) + 1 = 0.
We are about to do something to this generating function that may seem a bit like black magic:
we will use the quadratic formula to factor this quadratic equation in c(x), treating x as the
68 9. Some Important Recursively-Defined Sequences
coefficient of (c(x))2 . Thus, in the quadratic formula, we take a = x, b = −1, and c = 1, and
obtain
√
1 ± 1 − 4x
c(x) = .
2x
Of course, there are two roots to this, and only one of them will give the correct generating
function; we need to work out which one (whether to take the plus or the minus).
Using the Generalised Binomial Theorem, we see that
1/2 1/2 1/2 1/2 2 1/2
(1 − 4x) = + (−4x) + (−4x) + . . . + (−4x)k + . . . ,
0 1 2 k
and
(−1)k−1 1 · 3 · 5 · (2k − 3)
1/2 (1/2)(−1/2)(−3/2) . . . (1/2 − k + 1)
= =
k k! 2k k!
so the coefficient of xk in (1 − 4x)1/2 is
The coefficients shown on the right-hand side of this equation quickly get big and negative.
If
√
1+ 1 − 4x
c(x) = ,
2x
then for n > 0 the coefficient of xn in c(x) will be half of the coefficient of xn+1 in (1 − 4x)1/2 ,
which (when n is large) will be big and negative. But it is easy to see from the recurrence
relation that all of the Catalan numbers are positive. To get positive coefficients, we must use
√
1 − 1 − 4x
c(x) = .
2x
Since in this expression we take the negative of the large negative coefficients, the result will
be large positive coefficients (even when we divide by 2, and look for the coefficient of xn+1 ).
Thus,
1+ ∞ 1 2k k
P
1 − (1 − 4x)1/2 k=0 2k−1 k x
c(x) = = .
2x 2x
9. Some Important Recursively-Defined Sequences 69
From this, we see that for n > 0, the coefficient of xn in c(x) is half of the coefficient of
xn+1 in (1 − 4x)1/2 , which is
1 2(n + 1) 1 (2n + 2)!
=
2 n + 1 2n + 1 2(n + 1)!(n + 1)!(2n + 1)
1 2n + 2 (2n)! 2n + 1
= · · ·
2 n + 1 (n + 1)!n! 2n + 1
1 2n
= .
n+1 n
So
1 2n
cn = .
n+1 n
1 0
Although we derived this expression for n > 0 only, we can verify that c0 = 1 = 0+1 0 since
0! = 1, so this expression is true for every n ≥ 0.
EXERCISES 9.5.
1) Use induction and the recursive relation for Catalan numbers (as adjusted for the values
of {ci }, where ci = Ci+1 ) to prove that cn > 0 for every n ≥ 0.
2) Calculate c4 using the explicit formula that we calculated in this section.
3) Calculate c4 using the recursive relation.
Obviously, the difference between this and an ordinary generating function comes from
the factorial expression in the denominator. Cancellation between this and expressions in the
numerator can lead to nicer compact expressions.
EXAMPLE 9.7. The exponential generating function for the sequence 1, 1, 1, . . . is
1 x x2
+ + + ....
0! 1! 2!
This is the Taylor series expansion for ex . Thus, ex is the exponential generating function for
1, 1, 1, . . ..
We will not be using exponential generating functions in this class; we are just introducing
the topic. We will go through one example of a sequence for which exponential generating
functions are useful: the Bell numbers.
DEFINITION 9.8. The Bell number Bn is the number of partitions of {1, . . . , n} into subsets.
Let’s look at the first few Bell numbers.
70 9. Some Important Recursively-Defined Sequences
EXAMPLE 9.9. There is only one way to partition {1} into subsets: {1}, so B1 = 1.
There are two ways to partition {1, 2} into subsets: {1}, {2}, or {1, 2}, so B2 = 2.
There are five ways to partition {1, 2, 3} into subsets: {1}, {2}, {3}, or {1, 2}, {3}, or
{1, 3}, {2}, or {2, 3}, {1}, or {1, 2, 3}, so B3 = 5.
Probably after seeing the above examples, you don’t want to calculate larger Bell numbers
directly. However, we can derive a recursive relation for these numbers. For this relation to
work properly, we will define B0 = 1.
PROOF. We’ll use a combinatorial proof of this statement. We know that Bn is the number of
partitions of {1, . . . , n} into subsets.
For the other side of the equation, let’s consider the subset that contains the element n, and
k ≥ 1, and since this is a subset
call the cardinality of this subset k. Since n is in this subset,
of {1, . . . , n}, we have k ≤ n, so 1 ≤ k ≤ n. There are n−1
k−1 waysto choose the remaining k − 1
elements of this subset; that is, for any 1 ≤ k ≤ n, there are n−1k−1 ways to choose the subset of
{1, . . . n} that contains the element n. For each of these ways, there are n − k other elements
that must be partitioned, and by the definition of the Bell numbers, there are Bn−k ways to
partition them into subsets. (Our definition of B0 = 1 deals with the case k = n, ensuring that
the n−1n−1 = 1 way of choosing n to be in a single set of all n elements is counted once and only
once.)
Thus, using the product and sum rules, we see that
n
X n−1
Bn = Bn−k .
k−1
k=1
Let us try to find the exponential generating function for the Bell numbers. When deal-
ing with exponential generating functions, notice that the derivative of xn /n! is nxn−1 /n! =
xn−1 /(n − 1)!, so taking derivatives often results in a nice expression that helps us find a nice
expression for the coefficients. You already know a particularly nice example of this: the deriv-
ative of ex is ex , which tells us that all of the coefficients in that exponential generating function
are equal.
Define
∞
X xi x x2 xn
B(x) = Bi = B0 + B1 + B2 + . . . + Bn + ....
i! 1! 2! n!
i=0
Using our recursive relation from Proposition 9.10, we see that this is
∞ X
" n #
xn−1
d X n−1
B(x) = Bn−k
dx k−1 (n − 1)!
n=1 k=1
∞ X n
" #
X (n − 1)! xn−1
= Bn−k
(k − 1)!(n − k)! (n − 1)!
n=1 k=1
∞ X n
" #
X 1
= Bn−k xn−1
(k − 1)!(n − k)!
n=1 k=1
∞ X
" n #
X xk−1 xn−k
= Bn−k .
(k − 1)! (n − k)!
n=1 k=1
Notice that for each value of n, as k goes from 1 to n the values k − 1 and n − k take on every
pair of non-negative integral values that add up to n. Thus, as n goes from 1 to infinity, the
values k − 1 and n − k take on every possible pair of non-negative integral values. Therefore,
we can rewrite this expression as
∞ X
"∞ #
d X xj xi
B(x) = Bi
dx j! i!
j=0 i=0
∞
"∞ #
X xj X xi
= Bi
j! i!
j=0 i=0
"
∞ ∞
#
X x j X x i
= Bi
j! i!
j=0 i=0
x
= e B(x).
x
Now, consider the derivative of e−(e ) B(x). By the product and chain rules, this is
x x
e−(e ) ex B(x) − B(x)e−(e ) ex = 0,
x x x
so it must be the case that e−(e ) B(x) is constant, say e−(e ) B(x) = c. Then B(x) = ce(e ) .
Since
∞ ∞
X 0n X
B(0) = Bn =1+ 0 = 1,
n!
n=0 n=1
(recall that 00 = 0, or if you don’t like that, simply use the expansion of B(0)), we see that
0
cee = ce1 = ce = 1,
so c = e−1 . Hence
x x
B(x) = e−1 e(e ) = e(e −1) .
There are techniques to extract coefficients from expressions like this, also, but we will not
cover these techniques in this class.
EXERCISES 9.11.
1) Find B4 .
2) What is the exponential generating function for the sequence ai = i! for every i ≥ 0?
Give the sequence in both an expanded and a closed form.
3) What is the exponential generating function for the sequence bi = (i + 1)!/2 for every
i ≥ 0? Give the sequence in both an expanded and a closed form.
72 9. Some Important Recursively-Defined Sequences
SUMMARY:
• generating functions must start with a 0th term
• Important definitions:
◦ derangements
◦ Catalan numbers
◦ exponential generating function
◦ Bell numbers
Chapter 10
Other Basic
Counting
Techniques
There are two other elementary techniques that are surprisingly useful even in quite difficult
counting problems. We will wrap up our exploration of enumeration by discussing these tech-
niques.
PROOF. Amongst the first m items, either two of the items are from the same category (so we
are done), or there is exactly one item from each of the m categories. Since n > m, there is at
least one more item. This item must fall into the same category as one of the previous items,
since every category already has an item.
73
74 10. Other Basic Counting Techniques
The name of this principle comes from the idea that it can be stated with the categories
being a row of holes, and the items being pigeons who are assigned to these holes.
In Example 10.1, the categories were the editions, and the items were the text books.
Example 10.1 was a very direct and straightforward application of the Pigeonhole Principle.
The Principle can also apply in much more subtle and surprising ways.
EXAMPLE 10.3. Maria makes a bet with Juan. He must buy her at least one chocolate bar
every day for the next 60 days. If, at the end of that time, she cannot point out a span of
consecutive days in which the number of chocolate bars he gave her was precisely 19, then she
will pay for all of the chocolate bars and give them back to him. If she can find such a span,
then she gets to keep the chocolate bars. To limit the size of the bet, they agree in advance
that Juan will not buy more than 100 chocolate bars in total.
Is there a way for Juan to win this bet?
SOLUTION. The answer is no. For 1 ≤ i ≤ 60, let ai represent the number of chocolate bars
that Juan has bought for Maria by the end of day i. Then 1 ≤ a1 < a2 < . . . < a60 ≤ 100.
Maria is hoping that for some i < j, she will be able to find that ai + 19 = aj . We therefore
also need to consider the values a1 + 19 < a2 + 19 < . . . < a60 + 19. By the bounds on a1 and
a60 , we have a1 + 19 ≥ 20, and a60 + 19 ≤ 119. Thus, the values a1 , . . . , a60 , a1 + 19, . . . , a60 + 19
are 120 numbers all of which lie between 1 and 119.
By the Pigeonhole Principle, at least two of these numbers must be equal, but we know
that the ai s are strictly increasing (as are the ai + 19s), so there must exist some i < j such
that ai + 19 = aj . Maria must point to the span of days from the start of day i + 1 to the end
of day j, since in this span Juan gave her 19 chocolate bars.
In fact, Juan could not win a bet of this nature that lasted more than 56 days, but proving
this requires more detailed analysis specific to the numbers involved, and is not really relevant
to this course.
Here is another example that would be hard to prove if you didn’t know the Pigeonhole
Principle.
EXAMPLE 10.4. Fix n, and colour each point of the plane with one of n colours. Prove that
there exists a rectangle whose four corners are the same colour.
So far we have only thought about guaranteeing that there are at least two items in some
category. Sometimes we might want to know that there are at least k items in some cate-
gory, where k > 2. There is a generalisation of the Pigeonhole Principle that applies to such
situations.
10. Other Basic Counting Techniques 75
PROPOSITION 10.5. Generalised Pigeonhole Principle Given n items that fall into m dif-
ferent categories, if n > km for some positive integer k, then at least k + 1 of the items must
fall into the same category.
PROOF. Amongst the first km items, either k + 1 of the items are from the same category (so
we are done), or there are exactly k items from each of the m categories. Since n > km, there
is at least one more item. This item must fall into the same category as one of the previous
items. Since every category already has k items, this means that there will be k + 1 items in
this category.
Notice that the Pigeonhole Principle is a special case of the Generalised Pigeonhole Princi-
ple, obtained by taking k = 1.
EXAMPLE 10.6. The population of West Lethbridge in the 2014 census was 35, 377.
Show that at least 97 residents of West Lethbridge share a birthday. If you live in West
Lethbridge, how many people can you be sure have the same birthday as you?
SOLUTION. For the first part of this question, we apply the generalised pigeonhole principle,
with m = 366 (for the 366 days of the year, counting February 29 since it is just as legitimate
a birthday as any other despite being more uncommon), k = 96, and n = 35, 377. We have
n = 35, 377 > km = 96 · 366 = 35, 136,
so the Generalised Pigeonhole Principle tells us that at least k + 1 = 97 people must share a
birthday.
For the second part of the question, the answer is 0. There is no reason why every single
other person in West Lethbridge might not have their birthday on the day after yours (although
that particular possibility is quite unlikely). There is certainly no guarantee that any of them
has the same birthday as yours.
Notice that although we have found in the above example that some group of at least 97
people in West Lethbridge must have the same birthday, we have no idea of which 97 people
are involved, or of what the joint birthday is. This is rather remarkable, but is an example of
a type of proof that is quite common in advanced mathematics. Such proofs are referred to as
“non-constructive,” since they prove that something exists, without giving you any idea of how
to find (or construct) such a thing.
The proof of following theorem involves a more subtle application of the Generalised Pi-
geonhole Principle.
THEOREM 10.7. Erdös-Szekeres Theorem For every pair of integers a, b ≥ 1, if S is a se-
quence of ab + 1 distinct real numbers, then there is either an increasing subsequence of length
a + 1 or a decreasing subsequence of length b + 1 in S.
PROOF. Define a function f that maps each element of S to the length of the longest increasing
subsequence that begins with that element.
If there exists some s ∈ S such that f (s) ≥ a + 1, then we are done. So we may assume
that f (s) ≤ a for every s ∈ S. Since there is always an increasing sequence of length at least
1 starting at any element of S, we in fact have 1 ≤ f (s) ≤ a for every s ∈ S, so there are
a possible values for the outputs of f . Since |S| = ab + 1, and ab + 1 > ab, the Generalised
Pigeonhole Principle tells us that at least b + 1 elements of S must have the same output under
the function f .
We claim that if x is before y in S and f (x) = f (y), then x > y. By assumption, x 6= y
(all values of S are distinct), so the only other possibility is x < y. If x < y, then taking x
followed by an increasing subsequence of length f (y) that starts at y, would give an increasing
76 10. Other Basic Counting Techniques
subsequence of length f (y) + 1 that starts at x, contradicting f (x) = f (y). This contradiction
shows that x < y is not possible, so x > y, as claimed.
Let s1 , s2 , . . . , sb+1 be elements of S that have the same output under f , and appear in this
order. Then by the claim we proved in the previous paragraph, s1 > s2 > . . . > sn+1 , which is
a decreasing subsequence of length b + 1.
In fact, ab + 1 is the smallest possible length for S that guarantees this property. For any
a, b, there is a sequence of length ab in which the longest increasing sequence has length a and
the longest decreasing subsequence has length b. One such sequence is
b, b − 1, . . . , 1; 2b, 2b − 1, . . . , b + 1; . . . ; ab, ab − 1, . . . , (a − 1)b + 1.
Any increasing subsequence can only have one entry from each of the a subsequences of length
b that are separated by semicolons, so can only have length a. Any decreasing subsequence
must be entirely contained within one of the subsequences of length b that are separated by
semicolons, so can only have length b.
PROPOSITION 10.8. Even more generalised pigeonhole principle Let n1 , n2 , . . . , nm be pos-
itive integers. Given at least
n1 + n2 + . . . + nm − m + 1
items that fall into m categories, there must be some 1 ≤ i ≤ m such that at least ni items fall
into the ith category.
Notice that the Generalised Pigeonhole Principle is a special case of the “Even more gen-
eralised pigeonhole principle,” obtained by taking
n1 = n2 = . . . = nm = k.
EXAMPLE 10.9. Suppose Ali owes Tomas $10, and wants to give him a number of identical
pieces of currency to pay her debt. Her bank only gives out currency in loonies, twonies, five-
dollar bills, or ten-dollar bills, and does not take requests for specific kinds of currency. How
much money must Ali request from the teller, if she wants to be sure to have $10 in identical
pieces of currency with which to pay Tomas?
SOLUTION. If Ali gets any $10 bills she can give one of those to Tomas and is done. If she
gets at least two $5 bills, she is done. If she gets at least five twonies, she is done, and if she
gets at least 10 loonies she is done. So the most money she can get without being able to give
Tomas his $10 in a single type of currency, is 9 loonies, 4 twonies, and a $5 bill, for a total of
$22. Therefore, if Ali asks for $23, she is guaranteed to be able to pay Tomas in a single type
of currency.
Although the above example does not directly use the “Even more generalised pigeonhole
principle” because it asks for the value of the currency Ali needs to request rather than the
number of items she must request, it uses the same ideas and should be helpful in understanding
the concept.
10. Other Basic Counting Techniques 77
EXERCISES 10.10.
is even. Is the same conclusion necessarily true if n is even or if a is odd? Give a proof
or a counterexamples in each case.
5) Let n ≥ 1, let x be a positive integer, and let S be a subset of cardinality n + 1 from
{x, x2 , . . . , x2n }. Prove that there exist two numbers in S whose product is x2n+1 .
6) Show that in every set of n + 1 distinct integers, there exist two elements a and b such
that a − b is divisible by n.
7) A drawer contains socks of 8 different colours. How many socks must you pull out of
the drawer to be certain that you have two of the same colour?
8) There are 15 students in a Combinatorics class. Explain how you know that two of
them have their birthday in the same month.
9) A pizza restaurant has 8 different toppings. Every day in October, they will put a
2-topping pizza on sale. Prove that the same pizza will be on sale on two different
days.
10) Suppose A is a set of 10 natural numbers between 1 and 100 (inclusive). Show that
two different subsets of A have the same sum. For example, if
then the subsets {6, 13, 45, 65} and {2, 30, 97} both add up to 129.
[Hint: Compare the answers to two questions: How many subsets of A are there? Since there
are only 10 elements of A, and each of them is at most 100, how many different possible sums
are there?]
11) Consider any set of 5 points in the plane that have integer coordinates. Prove that there
is some pair from these 5 points such that the midpoint of the line segment joining this
pair of points also has integer coordinates. Give an example of 4 points in the plane
that do not have this property, and list all of the midpoints as evidence.
78 10. Other Basic Counting Techniques
10B. Inclusion-Exclusion
In school, you probably saw Venn diagrams sometimes, showing groups that overlapped with
one another. We could draw a very basic Venn diagram showing the kinds of trees that are
growing at the various houses on my street:
Houses on my street
Looking at the Venn diagram can help us figure out the values of some of the pieces from
knowing the values of others. Suppose we know how many houses have deciduous trees, and
how many houses have evergreen trees. Naı̈vely, you might think that adding these together
would give us the total number of houses with trees. However, by looking at the Venn diagram,
we see that if we simply add the values together, then any houses that have both kinds of trees
have been counted twice (once as a house with a deciduous tree, and again as a house with an
evergreen tree). So in order to work out the number of houses that have trees, we can add the
number that have deciduous trees to the number that have evergreen trees and then subtract
the number that have both kinds of trees. This is the idea of “inclusion-exclusion.”
Specifically, if two sets A and B are disjoint, then |A ∪ B| = |A| + |B|. However, if A and B
are not disjoint, then |A| + |B| counts the elements of A ∩ B twice (both as elements of A and
as elements of B). Subtracting this overcount yields the correct answer:
PROPOSITION 10.11 (Inclusion-Exclusion for 2 sets). For any finite sets A and B, we have
|A ∪ B| = |A| + |B| − |A ∩ B|.
EXAMPLE 10.13. Every one of the 4000 students at Modern U owns either a tablet or a smart
watch (or both). Surveys show that:
• 3500 students own a tablet, and
• 1000 students own a smart watch.
How many students own both a tablet and a smart watch?
SOLUTION. Let
• S be the set of all students at Modern U ,
• T be the set of students who own a tablet, and
• W be the set of students who own a smart watch.
Then, by assumption,
|S| = 4000, |T | = 3500, |W | = 1000.
Since every student owns either a tablet or a smart watch, we have S = T ∪ W . Therefore,
Inclusion-Exclusion tells us that
|S| = |T ∪ W | = |T | + |W | − |T ∩ W |,
so
|T ∩ W | = |T | + |W | − |S| = 3500 + 1000 − 4000 = 500.
Hence, there are exactly 500 students who own both a tablet and a smart watch.
The following exercise provides a formula for the union of three sets A, B, and C. The idea
is that A ∩ B, A ∩ C and B ∩ C have all been overcounted. However, subtracting all of these
will overcompensate, because the elements of A ∩ B ∩ C have been subtracted too many times,
so they need to be added back in.
EXERCISE 10.14. Suppose A, B, and C are finite sets. Show
|A ∪ B ∪ C| = |A| + |B| + |C|
− |A ∩ B| − |A ∩ C| − |B ∩ C|
+ |A ∩ B ∩ C|.
[Hint: We have formulas for |(A ∪ B) ∪ C| and |A ∪ B|. The equality (A ∪ B) ∩ C = (A ∩ C) ∪ (B ∩ C)
provides another useful formula.]
The following general formula calculates the cardinality of the union of any number of sets,
by adding or subtracting the cardinality of every possible intersection of the sets. It is called the
Inclusion-Exclusion formula, because it works by adding (or “including”) the cardinalities of
certain sets, and subtracting (or “excluding”) the cardinalities of certain other sets.
THEOREM 10.15. Inclusion-Exclusion Let A1 , . . . , An be finite sets. Then
n
!
X X
|Ai ∩ Aj | + . . . + (−1)n+1 |A1 ∩ . . . ∩ An | .
|A1 ∪ . . . ∪ An | = |Ai | −
i=1 1≤i<j≤n
Of course, we can figure out the value of any one of the terms in the inclusion-exclusion
formula, if we know the values of all of the other terms.
80 10. Other Basic Counting Techniques
EXAMPLE 10.16. Sandy’s class is at Calaway Park. There are 21 students in the class. At
the end of the day, the teacher asks some questions and determines the following:
• every student rode at least one of the roller coaster, the train, the log ride, or the
bumper cars;
• 13 students rode the roller coaster;
• 6 students rode the train;
• 12 students rode the log ride;
• 15 students rode the bumper cars;
• 2 students rode all four of the rides; and
• 10 students rode at least 3 of these 4 rides.
How many students rode exactly two of the four rides?
SOLUTION. We begin by establishing some notation. Let A1 be the set of students who rode
the roller coaster; A2 will be the set of students who rode the train; A3 will be the set of
students who rode the log ride; and A4 will be the set of students who rode the bumper cars.
Ignoring the last piece of information for a moment, the rest of we have been given tells us
that:
• |A1 ∪ A2 ∪ A3 ∪ A4 | = 21;
• |A1 | = 13;
• |A2 | = 6;
• |A3 | = 12;
• |A4 | = 15; and
• |A1 ∩ A2 ∩ A3 ∩ A4 | = 2.
The last piece of information is a bit more tricky to encode. Observe that if we take
|A1 ∩ A2 ∩ A3 | + |A1 ∩ A2 ∩ A4 | + |A1 ∩ A3 ∩ A4 | + |A2 ∩ A3 ∩ A4 |, using ideas similar to inclusion-
exclusion (or drawing the Venn diagram) we see that we have found the number of students
who rode at least 3 of the 4 rides, except that we have counted the number of students who
rode all 4 rides in each of the four summands, instead of counting it only once. So we need to
subtract |A1 ∩ A2 ∩ A3 ∩ A4 | off three times to get the number of students who rode at least 3
of the 4 rides. Since we know that |A1 ∩ A2 ∩ A3 ∩ A4 | = 2, this tells us that
|A1 ∩ A2 ∩ A3 | + |A1 ∩ A2 ∩ A4 | + |A1 ∩ A3 ∩ A4 | + |A2 ∩ A3 ∩ A4 | − 6 = 10,
so
|A1 ∩ A2 ∩ A3 | + |A1 ∩ A2 ∩ A4 | + |A1 ∩ A3 ∩ A4 | + |A2 ∩ A3 ∩ A4 | = 16.
Thus, the inclusion-exclusion formula tells us that
X
21 = (13 + 6 + 12 + 15) − |Ai ∩ Aj | + 16 − 2,
1≤i<j≤4
P
so 1≤i<j≤4 |Ai ∩ Aj | = 39. Unfortunately, this still isn’t quite what we’re looking for. The
value we want is the number of students who rode exactly two of the four rides. Again, similar
reasoning shows that the number of students who rode the roller coaster and the train but
neither of the other two rides, will be given by:
|A1 ∩ A2 | − |A1 ∩ A2 ∩ A3 | − |A1 ∩ A2 ∩ A4 | + |A1 ∩ A2 ∩ A3 ∩ A4 |.
10. Other Basic Counting Techniques 81
Similar formulas can be worked out for each of the other five pairs that can be formed from the
four rides. What we have been asked for, is the sum of these six formulas. This works out to
X X
|Ai ∩ Aj | − 3 |Ai ∩ Aj ∩ Ak | + 6|A1 ∩ A2 ∩ A3 ∩ A4 | = 39 − 3(16) + 6(2) = 3.
1≤i<j≤4 1≤i<j<k≤4
Only three of the students rode exactly two of the four rides.
This was a very complicated example. You should not expect to have to work out examples
that are quite so tricky, but this gives you an idea of the power of inclusion-exclusion. Here is
a more straightforward application.
EXAMPLE 10.17. In the Faculty of Arts and Science, the voting method used is “approval;”
that is, regardless of the number of positions available, each voter can mark as many boxes as
they wish on their ballot.
Imagine that Prof. Li, Prof. Cheng, and Prof. Osborn were all nominated for two computer
science positions on the department’s search committee. Barb Hodgson notes the following facts
when counting the ballots:
• Prof. Cheng received 18 votes; Prof. Osborn received 15 votes, and Prof. Li received
10 votes.
• Only one ballot had all three boxes marked.
• Five of the ballots were marked for both Prof. Osborn and Prof. Li.
• Ten of the ballots were marked for Prof. Cheng and Prof. Osborn.
• Six of the ballots were marked for Prof. Cheng and Prof. Li.
How many members of the department voted in the election?
SOLUTION. Again, we begin by establishing some notation. Let C be the set of ballots that
were marked for Prof. Cheng; let O be the set of ballots that were marked for Prof. Osborn;
and let L be the set of ballots that were marked for Prof. Li. Then what we want is |C ∪ O ∪ L|:
the number of ballots that were marked for at least one of the three candidates; this is the same
as the number of people who voted.
Inclusion-Exclusion tells us that
We have been given all of the values on the right-hand side of this equation, so we see that
|C ∪ O ∪ L| = 18 + 15 + 10 − 10 − 6 − 5 + 1 = 23.
Department members
C O
3 9 1
1
5 4
The 9 people who voted for Prof. Cheng and Prof. Osborn but not Prof. Li is determined
from the fact that 10 people voted for Professors Cheng and Osborn, and only one of those
voted for all three professors. Similarly, the 4 people who voted for Prof. Li and Prof. Osborn
but not Prof. Cheng is determined from the fact that 5 people voted for Professors Li and
Osborn, and only one of those voted for all three professors; also, the 5 people who voted for
Prof. Cheng and Prof. Li but not Prof. Osborn is determined from the fact that 6 people voted
for Professors Cheng and Li, and only one of those voted for all three professors.
From the above deductions, we see that of the 18 votes Prof. Cheng received, one ballot
was marked for all 3 candidates; 9 were marked for Professors Cheng and Osborn (but not
Li); and 5 were marked for Professors Cheng and Li (but not Osborn). The remaining 3 votes
must have been for Prof. Cheng alone, allowing us to fill in that spot. Similarly, of the 15
votes Prof. Osborn received, one ballot was marked for all 3 candidates; 9 were marked for
Professors Cheng and Osborn (but not Li); and 4 were marked for Professors Osborn and Li
(but not Cheng). The remaining vote must have been for Prof. Osborn alone, allowing us to
fill in that spot. Finally, all of Prof. Li’s 10 votes are accounted for between the 5 who voted
for Professors Cheng and Li (but not Osborn), the 4 who voted for Professors Li and Osborn
(but not Cheng) and the one who voted for all three, so we put a 0 into the final spot.
EXERCISES 10.18.
1) Of 15 students in a stats class, 8 are math majors, 6 are CS majors, and 7 are in
education. None are in all three, and none have any other majors. There are two
math/CS joint majors, and 3 CS majors who are in education. How many math majors
are in education? How many of the math majors are not in either CS or education?
2) Kevin has 165 apps on his phone. Every one of these that is not a game and was not
free, requires internet access. Of these, 78 were free. Internet access is necessary for
124 of the apps to function fully. Of the apps on his phone, 101 are games. Kevin has
62 games on his phone that require internet access; 48 of these were free. Out of all
10. Other Basic Counting Techniques 83
of the games on his phone, 58 were free. How many of the free apps on Kevin’s phone
that aren’t games, require internet access?
3) How many integers between 1 and 60 are divisible by at least one of 2, 3, and 5?
4) In the 403 area code, how many of the 10-digit possible phone numbers (where any
combination of digits is allowed) contain at least one of each odd digit?
5) Assume |U | = 15, |V | = 12, and |U ∩ V | = 4. Find |U ∪ V |.
6) Assume |R| = 13, |S| = 17, and |R ∪ S| = 25. Find |R ∩ S|.
7) Assume |J| = 300, |J ∪ L| = 500, and |J ∩ L| = 150. Find |L|.
8) At a small university, there are 90 students that are taking either Calculus or Linear
Algebra (or both). If the Calculus class has 70 students, and the Linear Algebra class
has 35 students, then how many students are taking both Calculus and Linear Algebra?
9) How many numbers from 1 to 5000 are divisible by either 3 or 17?
10) How many 12-digit numbers (in which the first digit is not 0) have either no 0 or no 5?
SUMMARY:
• Pigeonhole Principle
• Generalised Pigeonhole Principle
• Even more generalised pigeonhole principle
• Inclusion-Exclusion
Part II
Graph Theory
Chapter 11
Basics of Graph
Theory
11A. Background
In combinatorics, what we call a graph has nothing to do with the x and y axes, and plotting.
Here, a graph is the most straightforward way you could think of to model a network. A
network could be a computer network, a road network, a telephone network; it doesn’t matter
what kind of network it is. Conceptually, any network consists of a bunch of things (let’s call
them nodes) that are being connected in some fashion. To model this, we draw some points for
the nodes, and we draw edges between nodes that have a direct connection.
Leonhard Euler laid the foundations of graph theory in 1735, with his solution to the
Königsberg bridge problem. Königsberg, Prussia (now Kaliningrad, Russia) was a city on the
river Pregel. The city included two islands in the river, as well as land on both sides of the
river, and there were seven bridges connecting the various parts of the city. The lay-out of the
city and its bridges looked something like this:
The question had been posed: is it possible for residents of Königsberg, out for Sunday
strolls, to cross each of the seven bridges exactly once? Better yet, can they do this and end
up in the same part of the city where they started?
Euler modeled the problem using a graph, with a vertex for each part of the city (one for
each bank, and one for each island), and edges representing the bridges. His model looked like
this:
86
11. Basics of Graph Theory 87
B D
C
The nodes A and C represent the two banks of the river, while B and D represent the
islands. In the model, the question becomes can we trace all of the edges of this graph, without
lifting our pen from the paper or going over an edge more than once?
Euler was actually able to find an easy method you can use on any graph, to quickly work
out whether or not this can be done for that graph. Also, unlike what we saw in the Pigeonhole
Principle, his method is constructive: if it can be done, his method shows you how to do it.
We’ll go over this method later, in Chapter 13.
a b c
For most of the graph theory we cover in this course, we will only consider simple graphs.
However, there are some results for which the proof is identical whether or not the graph is
simple, and other results that actually become easier to prove if we allow multigraphs and/or
loops, than if we only allow simple graphs. It is worthwhile and sometimes important to think
about which of our results apply to multigraphs (and/or graphs with loops), and which do
not. From this point on, unless otherwise specified, you should assume that any time the word
“graph” is used, it means a simple graph. However, be aware that many of our definitions and
results generalise to multigraphs and to graphs or multigraphs with loops, even where we don’t
specify this.
There is still more basic terminology that we need to establish before we can say much
about a graph.
DEFINITION 11.4. If e = {u, v} is an edge of a graph (or a multigraph, with or without loops),
then we say that u and v are endvertices (singular: endvertex) of e. We say that e is incident
with u and v (or vice versa, the vertices are also incident with the edge), and that u and v are
adjacent since there is an edge joining them, or that u is a neighbour of v.
NOTATION 11.5. We use the notation u ∼ v to denote that u is adjacent to v. We may also
denote the edge e = {u, v} by uv or by vu.
After one more definition, we will go through some examples using the terminology we have
established.
DEFINITION 11.6. If v ∈ V is a vertex of a graph (simple or multi, with or without loops),
then the number of times v appears as the endvertex of some edge is called the valency of v
in G. (Many sources use degree rather than valency, but the word degree has many meanings
in mathematics, making valency a preferable term for this.) A vertex of valency 0 is called a
isolated vertex.
Remark 11.7. In a graph without loops, we can define the valency of any vertex v as the number
of edges incident with v. For most purposes, this is a good way to think of the valency. However,
when a graph has loops, many formulas work out more nicely if we consider each loop to
contribute 2 to the valency of its endvertex. This fits the definition we have given, since a
vertex v appears twice as the endvertex of any loop incident with v.
The vertex a is adjacent to A, B and C. The vertex C is not adjacent to B. The edge
{a, C} is incident with the vertex a; the vertex C is also an endvertex of this edge. Every vertex
in this graph has valency 3, so none of the vertices is isolated. This is a simple graph, as it has
no loops or multiple edges.
Although a diagram is a convenient and often helpful way to visualise a graph, it is important
to note that because a graph is defined by the sets V and E, it is often possible to draw a
particular graph in ways that look quite different. Despite the different-looking drawings, as
long as V and E are the same, the graph is also the same. In Figure 11.3, we see two different
drawings of the graph given by V = {a, b, c, d} and
E = {{a, b}, {a, c}, {a, d}, {b, c}, {b, d}, {c, d}}.
d c c b
EXAMPLE 11.10. Let the graph G be defined by V = {w, x, y, z} and E = {e1 , e2 }, where
e1 = {w, x} and e2 = {w, y}. There are no loops or multiple edges, so G is a simple graph. The
edge e2 has endvertices w and y. The vertex w is incident with both e1 and e2 . The vertices x
and y are not adjacent. The vertex z is an isolated vertex, as it has no neighbours. The vertex
y has only one neighbour, w. The valency of w is 2. The valency of x and the valency of y are
both 1. In verifying all of these statements, drawing a diagram of the graph might help you.
EXERCISES 11.11. For each of the following graphs (which may or may not be simple, and
may or may not have loops), find the valency of each vertex. Determine whether or not the
graph is simple, and if there is any isolated vertex. List the neighbours of a, and all edges with
which a is incident.
1) Let G be defined by V = {a, b, c, d, e} and E = {e1 , e2 , e3 , e4 , e5 , e6 } with e1 = {a, c},
e2 = {b, d}, e3 = {c, d}, e4 = {c, e}, e5 = {d, e}, and e6 = {e, e}.
2) Let G be defined by V = {a, b, c} and E = {e1 , e2 , e3 } with e1 = {a, b}, e2 = {a, c},
and e3 = {a, c}.
3) Let G be defined by V = {a, b, c, d} and E = {e1 , e2 , e3 } with e1 = {a, b}, e2 = {a, c},
and e3 = {b, c}.
EXERCISES 11.12.
1) Let G be the graph whose vertices are the 2-element subsets of {1, 2, 3, 4, 5}, with
vertices {a, b} and {c, d} adjacent if and only if {a, b} ∩ {c, d} = ∅. Draw G.
2) The number of edges in the k-dimensional cube Qk (which is an important structure in
network design, but you do not need to know the structure to solve this) can be found
by the recurrence relation:
e(Q0 ) = 0; e(Qn ) = 2e(Qn−1 ) + 2n−1 for n ≥ 1.
Use generating functions to solve this recurrence relation and therefore determine the
number of edges in the k-dimensional cube.
90 11. Basics of Graph Theory
NOTATION 11.14. The graph obtained by deleting the vertex v from G is denoted by G \ {v}.
We can delete more than one vertex; for any set S ⊆ V of vertices of G, we use G \ S to denote
the graph obtained by deleting all of the vertices of S from G.
The graph G \ {v} might be a multigraph, but only if G is. It could have loops, but only if
G has loops.
If we begin with the graph
A B C
a b c
and delete the vertex D, then we obtain the graph shown in Figure 11.2.
We can also delete edges, rather than vertices.
DEFINITION 11.15. Start with a graph (or multigraph, with or without loops) G with vertex
set V and edge set E, and some edge e ∈ E. If we delete the edge e from the graph G, the
resulting graph has vertex set V and edge set E \ {e}.
NOTATION 11.16. The graph obtained by deleting the edge e from G is denoted by G \ {e}.
We can delete more than one edge; for any set T ⊆ E of edges of G, we use G \ T to denote
the graph obtained by deleting all of the edges of T from G.
The graph G \ {e} might be a multigraph, but only if G is. It could have loops, but only if
G has loops.
Notice that deleting the edges {C, D}, {a, D} and {c, D} from the graph drawn above, does
not result in the graph shown in Figure 11.2, because the graph we obtain by deleting these
edges still has the vertex D (as an isolated vertex), whereas the graph shown in Figure 11.2 has
only the six vertices {a, b, c, A, B, C}.
Vertex and edge deletion will be very useful for using proofs by induction on graphs (and
multigraphs, with or without loops). It is handy to have terminology for a graph that can be
obtained from another graph by deleting vertices and/or edges.
DEFINITION 11.17. Let G be a graph. If H can be obtained from G by deleting vertices
and/or edges, then H is a subgraph of G. A subgraph H of G is proper if H 6= G.
We now define a very important family of graphs, called complete graphs.
DEFINITION 11.18. A (simple) graph in which every vertex is adjacent to every other vertex,
is called a complete graph. If this graph has n vertices, then it is denoted by Kn .
11. Basics of Graph Theory 91
The notation Kn for a complete graph on n vertices comes from the name of Kazimierz
Kuratowski, a Polish mathematician who lived from 1896–1980. Although his main area of
research was logic, Kuratowski proved an important theorem that involves a complete graph.
We’ll study his theorem later in the course.
With this set-up, we are ready to prove our first result about graphs.
PROPOSITION 11.19. The number of edges of Kn is n(n−1) = n2 .
2
We present two proofs of this proposition: first, a combinatorial proof; then, a proof by
induction.
COMBINATORIAL PROOF. A complete graph has an edge between any pair of vertices. From
n
n vertices, there are
2 pairs that must be connected by an edge for the graph to be complete.
n
Thus, there are 2 edges in Kn .
Before giving the proof by induction, let’s show a few of the small complete graphs. In
particular, we’ll need to have K1 in mind as it will be the base case for our induction.
K1
K2 K3 K4 K5
PROOF BY INDUCTION. Base case: n = 1. As we can see above, the graph K1 has 0 edges.
Also,
n(n − 1)/2 = 1(0)/2 = 0.
So the equality holds for n = 1. This completes the proof of the base case.
We begin with the inductive hypothesis. Let k ≥ 1 be arbitrary, and suppose
Inductive step:
that Kk has k2 edges.
We want to deduce that Kk+1 has k+1
2 edges. Start with Kk+1 , and let the number of
edges of this graph be t. Now we delete a vertex v from Kk+1 . By the definition of vertex
deletion, we must delete every edge incident with v. Since Kk+1 is complete, v is adjacent to
every other vertex, so there are k edges incident with v, and it is precisely these edges that we
have deleted. There must be t − k edges remaining.
Notice that deleting v does not affect edges that are not incident with v. Therefore, if we
consider any two vertices in the remaining graph, they will still be adjacent (since they were
adjacent in Kk+1 and the edge between them was not deleted). Thus, the remaining graph is
Kk .
Using our inductive hypothesis, we know that Kk has k(k − 1)/2 edges. We have shown
that t − k = k(k − 1)/2, so
k(k − 1) k − 1) k(k + 1) k+1
t= +k =k +1 = = ,
2 2 2 2
which is what we wanted to deduce. This completes the proof
of the inductive step.
n
By the Principle of Mathematical Induction, Kn has 2 vertices for every n ≥ 1.
Although this proof by induction may seem ridiculously long and complicated in comparison
with the combinatorial proof, it serves as a relatively simple illustration of how proofs by
induction can work on graphs. This can be a very powerful technique for proving results about
graphs.
92 11. Basics of Graph Theory
Here is another result that can be proven using either a combinatorial proof, or a proof by
induction.
LEMMA 11.20. Euler’s handshaking lemma For any graph (or multigraph, with or without
loops)
X
d(v) = 2|E|.
v∈V
This is called the handshaking lemma because it is often explained using vertices to represent
people, and edges as handshakes between people. In this explanation, the lemma says that if you
add up all of the hands shaken by all of the people, you will get twice the number of handshakes
that took place. This is an example of using two ways to count pairs (v, e) ∈ V × E such that v
is incident with e, a notion that we discussed briefly when we introduced combinatorial proofs.
COMBINATORIAL PROOF. For the left-hand side of the equation, at every vertex we count
the number of edges incident with that vertex. To get the right-hand side from this, observe
that this process results in every edge having been counted exactly twice (once at each of its two
endvertices; or, in the case of a loop, twice at its single endvertex since both ends are there).
Although from the right perspective the handshaking lemma might seem obvious, it has a
very important and useful corollary.
COROLLARY 11.21. Every graph has an even number of vertices of odd valency.
PROOF. Since the sum of all of the valencies in the graph is even (by Euler’s handshaking
lemma, Lemma 11.20), the number of odd summands in this sum must be even. That is, the
number of vertices that have odd valency must be even.
EXERCISES 11.22.
1) Give a proof by induction of Euler’s handshaking lemma for simple graphs.
2) Draw K7 .
3) Show that there is a way of deleting an edge and a vertex from K7 (in that order) so
that the resulting graph is complete. Show that there is a way of deleting an edge and
a vertex from K7 (in that order) so that the resulting graph is not complete.
4) Prove Corollary 11.21 by induction on the number of edges. (Use edge deletion, and
remember that the base case needs to be when there are no edges.)
5) Use graphs to give a combinatorial proof that
k
X ni n
≤ ,
2 2
i=1
Pk
where n1 , n2 , . . . , nk are positive integers with i=1 ni = n. Under what circumstances
does equality hold?
b B
a A
G H
Which of these graphs is K2 ? They can’t both be K2 since they aren’t the same graph –
can they?
The answer lies in the concept of isomorphisms. Intuitively, graphs are isomorphic if they
are identical except for the labels (on the vertices). Recall that as shown in Figure 11.3, since
graphs are defined by the sets of vertices and edges rather than by the diagrams, two isomorphic
graphs might be drawn so as to look quite different.
DEFINITION 11.23. Two graphs G1 = (V1 , E1 ) and G2 = (V2 , E2 ) are isomorphic if there is a
bijection (a one-to-one, onto map) ϕ from V1 to V2 such that
{v, w} ∈ E1 ⇔ {ϕ(v), ϕ(w)} ∈ E2 .
In this case, we call ϕ an isomorphism from G1 to G2 .
so G1 ∼
= G3 .
The answer to our question about complete graphs is that any two complete graphs on n
vertices are isomorphic, so even though technically the set of all complete graphs on 2 vertices
is an equivalence class of the set of all graphs, we can ignore the labels and give the name K2
to all of the graphs in this class.
a y
e b w v
d c z x
G H
PROPOSITION 11.26. If G1 ∼
= G2 are graphs, then
1) G1 and G2 have the same number of vertices;
2) G1 and G2 have the same number of edges;
11. Basics of Graph Theory 95
3) if we list the valency of every vertex of G1 and do the same for G2 , the lists will be the
same (though possibly in a different order). (Such a list is called the degree sequence
of the graph.)
PROOF.
1) Since G1 ∼
= G2 , there is an isomorphism ϕ : V1 → V2 (where V1 is the vertex set of G1
and V2 is the vertex set of G2 ). Since ϕ is a bijection, we must have |V1 | = |V2 |.
2) Since
{v, w} ∈ E1 ⇒ {ϕ(v), ϕ(w)} ∈ E2 ,
we see that for every edge of E1 , there is an edge of E2 . Therefore, |E2 | ≥ |E1 |.
Similarly, since
{ϕ(v), ϕ(w)} ∈ E2 ⇒ {v, w} ∈ E1 ,
we see that |E1 | ≥ |E2 |. So |E1 | = |E2 |.
3) If ϕ(v1 ) = v2 then dG1 (v1 ) = dG2 (v2 ), because u ∼ v1 if and only if ϕ(u) ∼ v2 .
EXAMPLE 11.27. The graph G of Example 11.25 is not isomorphic to K5 , because K5 has
5
2 = 10 edges by Proposition 11.19, but G has only 5 edges. Notice that the number of
vertices, despite being a graph invariant, does not distinguish these two graphs.
The graphs G and H:
a b u v
f c z w
e d y x
G H
are not isomorphic. Each of them has 6 vertices and 9 edges. However, the graph G has two
vertices of valency 2 (a and c), two vertices of valency 3 (d and e), and two vertices of valency
4 (b and f ). Meanwhile, the graph H has one vertex of valency 2 (w), four vertices of valency
3 (u, x, y, and z), and one vertex of valency 4 (v). Although each of these lists has the same
values (2s, 3s, and 4s), the lists are not the same since the number of entries that contain
each of the values is different. In particular, the two vertices a and c both have valency 2, but
there is only one vertex of H (vertex w) of valency two. Either a or c could be sent to w by
an isomorphism, but either choice leaves no possible image for the other vertex of valency 2.
Therefore, an isomorphism between these graphs is not possible.
Observe that the two graphs
a b u v
f c z w
e d y x
both have 6 vertices and 7 edges, and each has four vertices of valency 2 and two vertices of
valency 3. Nonetheless, these graphs are not isomorphic. Perhaps you can think of another
graph invariant that is not the same for these two graphs.
To prove that these graphs are not isomorphic, since each has two vertices of valency 3,
any isomorphism would have to map {c, f } to {v, z}. Now, whichever vertex gets mapped to u
must be a mutual neighbour of c and f since u is a mutual neighbour of v and z. But c and f
96 11. Basics of Graph Theory
have no mutual neighbours, so this is not possible. Therefore there is no isomorphism between
these graphs.
A natural problem to consider is: how many different graphs are there on n vertices? If
we are not worrying about whether or not the graphs are isomorphic, we could have infinitely
many graphs just by changing the labels on the vertices, and that’s not very interesting. To
avoid this problem, we fix the set of labels that we use. Label the vertices with the elements of
{1, . . . , n}. We’ll call the number of graphs we find, thenumber of labeled graphs on n vertices.
Any edge is a 2-subset of {1, . . . , n}. There are n2 possible edges in total. Any graph is
formed by taking a subset of the n(n − 1)/2 possible edges. In Example 4.1, we learned how to
count these: there are 2n(n−1)/2 subsets.
EXAMPLE 11.28. When n = 1, we have 12 = 0, and 20 = 1, so there is exactly one labeled
graph on 1 vertex. It looks like this:
1
2
When n = 2, we have 2 = 1, and 21 = 2. so there are exactly two labeled graphs on 2
vertices. They look like this:
1 1
2 2
3
When n = 3, we have 2 = 3, and 23 = 8, so there are exactly eight labeled graphs on 3
vertices. They look like this:
1 1 1 1 1 1 1 1
2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3
4
When n = 4, we have 2 = 6, and 26 = 64, so there are exactly sixty-four labeled graphs
on 4 vertices. We won’t attempt to draw them all here.
Although that answer is true as far as it goes, you will no doubt observe that even though
we are using a fixed set of labels, some of the graphs we’ve counted are isomorphic to others.
A more interesting question would be, how many isomorphism classes of graphs are there on
n vertices? Since we are considering isomorphism classes, the labels we choose for the vertices
are largely irrelevant except to tell us which vertices are connected to which other vertices, if
we don’t have a diagram. Thus, if we are drawing the graphs, we usually omit vertex labels
and refer to the resulting graphs (each of which represents an isomorphism class) as unlabeled.
So the question is, how many unlabeled graphs are there on n vertices?
We can work out the answer to this for small values of n. From the labeled graphs on 3
vertices, you can see that there are four unlabeled graphs on 3 vertices. These are:
There are 11 unlabeled graphs on four vertices. Unfortunately, since there is no known
polynomial-time algorithm for solving the graph isomorphism problem, determining the number
of unlabeled graphs on n vertices gets very hard as n gets large, and no general formula is known.
11. Basics of Graph Theory 97
EXERCISES 11.29. For each of the following pairs of graphs, find an isomorphism or prove
that the graphs are not isomorphic.
1) a w
e b x v
d c y z
G H
2)
a w
e b x v
d c y z
G H
3) G1 = (V1 , E1 ) and G2 = (V2 , E2 ) with V1 = {a, b, c, d}, V2 = {A, B, C, D}, E1 =
{ab, ac, ad}, E2 = {BC, CD, BD}.
EXERCISES 11.30.
1) Draw five unlabeled graphs on 5 vertices that are not isomorphic to each other.
2) How many labeled graphs on 5 vertices have 1 edge?
3) How many labeled graphs on 5 vertices have 3 or 4 edges?
98 11. Basics of Graph Theory
SUMMARY:
• graphs are defined by sets, not by diagrams
• deleting a vertex or edge
• how to use proofs by induction on graphs
• Euler’s handshaking lemma
• graph invariants, distinguishing between graphs
• labeled and unlabeled graphs
• Important definitions:
◦ graph, vertex, edge
◦ loop, multiple edge, multigraph, simple graph
◦ endvertex, incident, adjacent, neighbour
◦ degree, valency, isolated vertex
◦ subgraph
◦ complete graph
◦ isomorphic graphs, isomorphism between graphs
• Notation:
◦u∼v
◦ uv
◦ val(v), deg(v), d(v), dG (v)
◦ G \ {v}, G \ {e}
◦ Kn
◦ G1 ∼
= G2
Chapter 12
Moving through
graphs
We have some basic concepts and terminology now, but it is important to remember that graphs
are models of networks. Networks are all about moving things around, whether those things
are cars, data, or whatever. So if graphs are going to be useful models, routes in the network
need to correspond to routes in the graph, and we need to be able to describe these routes, and
to learn about them.
We will give one example of generalising a result on graphs, to the context of digraphs. In
order to do so, we need a definition.
DEFINITION 12.3. The outvalency or outdegree of a vertex v in a digraph is the number of
arcs whose first entry is v, i.e.,
|{w ∈ V | (v, w) ∈ A}|.
99
100 12. Moving through graphs
The invalency or indegree of a vertex v in a digraph is the number of arcs whose second entry
is v.
NOTATION 12.4. The outvalency of vertex v is denoted by d+ (v). The invalency of vertex v
is denoted by d− (v).
LEMMA 12.5. Euler’s handshaking lemma for digraphs. For any digraph,
X X
d+ (v) = d− (v) = |A|.
v∈V v∈V
COMBINATORIAL PROOF. For the left-hand side of the equation, at every vertex we count
the number of arcs that begin at that vertex. Since each of these arcs ends at some vertex,
we get the same result in the middle part of the equation, where at every vertex we count the
number of arcs that end at that vertex. In each case, we have counted every arc precisely once,
so both of these values are equal to the right-hand side of the equation, the number of arcs in
the digraph.
EXERCISES 12.6.
1) Use induction to prove Euler’s handshaking lemma for digraphs that have no loops
(arcs of the form (v, v) or multiarcs (more than one arc from some vertex u to some
other vertex v).
2) A digraph isomorphism is a bijection on the vertices that preserves the arcs. Come up
with a digraph invariant, and prove that it is an invariant.
3) List the indegree and outdegree of each vertex of the digraph from Example 12.2.
This definition of connected component seems to depend significantly on the choice of the
vertex u. In fact, though, being in the same connected component of G is an equivalence relation
on the vertices of G, so the connected components of G are a property of G itself, rather than
depending on particular choices of vertices. We won’t go through a formal proof that being in
the same connected component is an equivalence relation (we leave this as an exercise below),
but we will go through the proof of a proposition that is closely related.
PROPOSITION 12.9. Let G be a graph, and let u, v, w ∈ V (G). Suppose that v and w are in
the connected component of G that contains the vertex u. Then w is in the connected component
of G that contains the vertex v.
PROOF. Since v and w are in the connected component of G that contains the vertex u, by
definition there is a u − v walk, and a u − w walk. Let (u = u1 , u2 , . . . , uk = w) be a u − w
walk, and let (u = v1 , v2 , . . . , vm = v) be a u − v walk.
We need to show that w is in the connected component of G that contains the vertex v; by
definition, this is equivalent to showing that there is a v − w walk. Consider the sequence of
vertices:
(v = vm , vm−1 , . . . , v1 = u = u1 , u2 , . . . , uk = w).
Since (u = v1 , v2 , . . . , vm = v) is a u − v walk, consecutive vertices are adjacent, so consecutive
vertices in the first part of the given sequence (from vm through v1 = u) are adjacent. Similarly,
since (u = u1 , u2 , . . . , uk = w) is a u − w walk, consecutive vertices are adjacent, so consecutive
vertices in the last part of the given sequence (from u = u1 through uk ) are adjacent. Therefore,
the given sequence is in fact a v − w walk, as desired.
When discussing walks, it is convenient to have standard terminology for describing the
length of the walk.
DEFINITION 12.10. The length of a walk is one less than the number of vertices in the walk.
Thus, if we think of a walk as a sequence of edges (formed by consecutive pairs of vertices from
the walk), the length of the walk is the number of edges in the walk.
Unfortunately, there is some disagreement amongst mathematicians as to whether the length
of a walk should be used to mean the number of vertices in the walk, or the number of edges
in the walk. We will use the latter convention throughout this course because it is consistent
with the definition of the length of a cycle (which will be introduced in the next section). You
should be aware, though, that you might find the other convention used in other sources.
Sometimes it is obvious that a graph is disconnected from the way it has been drawn,
but sometimes it is less obvious. In the following example, you might not immediately notice
whether or not the graph is connected.
EXAMPLE 12.11. Consider the following graph.
a b
h c
g d
f e
Find a walk of length 4 from a to f . Find the connected component that contains a. Is the
graph connected?
102 12. Moving through graphs
SOLUTION. A walk from of length 4 from a to f is (a, c, a, c, f ). (Notice that the vertices
and edges used in a walk need not be distinct.) Remember that the length of this walk is the
number of edges used, which is one less than the number of vertices in the sequence!
The connected component that contains a is {a, c, e, f }. There are walks from a to each
of these vertices, but there are no edges between any of these vertices and any of the vertices
{b, d, g, h}.
Since there is no walk from a to b (for example), the graph is not connected.
EXERCISES 12.12.
1) Prove that being in the same connected component of G is an equivalence relation on
the vertices of any graph G.
2) Is the following graph connected? Find the connected component that contains a. Find
a walk of length 5 from a to f .
a b
j c
i d
h e
g f
3) Is the following graph connected? Find the connected component that contains a. Find
a walk of length 3 from a to d.
a b
j c
i d
h e
g f
NOTATION 12.14. For n ≥ 0, a graph on n + 1 vertices whose only edges are those used in
a path of length n (which is a walk of length n that is also a path) is denoted by Pn . (Notice
= K1 and P1 ∼
that P0 ∼ = K2 .)
Notice that if an edge were to appear more than once in a walk, then both of its endvertices
would also have to appear more than once, so a path does not allow vertices or edges to be
re-visited.
EXAMPLE 12.15. In the graph
a b c d
e f g h
(a, f, c, h) is a path of length 3. However, (a, f, c, h, d, f ) is not a path, even though no edges
are repeated, since the vertex f appears twice. Both are walks.
PROPOSITION 12.16. Suppose that u and v are in the same connected component of a graph.
Then any u − v walk of minimum length is a path. In particular, if there is a u − v walk, then
there is a u − v path.
PROOF. Since u and v are in the same connected component of a graph, there is a u − v walk.
Towards a contradiction, suppose that we have a u − v walk of minimum length that is not
a path. By the definition of a path, this means that some vertex x appears more than once in
the walk, so the walk looks like:
(u = u1 , . . . , ui = x, . . . , uj = x, . . . , uk = v),
and j > i. Observe that the following is also a u − v walk:
(u = u1 , . . . , ui = x, uj+1 , uj+2 , . . . , uk = v).
Since consecutive vertices were adjacent in the first sequence, they are also adjacent in the
second sequence, so the second sequence is a walk. The length of the first walk is k − 1, and
the length of the second walk is k − 1 − (j − i). Since j > i, the second walk is strictly shorter
than the first walk. In particular, the first walk was not a u − v walk of minimum length. This
contradiction serves to prove that every u − v walk of minimum length is a path.
This allows us to prove another interesting fact that will be useful later.
PROPOSITION 12.17. Deleting an edge from a connected graph can never result in a graph
that has more than two connected components.
PROOF. Let G be a connected graph, and let uv be an arbitrary edge of G. If G \ {uv} is
connected, then it has only one connected component, so it satisfies our desired conclusion.
Thus, we assume in the remainder of the proof that G \ {uv} is not connected.
Let Gu denote the connected component of G \ {uv} that contains the vertex u, and let Gv
denote the connected component of G \ {uv} that contains the vertex v. We aim to show that
Gu and Gv are the only connected components of G \ {uv}.
Let x be an arbitrary vertex of G, and suppose that x is a vertex that is not in Gu . Since
G is connected, there is a u − x walk in G, and therefore by Proposition 12.16 there is a u − x
path in G. Since x is not in Gu , this u − x path must use the edge u − v, so must start with this
edge since u only occurs at the start of the path. Therefore, by removing the vertex u from the
start of this path, we obtain a v − x path that does not use the vertex u. This path cannot use
the edge uv, so must still be a path in G \ {uv}. Therefore x is a vertex in Gv .
104 12. Moving through graphs
Since x was arbitrary, this shows that every vertex of G must be in one or the other of the
connected components Gu and Gv , so there are at most two connected components of G \ {uv}.
Since uv was an arbitrary edge of G and G was an arbitrary connected graph, this shows
that deleting any edge of a connected graph can never result in a graph with more than two
connected components.
A cycle is like a path, except that it starts and ends at the same vertex. The structures
that we will call cycles in this course, are sometimes referred to as circuits.
DEFINITION 12.18. A walk of length at least 1 in which no vertex appears more than once,
except that the first vertex is the same as the last, is called a cycle.
NOTATION 12.19. For n ≥ 3, a graph on n vertices whose only edges are those used in a cycle
of length n (which is a walk of length n that is also a cycle) is denoted by Cn .
The requirement that the walk have length at least 1 only serves to make it clear that a
walk of just one vertex is not considered a cycle. In fact, a cycle in a simple graph must have
length at least 3.
EXAMPLE 12.20. In the graph from Example 12.15, (a, e, f, a) is a cycle of length 3, and
(b, g, d, h, c, f, b) is a cycle of length 6.
Here are drawings of some small paths and cycles:
P0 P1 P2 P3 P4 P5 P6
C3 C4 C5 C6
We end this section with a proposition whose proof will be left as an exercise.
PROPOSITION 12.21. Suppose that G is a connected graph. If G has a cycle in which u and
v appear as consecutive vertices (so uv is an edge of G) then G \ {uv} is connected.
EXERCISES 12.22.
1) In the graph
a b c d
e f g h
12. Moving through graphs 105
12D. Trees
A special class of graphs that arise often in graph theory, is the class of trees. If a mathematician
suspects that something is true for all graphs, one of the first families of graphs for which s/he
will probably try to prove it, is the family of trees, because their strong structure makes them
much easier to work with than many other families of graphs.
DEFINITION 12.23. A tree is a connected graph that has no cycles.
A forest is a disjoint union of trees. So a forest is a graph that has no cycles (but need not
be connected).
A leaf is a vertex of valency 1 (in any graph, not just in a tree or forest).
Notice that the graph Pn is a tree, for every n ≥ 1.
We prove some important results about the structure of trees.
PROPOSITION 12.24. Let T be a connected graph with no cycles. Then deleting any edge
from T disconnects the graph.
PROOF. If T has no edges, the statement is vacuously true. We may thus assume that T has
at least one edge. Let {u, v} be an arbitrary edge of T . (Since a loop is a cycle, we must have
u 6= v even if we were not assuming that our graphs are simple.)
Towards a contradiction, suppose that deleting {u, v} from T does not disconnect T . Then
by the definition of a connected graph, there is a u − v walk in T \ {uv}. By Proposition 12.16,
the shortest u − v walk in T \ {uv} must be a u − v path. If we take this same walk in T and
add u to the end, this will still be a walk in T since T contains the edge uv. Since the walk
in T \ {uv} was a path, no vertices were repeated. Adding u to the end of this walk makes a
walk (certainly of length at least 2) in which no vertex is repeated except that the first and last
vertices are the same: by definition, a cycle. Thus, T has a cycle, contradicting our hypothesis.
This contradiction serves to prove that deleting any edge from T disconnects the graph.
Since a tree is a connected graph with no cycles, this shows that deleting any edge from a
tree will disconnect the graph.
PROPOSITION 12.25. Every tree that has at least one edge, has at least two leaves.
PROOF. We prove this by strong induction on the number of vertices. Notice that a (simple)
graph on one vertex must be K1 , which has no edges, so the proposition does not apply.
Therefore our base case will be when there are 2 vertices.
106 12. Moving through graphs
Base case: n = 2. Of the two (unlabeled) graphs on 2 vertices, only one is connected: K2
(or P1 ; these are isomorphic). Both of the vertices have valency 1, so there are two leaves. This
completes the proof of the base case.
Induction step: We begin with the strong inductive hypothesis. Let k ≥ 2 be arbitrary.
Suppose that for every 2 ≤ i ≤ k, every tree with i vertices has at least two leaves. (Since i ≥ 2
and a tree is a connected graph, every tree on i vertices has at least one edge, so we may omit
this part of the hypothesis.)
Let T be a tree with k + 1 vertices. Since k + 1 > 1, T has at least one edge. Choose any
edge {u, v} of T , and delete it. By Proposition 12.24, the resulting graph is disconnected. By
Proposition 12.17, it cannot have more than two connected components, so it must have exactly
two connected components. Furthermore, by the proof of that proposition, the components are
Tu (the connected component that contains the vertex u) and Tv (the connected component
that contains the vertex v).
Since T has no cycles, neither do Tu or Tv . Since they are connected components, they are
certainly connected. Therefore, both Tu and Tv are trees. Since u is not a vertex of Tv and v
is not a vertex of Tu , each of these trees has at most k vertices.
If both Tu and Tv have at least two vertices, then we can apply our induction hypothesis to
both. This tells us that Tu and Tv each have at least two leaves. In particular, Tu must have
some leaf x that is not u, and Tv must have some leaf y that is not v. Deleting uv from T did
not change the valency of either x or y, so x and y must also have valency 1 in T . Therefore T
has at least two leaves. This completes the induction step and therefore the proof, in the case
where Tu and Tv each have at least two vertices. We must still consider the possibility that at
least one of Tu and Tv has only one vertex.
Since k + 1 ≥ 3, at least one of Tu and Tv must have two vertices, so only one of them can
have only one vertex. Without loss of generality (since nothing in our argument so far made
any distinction between u and v, we can switch u and v if we need to), we may assume that Tv
has only one vertex, and Tu has at least two vertices. Applying our induction hypothesis to Tu ,
we conclude that Tu has some leaf x that is not u, and that is also a leaf of T . Furthermore,
since Tv has only one vertex, this means that deleting the edge uv left v as an isolated vertex,
so uv was the only edge incident with v in T . Therefore, v is a leaf of T . Thus, T has at least
two leaves: x and v. This completes the induction step and therefore the proof, in the case
where at least one of Tu and Tv has only one vertex. Since we have dealt with all possibilities,
this completes our induction step.
By the Principle of Mathematical Induction, every tree that has at least one edge, has at
least two leaves.
THEOREM 12.27. The following are equivalent for a graph T with n vertices:
1) T is a tree;
2) T is connected and has n − 1 edges;
3) T has no cycles, and has n − 1 edges;
4) T is connected, but deleting any edge leaves a disconnected graph.
PROOF. We will prove that the statements are equivalent by showing that 1 ⇒ 2 ⇒ 3 ⇒ 4 ⇒ 1.
Thus, by using a sequence of implications, we see that any one of the statements implies any
other.
12. Moving through graphs 107
(1 ⇒ 2) We assume that T is a tree, and we would like to deduce that T is connected and
has n − 1 edges. By the definition of a tree, T is connected. We will use induction on n to show
that T has n − 1 edges.
Base case: n = 1. There is only one (unlabeled) graph on one vertex, it is K1 , so T ∼ = K1 ,
which has no edges. Since 0 = n − 1, this completes the proof of the base case.
Inductive step: We begin with the inductive hypothesis. Let k ≥ 1 be arbitrary, and suppose
that every tree on k vertices has k − 1 edges.
Let T be an arbitrary tree with k + 1 vertices. Since k + 1 ≥ 2 and T is connected, T
must have at least one edge, so by Proposition 12.25, T has at least two leaves. Let v be a leaf
of T . By Proposition 12.26, T \ {v} is a tree. Also, T \ {v} has k vertices, so we can apply
our induction hypothesis to conclude that T \ {v} has k − 1 edges. Since v was a leaf, T has
precisely one more edge than T \ {v}, so T must have k = (k + 1) − 1 edges. This completes
our inductive step.
By the Principle of Mathematical Induction, every tree on n vertices has n − 1 edges.
(2 ⇒ 3) We assume that T is connected and has n − 1 edges. We need to deduce that T
has no cycles.
Towards a contradiction, suppose that T has a cycle. Repeatedly delete edges that are in
cycles until no cycles remain. By Proposition 12.21 (used repeatedly), the resulting graph is
connected, so by definition it is a tree. Since we have already proven that 1 ⇒ 2, this tree must
have n − 1 edges. Since we started with n − 1 edges and deleted at least one (based on our
assumption that T has at least one cycle), this is a contradiction. This contradiction serves to
prove that T must not have any cycles.
(3 ⇒ 4) We assume that T has no cycles, and has n − 1 edges. We must show that T is
connected, and that deleting any edge leaves a disconnected graph. We begin by showing that
T is connected; we prove this by induction on n.
Base case: n = 1. Then T ∼ = K1 is connected.
Inductive step: We begin with the inductive hypothesis. Let k ≥ 1 be arbitrary, and suppose
that every graph on k vertices that has k − 1 edges and no cycles, is connected.
Let T be an arbitrary graph with k + 1 vertices that has k edges and no cycles. By Euler’s
handshaking lemma,
X
d(v) = 2k.
v∈V
If each of the k + 1 vertices had valency 2 or more, then we would have
X
d(v) ≥ 2(k + 1)
v∈V
(this is a lot like the Pigeonhole Principle in concept, but the Pigeonhole Principle itself doesn’t
apply to this situation). Since 2k < 2(k + 1), there must be some vertex v that does not have
valency 2 or more. Delete v. In so doing, we delete at most 1 edge, since v has at most 1
incident edge. Thus, the resulting graph has k vertices and k or k − 1 edges, and since T has
no cycles, neither does T \ {v}.
If T \ {v} has k edges, then deleting any of the edges results in a graph on k vertices with no
cycles and k − 1 edges, which by our inductive hypothesis must be connected. Therefore T \ {v}
is a connected graph that remains connected after any edge is deleted. By Proposition 12.24 (in
the contrapositive), this means that T \ {v} must contain a cycle, but this is a contradiction.
This contradiction serves to prove that T \ {v} cannot have k edges.
Thus, T \ {v} has k − 1 edges and k vertices, and no cycles. By our inductive hypothesis,
T \ {v} must be connected. Furthermore, the fact that T \ {v} has k − 1 edges means that v is
incident to an edge, which must have its other endvertex in T \ {v}. Therefore T is connected.
This completes the inductive step.
108 12. Moving through graphs
By the Principle of Mathematical Induction, every graph on n vertices with no cycles and
n − 1 edges is connected.
It remains to be shown that deleting any edge leaves a disconnected graph, but now that
we know that T is connected, this follows from Proposition 12.24.
(4 ⇒ 1) We assume that T is connected, but deleting any edge leaves a disconnected graph.
By the definition of a tree, we must show that T has no cycles. This follows immediately from
Proposition 12.21.
EXERCISES 12.28.
1) Prove Proposition 12.26.
2) Draw a tree on 6 vertices.
3) There are two non-isomorphic trees on 4 vertices. Find them.
4) There are 11 non-isomorphic graphs on 4 vertices. Draw all 11, and under each one
indicate: is it connected? Is it a forest? Is it a tree?
[Hint: One has 0 edges, one has 1 edge, two have 2 edges, three have 3 edges, two have 4 edges,
one has 5 edges, and one has 6 edges.]
SUMMARY:
• many definitions and results about graphs can be generalised to the context of digraphs.
• Important definitions:
◦ digraph
◦ arc
◦ walk
◦ length of a walk
◦ connected
◦ connected component
◦ path, cycle
◦ tree, forest, leaf
• Notation:
◦ Pn
◦ Cn
Chapter 13
i d
h e
g f
a b c d
e f g h
Here is Euler’s method for finding Euler tours. We will state it for multigraphs, as that
makes the corresponding result about Euler trails a very easy corollary.
THEOREM 13.3. A connected graph (or multigraph, with or without loops) has an Euler tour
if and only if every vertex in the graph has even valency.
PROOF. As the statement is if and only if, we must prove both implications.
(⇒) Suppose we have a multigraph (possibly with loops) that has an Euler tour,
(u1 , u2 , . . . , ue+1 = u1 ),
where e = |E|. Let u be an arbitrary vertex of the multigraph. Every time u appears in the
tour, exactly two of the edges incident with u are used: if u = uj , then the edges used are
uj−1 uj and uj uj−1 unless j = 1 or j = e + 1 in which case u = u1 = ue+1 and the edges are
ue u and uu2 (and we consider this as one appearance of u in the tour). Therefore, if u appears
k times in the tour, then since by the definition of an Euler tour all edges incident with u are
used exactly once, we conclude that u must have valency 2k. Since u was an arbitrary vertex
of the multigraph and k (the number of times u appears in the tour) must be an integer, this
shows that the valency of every vertex must be even.
(⇐) Suppose we have a connected multigraph in which the valency of every vertex is even.
Consider the following algorithm (which will be the first stage of our final algorithm):
Make u (some arbitrary vertex) our active vertex, with a list L of all of the edges of E.
Make u the first vertex in a new sequence C of vertices. Repeat the following step as many
times as possible:
Call the active vertex v. Choose any edge vx in L that is incident with v. Add x (the other
endvertex of this edge) to the end of C, and make x the new active vertex. Remove vx from L.
We claim that when this algorithm terminates, the sequence C will be a tour (though not
necessarily an Euler tour) in the multigraph. By construction, C is a walk, and C cannot use
any edge more than once since each edge appears in L only once and is removed from L once
it has been used, so C is a trail. We need to show that the walk C is closed.
The only way the algorithm can terminate is if L contains no edge that is incident with the
active vertex. Towards a contradiction, suppose that this happens at a time when the active
vertex is y 6= u. Now, y has valency 2r in the multigraph for some integer r, so there were
2r edges in L that were incident with y when we started the algorithm. Since y 6= u, every
time y appears in C before this appearance, we removed 2 edges incident with y from L (one
in the step when we made y the active vertex, and one in the following step). Furthermore,
we removed one additional edge incident with y from L in the final step, when we made y the
active vertex again. Thus if there are t previous appearances of y in C, we have removed 2t + 1
edges incident with y from L. Since 2r is even and 2t + 1 is odd, there must still be at least one
edge incident with y that is in L, contradicting the fact that the algorithm terminated. This
contradiction shows that, when the algorithm terminates, the active vertex must be u, so the
sequence C is a closed walk. Since C is a trail, we see that C must be a tour.
If the tour C is not an Euler tour, let y be the first vertex that appears in C for which
there remains an incident edge in L. Repeat the previous algorithm starting with y being the
active vertex, and with L starting at its current state (not all of E). The result will be a tour
beginning and ending at y that uses only edges that were not in C. Insert this tour into C as
follows: if C = (u = u1 . . . , y = ui , . . . , uk = u) and the new tour is (y = v1 , . . . , vj = y), then
the result of inserting the new tour into C will be
(u = u1 , . . . , y = ui = v1 , v2 , . . . , vj = y = ui , ui+1 , . . . , uk = u).
Replace C by this extended tour.
13. Euler and Hamilton 111
Repeat the process described in the previous paragraph as many times as possible (this
is the second and last stage of our final algorithm). Since E is finite and the multigraph is
connected, sooner or later all of the edges of L must be exhausted. At this point, we must have
an Euler tour.
EXAMPLE 13.4. Use the algorithm described in the proof of the previous result, to find an
Euler tour in the following graph.
a b c d
e f g h
SOLUTION. Let’s begin the algorithm at a. As E = L is a large set, we won’t list the remaining
elements every time we choose a new active vertex in the early stages. An easy method for you
to keep track of the edges still in L is to colour the edges that are no longer in L (the edges we
use) with a different colour as we go.
There are many different possible outcomes for the algorithm since there are often many
acceptable choices for the next active vertex. One initial set of choices could be
C = (a, b, f, e, a, f, g, a).
The first stage of the algorithm terminates at this point since all four edges incident with a
have been used. At this point, we have
L = {bg, bh, cd, cf, cg, ch, df, dg, dh, gh}.
The first vertex in C that is incident with an edge in L is b. We run the first stage of the
algorithm again with b as the initial active vertex and this list for L. Again, there are many
possible outcomes; one is (b, g, h, b).
We insert (b, g, h, b) into C, obtaining a new C = (a, b, g, h, b, f, e, a, f, g, a). At this point,
we have
L = {cd, cf, cg, ch, df, dg, dh}.
Now g is the first vertex in C that is incident with an edge in L. We run the first stage of the
algorithm again with g as the initial active vertex and the current L. One possible outcome is
(g, c, f, d, g).
Inserting this into C yields a new
C = (a, b, g, c, f, d, g, h, b, f, e, a, f, g, a).
At this point, we have L = {cd, ch, dh}. The first vertex in C that is incident with an edge in
L is c. We run the first stage of the algorithm one final time with c as the initial active vertex
and L = {cd, ch, dh}. This time there are only two possible outcomes: (c, d, h, c) or (c, h, d, c).
We choose (c, d, h, c).
Inserting this into C yields our Euler tour:
C = (a, b, g, c, d, h, c, f, d, g, h, b, f, e, a, f, g, a).
COROLLARY 13.5. A connected graph (or multigraph, with or without loops) has an Euler
trail if and only if at most two vertices have odd valency.
112 13. Euler and Hamilton
PROOF. Suppose we have a connected graph (or multigraph, with or without loops), G. Since
the statement is if and only if, there are two implications to prove.
(⇒) Suppose that G has an Euler trail. If the trail is closed then it is a tour, and by
Theorem 13.3, there are no vertices of odd valency. If the trail is not closed, say it is a u − v
walk. Add an edge between u and v to G, creating a new graph G∗ (note that G∗ may be a
multigraph if uv was already an edge of G, even if G wasn’t a multigraph), and add u to the
end of the Euler trail in G, to create an Euler tour in G∗ . By Theorem 13.3, the fact that G∗
has an Euler tour means that every vertex of G∗ has even valency. Now, the vertices of G all
have the same valency in G∗ as they have in G, with the exception that the valencies of u and
v are one higher in G∗ than in G. Therefore, in this case there are exactly two vertices of odd
valency in G; namely, u and v.
(⇐) Now we suppose that G has at most 2 vertices of odd valency. By Corollary 11.21
(the corollary to Euler’s handshaking lemma), if there are at most two vertices of odd valency,
then there are either 0 or 2 vertices of odd valency. We consider these two cases.
If there are 0 vertices of odd valency, then by Theorem 13.3, G has an Euler tour.
If there are two vertices of odd valency, say u and v, add an edge between u and v to G,
creating a new graph G∗ (note that G∗ may be a multigraph if uv was already an edge of G,
even if G wasn’t a multigraph). Now in G∗ every vertex has even valency, so G∗ has an Euler
tour. In fact, a careful look at the algorithm given in the proof of Theorem 13.3 shows that we
may choose u and v (in that order) to be the first two vertices in this Euler tour, so that uv
(the edge that is in G∗ but not G) is the first edge used in the tour. Now if we delete u from
the start of this Euler tour, the result is an Euler trail in G that starts at v and ends at u.
EXERCISES 13.6. For each of the following graphs, is there an Euler tour? Is there an Euler
trail? If either exists, find one; if not, explain why not.
1)
a b
j c
i d
h e
g f
2)
a b c d
e f g h
3)
a b c
d e f
13. Euler and Hamilton 113
4) If it is possible, draw a graph that has an even number of vertices and an odd number
of edges, that also has an Euler tour. If that isn’t possible, explain why there is no
such graph.
5) Which complete graphs have an Euler tour? Of the complete graphs that do not have
an Euler tour, which of them have an Euler trail?
EXERCISES 13.7. Sylvia’s cat is missing. She wants to look for it in all the nearby streets,
but she is tired and doesn’t want to walk any farther than she must. Find an efficient route
for Sylvia to take through her neighbourhood so that she starts and ends at home and walks
through each street exactly once. The location of Sylvia’s house is marked with a house-shaped
symbol ( ).
A street
2nd Cres.
.
ve
B street
.
ve
zA
yA
1st Cres. 3rd Cres.
C street
an actual dodecahedron. In both cases, nails were placed at the corners of the dodecahedron
representing cities, and the game was played by wrapping a string around the nails, traveled
only along edges, visiting each nail once, and ending at the starting point. Unfortunately, the
game was not a financial success. It is not very difficult and becomes uninteresting once solved.
The thick edges form a Hamilton cycle in the graph of the dodecahedron:
Not every connected graph has a Hamilton cycle; in fact, not every connected graph has a
Hamilton path.
Unfortunately, in contrast to Euler’s result about Euler tours and trails (given in Theo-
rem 13.3 and Corollary 13.5), there is no known characterisation that enables us to quickly
determine whether or not an arbitrary graph has a Hamilton cycle (or path). This is a hard
problem in general. We do know of some necessary conditions (any graph that fails to meet
these conditions cannot have a Hamilton cycle) and some sufficient conditions (any graph that
meets these must have a Hamilton cycle). However, many graphs fail to meet any of these con-
ditions. There are also some conditions that are either necessary or sufficient for the existence
of a Hamilton path.
Here is a necessary condition for a graph to have a Hamilton cycle.
THEOREM 13.9. If G is a graph with a Hamilton cycle, then for every S ⊂ V with S 6= ∅, V ,
the graph G \ S has at most |S| connected components.
PROOF. Let C be a Hamilton cycle in G. Fix an arbitrary proper, nonempty subset S of V .
One at a time, delete the vertices of S from C. After the first vertex is deleted, the result
is still connected, but has become a path. When any of the subsequent |S| − 1 vertices is
deleted, it either breaks some path into two shorter paths (increasing the number of connected
components by one) or removes a vertex at an end of some path (leaving the number of connected
components unchanged, or reducing it by one if this component was a P0 ). So C \ S has at
most 1 + (|S| − 1) = |S| connected components.
Notice that if two vertices u and v are in the same connected component of C \ S, then
they will also be in the same connected component of G \ S. This is because adding edges can
13. Euler and Hamilton 115
only connect things more fully, reducing the number of connected components. More formally,
if there is a u − v walk in C, then any pair of consecutive vertices in that walk is adjacent in C
so is also adjacent in G. Therefore the same walk is a u − v walk in G. This tells us that the
number of connected components of G \ S is at most the number of connected components of
C \ S, which we have shown to be at most |S|.
EXAMPLE 13.10. When a non-leaf is deleted from a path of length at least 2, the deletion of
this single vertex leaves two connected components. So no path of length at least 2 contains a
Hamilton cycle.
Here’s a graph in which the non-existence of a Hamilton cycle might be less obvious without
Theorem 13.9. Deleting the three white vertices leaves four connected components.
As you might expect, if all of the vertices of a graph have sufficiently high valency, it will
always be possible to find a Hamilton cycle in the graph. (In fact, generally the graph will
have many different Hamilton cycles.) Before we can formalise this idea, it is helpful to have
an additional piece of notation.
DEFINITION 13.11. The minimum valency of a graph G is
min d(v).
v∈V
NOTATION 13.12. We use δ to denote the minimum valency of a graph, and ∆ to denote its
maximum valency. If we need to clarify the graph involved, we use δ(G) or ∆(G).
Although the following theorem was proven back in 1952, it remains one of the most powerful
known methods for determining that a graph has a Hamilton cycle.
THEOREM 13.13 (Dirac, 1952). If G is a graph with vertex set V such that |V | ≥ 3 and
δ(G) ≥ |V |/2, then G has a Hamilton cycle.
PROOF. Towards a contradiction, suppose that G is a graph with vertex set V , that |V | = n ≥
3, and that δ(G) ≥ n/2, but G has no Hamilton cycle.
Repeat the following as many times as possible: if there is an edge that can be added to G
without creating a Hamilton cycle in the resulting graph, add that edge to G. When this has
been done as many times as possible, call the resulting graph H. The graph H has the same
vertex set V , and since we have added edges we have not decreased the valency of any vertex,
116 13. Euler and Hamilton
so we have δ(H) ≥ n/2. Now, H still has no Hamilton cycle, but adding any edge to H gives
a graph that does have a Hamilton cycle.
Since complete graphs on at least three vertices always have Hamilton cycles (see Exer-
cise 13.19(1)), we must have H ∼ 6 Kn , so there are at least two vertices of H, say u and v,
=
that are not adjacent. By our construction of H from G, adding the edge uv to H would result
in a Hamilton cycle, and this Hamilton cycle must use the edge uv (otherwise it would be a
Hamilton cycle in H, but H has no Hamilton cycle). Thus, the portion of the Hamilton cycle
that is in H forms a Hamilton path from u to v. Write this Hamilton path as
(u = u1 , u2 , . . . , un = v).
Define the sets
S = {ui | u ∼ ui+1 } and T = {ui | v ∼ ui }.
That is, S is the set of vertices that appear immediately before a neighbour of u on the Hamilton
path, while T is the set of vertices on the Hamilton path that are neighbours of v. Notice that
v = un 6∈ S since un+1 isn’t defined, and v = un 6∈ T since our graphs are simple (so have no
loops). Thus, un 6∈ S ∪ T , so |S ∪ T | < n.
Towards a contradiction, suppose that for some i, ui ∈ S ∩ T . Then by the definitions of S
and T , we have u ∼ ui+1 and v ∼ ui , so:
ui+1 un−1
... ...
u = u1 u2 ui un = v
In fact, the statement of Dirac’s theorem was improved by Bondy and Chvatal in 1974.
They began by observing that the proof given above for Dirac’s Theorem actually proves the
following result.
LEMMA 13.14. Suppose that G is a graph on n vertices, u and v are nonadjacent vertices of
G, and d(u) + d(v) ≥ n. Then G has a Hamilton cycle if and only if the graph obtained by
adding the edge uv to G has a Hamilton cycle.
With this in mind, they made the following definition.
DEFINITION 13.15. Let G be a graph on n vertices. The closure of G is the graph obtained
by repeatedly joining pairs of nonadjacent vertices u and v for which d(u) + d(v) ≥ n, until no
such pair exists.
Before they were able to work with this definition, they had to prove that the closure of a
graph is well-defined. In other words, since there will often be choices involved in forming the
closure of a graph (if more than one pair of vertices satisfy the condition, which edge do we add
13. Euler and Hamilton 117
first?), is it possible that by making different choices, we might end up with a different graph at
the end? The answer, fortunately, is no; any graph has a unique closure, as we will now prove.
LEMMA 13.16. Closure is well-defined. That is, any graph has a unique closure.
PROOF. Let (e1 , . . . , e` ) be one sequence of edges we can choose to arrive at the closure of
G, and let the resulting closure be the graph G1 . Let (f1 , . . . , fm ) be another such sequence,
and let the resulting closure be the graph G2 . We will prove by induction on ` that for every
1 ≤ i ≤ `, ei ∈ {f1 , . . . , fm }. We will use {ui , vi } to denote the endvertices of ei .
Base case: ` = 1, so only the edge {u1 , v1 } is added to G in order to form G1 . Since this
was the first edge added, we must have
dG (u1 ) + dG (v1 ) ≥ n.
Since G2 has all of the edges of G, we must certainly have
dG2 (u1 ) + dG2 (v1 ) ≥ n.
Since G2 is a closure of G, it has no pair of nonadjacent edges whose valencies sum to n or
higher, so u1 must be adjacent to v1 in G2 . Since the edge u1 v1 was not in G, it must be in
{f1 , . . . , fm }. This completes the proof of the base case.
Inductive step: We begin with the inductive hypothesis. Let k ≥ 1 be arbitrary (with
k ≤ `), and suppose that
e1 , . . . , ek ∈ {f1 , . . . , fm }.
Consider ek+1 = {uk+1 , vk+1 }. Let G0 be the graph obtained by adding the edges e1 , . . . , ek
to G. Since ek+1 was chosen to add to G0 to form G1 , it must be the case that
dG0 (uk+1 ) + dG0 (vk+1 ) ≥ n.
By our induction hypothesis, all of the edges of G0 are also in G2 , so this means
dG2 (uk+1 ) + dG2 (vk+1 ) ≥ n.
Since G2 is a closure of G, it has no pair of nonadjacent edges whose valencies sum to n or
higher, so uk+1 must be adjacent to vk+1 in G2 . Since the edge ek+1 was not in G, it must be
in {f1 , . . . , fm }.
By the Principle of Mathematical Induction, G2 contains all of the edges of G1 . Since there
was nothing special about G2 as distinct from G1 , we could use the same proof to show that
G1 contains all of the edges of G2 . Therefore, G1 and G2 have the same edges. Since they also
have the same vertices (the vertices of G), they are the same graph. Thus, the closure of any
graph is unique.
This allowed Bondy and Chvatal to deduce the following result, which is stronger than
Dirac’s although as we’ve seen the proof is not significantly different.
THEOREM 13.17. A simple graph has a Hamilton cycle if and only if its closure has a Hamilton
cycle.
PROOF. Repeatedly apply Lemma 13.14.
EXERCISES 13.19.
1) Prove by induction that for every n ≥ 3, Kn has a Hamilton cycle.
2) Find the closure of each of these graphs. Can you easily tell from the closure whether
or not the graph has a Hamilton cycle?
(a) (b)
a b a b
f c f c
e d e d
3) Use Theorem 13.9 to prove that this graph does not have a Hamilton cycle.
a b
h c
g d
f e
4) Prove that if G has a Hamilton path, then for every nonempty proper subset S of V ,
G − S has no more than |S| + 1 connected components.
5) For the two graphs in Exercise 13.19(2), either find a Hamilton cycle or use Theo-
rem 13.9 to show that no Hamilton cycle exists.
SUMMARY:
• algorithms for finding Euler tours and trails
• Important definitions:
◦ closed walk, trail, tour
◦ Euler tour, Euler trail
◦ Hamilton cycle, Hamilton path
◦ minimum valency, maximum valency
◦ closure of a graph
• Notation:
◦ δ, ∆
Chapter 14
Graph Colouring
14A. Edge colouring
Suppose you have been given the job of scheduling a round-robin tennis tournament with n
players. One way to approach the problem is to model it as a graph: the vertices of the graph
will represent the players, and the edges will represent the matches that need to be played.
Since it is a round-robin tournament, every player must play every other player, so the graph
will be complete. Creating the schedule amounts to assigning a time to each of the edges,
representing the time at which that match is to be played.
Notice that there is a constraint. When you have assigned a time to a particular edge uv,
no other edge incident with either u or v can be assigned the same time, since this would mean
that either player u or player v is supposed to play two games at once. Instead of writing times
on each edge, we will choose a colour to represent each of the time slots, and colour the edges
that are to be played at that time, with that colour.
Here is an example of a possible schedule for the tournament, when n = 7.
EXAMPLE 14.1. The players are numbered from 1 through 7, and we will spread the tour-
nament out over seven days. Games to be played on each day should have a different colour
than the games on other days, but, because this text is printed in black-and-white, we will use
some line patterns, instead of colours. Games to be played on Monday will be drawn as usual.
Games to be played on Tuesday will be thin. Games to be played on Wednesday will be dotted.
Games to be played on Thursday will be dashed. Games to be played on Friday will be thick.
Games to be played on Saturday will be grey. Games to be played on Sunday will be thin and
dashed.
1
7 2
6 3
5 4
This gives a schedule. For anyone who has trouble distinguishing the “colours” of the edges,
the normal edges are 12, 37, and 46; the thin edges are 13, 24, and 57; the dotted edges are 15,
26, and 34; the dashed edges are 17, 36, and 45; the thick edges are 23, 47, and 56; the grey
edges are 14, 25, and 67; and the thin dashed edges are 16, 27, and 35.
119
120 14. Graph Colouring
NOTATION 14.4. The chromatic index of G is denoted by χ0 (G), or simply by χ0 if the context
is unambiguous.
Here is an easy observation:
PROPOSITION 14.5. For any graph G, χ0 (G) ≥ ∆(G).
PROOF. Recall that ∆(G) denotes the maximum value of d(v) over all vertices v of G. So there
is some vertex v of G such that d(v) = ∆(G). In any proper edge-colouring, the d(v) edges that
are incident with v, must all be assigned different colours. Thus, any proper edge-colouring
must have at least d(v) = ∆(G) distinct colours. This means χ0 (G) ≥ ∆(G).
EXAMPLE 14.6. The colouring given in Example 14.1 shows that χ0 (K7 ) ≤ 7, since we were
able to properly edge-colour K7 using seven colours.
To show that we cannot colour K7 with fewer than 7 colours, notice that because each of
the 7 vertices can only be incident with one edge of a given colour, there cannot be more than
3 edges coloured with any given colour (3 edges are already incident with 6 of the 7 vertices,
and a fourth edge would have to be incident with two others).
7
We know that K7 has 2 = 21 edges, so if at most 3 edges can be coloured with any given
colour, we will require at least 7 colours to properly edge-colour K7 . Thus χ0 (K7 ) ≥ 7.
Thus, we have shown that χ0 (K7 ) = 7.
This shows that χ0 (K7 ) = 7 > ∆(K7 ) = 6, so it is not always possible to achieve equality
in the bound given by Proposition 14.5. Our next example shows that it is sometimes possible
to achieve equality in that bound.
EXAMPLE 14.7. Here is a proper 5-edge-colouring of K6 :
1 2
6 3
5 4
In case the edge colours are difficult to distinguish, the thick edges are 12, 36, and 45; the
thin edges are 13, 24, and 56; the dotted edges are 14, 26, and 35; the dashed edges are 15, 23,
14. Graph Colouring 121
and 46; and the grey edges are 16, 25, and 34. This shows that χ0 (K6 ) ≤ 5. Since the valency
of every vertex of K6 is 5, Proposition 14.5 implies that χ0 (K6 ) ≥ 5. Putting these together, we
see that χ0 (K6 ) = ∆(K6 ) = 5, so equality in the bound of Proposition 14.5 is achieved by K6 .
The following rather remarkable result was proven by Vadim Vizing in 1964:
THEOREM 14.8. Vizing’s Theorem For any simple graph G, χ0 (G) ∈ {∆(G), ∆(G) + 1}.
We will not go over the proof of this theorem.
DEFINITION 14.9. If χ0 (G) = ∆(G) then G is said to be a class one graph, and if χ0 (G) =
∆(G) + 1 then G is said to be a class two graph.
To date, graphs have not been completely classified according to which graphs are class
one and which are class two, but it has been proven that “almost every” graph is of class one.
Technically, this means that if you choose a random graph out of all of the graphs on at most
n vertices, the probability that you will choose a class two graph approaches 0 as n approaches
infinity.
There are, however, infinitely many class two graphs; the same argument we used to show
that χ0 (K7 ) ≥ 7 can also be used to prove that χ0 (K2n+1 ) = 2n + 1 for any positive integer n,
since the number of edges is
(2n + 1)(2n)/2 = n(2n + 1)
and each colour can only be used to colour n of the edges. Since ∆(K2n+1 ) = 2n, this shows
that K2n+1 is class two.
Large families of graphs have been shown to be class one graphs. We will devote most of
the rest of this section to proving that all of the graphs in one particular family are class one.
First we need to define the family.
DEFINITION 14.10. A graph is bipartite if its vertices can be partitioned into two sets V1
and V2 , such that every edge of the graph has one of its endvertices in V1 , and the other in V2 .
The sets V1 and V2 form a bipartition of the graph.
EXAMPLE 14.11. The following graphs are bipartite. Every edge has one endvertex on the
left side, and one on the right.
The graph Kn is not bipartite if n ≥ 3. The first vertex may as well go into V1 ; the second
vertex is adjacent to it, so must go into V2 ; but the third vertex is adjacent to both, so cannot
go into either V1 or V2 .
Although the following class of bipartite graphs will not be used in this chapter, they are
an important class of bipartite graphs that will come up again later.
DEFINITION 14.12. The complete bipartite graph, Km,n , is the bipartite graph on m + n
vertices with as many edges as possible subject to the constraint that it has a bipartition into
sets of cardinality m and n. That is, it has every edge between the two sets of the bipartition.
122 14. Graph Colouring
Before proving that all bipartite graphs are class one, we need to understand the structure
of bipartite graphs a bit better. Here is an important theorem.
THEOREM 14.13. A graph G is bipartite if and only if G contains no cycle of odd length.
PROOF. This is an if and only if statement, so we have two implications to prove.
(⇒) We prove the contrapositive, that if G contains a cycle of odd length, then G cannot
be bipartite.
Let
(v1 , v2 , . . . , v2k+1 , v1 )
be a cycle of odd length in G. We try to establish a bipartition V1 and V2 for G. Without
loss of generality, we may assume that v1 ∈ V1 . Then we must have v2 ∈ V2 since v2 ∼ v1 .
Continuing in this fashion around the cycle, we see that for every 1 ≤ i ≤ k, we have v2i+1 ∈ V1
and v2i ∈ V2 . In particular, v2k+1 ∈ V1 , but v1 ∈ V1 and v1 ∼ v2k+1 , contradicting the fact that
every edge must have one of its endvertices in V2 . Thus, G is not bipartite.
(⇐) Let G be a graph that is not bipartite. We must show that there is an odd cycle in G.
If every connected component of G is bipartite, then G is bipartite (choose one set of the
bipartition from each connected component; let V1 be the union of these, and V2 the set of all
other vertices of G; this is a bipartition for G). Thus there is at least one connected component
of G that is not bipartite.
Pick any vertex u from a non-bipartite connected component of G, and assign it to V1 .
Place all of its neighbours in V2 . Place all of their neighbours into V1 . Repeat this process,
at each step putting all of the neighbours of every vertex of V1 into V2 , and then all of the
neighbours of every vertex of V2 into V1 .
Since this component is not bipartite, at some point we must run into the situation that
we place a vertex v into Vj , but a neighbour u1 of v is also in Vj (for some j ∈ {1, 2}). By our
construction of V1 and V2 , there must be a walk from u1 to v that alternates between vertices
in Vj and vertices in V3−j . By Proposition 12.16, there must in fact be a path from u1 to v that
alternates between vertices in Vj and vertices in V3−j . Since the path alternates between the
two sets but begins and ends in Vj , it has even length. Therefore, adding u1 to the end of this
path yields a cycle of odd length in G.
In order to prove that bipartite graphs are class one, we require a lemma.
LEMMA 14.14. Let G be a connected graph that is not a cycle of odd length. Then G the edges
of G can be 2-coloured so that edges of both colours are incident with every non-leaf vertex.
(Note: this will probably not be a proper 2-edge-colouring of G.)
PROOF. We first consider the case where every vertex of G has even valency.
Choose a vertex v of G subject to the constraint that if any vertex of G has valency greater
than 2, then v is such a vertex. Since every vertex of G has even valency, we can find an Euler
tour of G that begins and ends at v. Alternate edge colours around this tour. Clearly, every
vertex that is visited in the middle of the tour (that is, every vertex except possibly v) must
be incident with edges of both colours, since whichever colour is given to the edge we travel to
reach that vertex, the other colour will be given to the edge we travel when leaving that vertex.
If any vertex of G has valency greater than 2, then by our choice of v, the valency of v must
be greater than 2, so v is visited in the middle of the tour, and this colouring has the desired
property. If every vertex of G has valency 2, then since G is connected, G must be a cycle (see
Exercise 12.22(4). Since G is not a cycle of odd length (by hypothesis), G must be a cycle of
even length. Therefore the number of edges of G is even, so the tour will begin and end with
edges of opposite colours, both of which are incident with v. Again we see that this colouring
has the desired property.
14. Graph Colouring 123
NOTATION 14.15. Given a (not necessarily proper) edge-colouring C, we use c(v) to denote
the number of distinct colours that have be used on edges that are incident with v. Clearly,
c(v) ≤ d(v).
then we must have c(v) = d(v) for every v ∈ V . This is precisely equivalent to the definition of
a proper colouring.
At last, we are ready to prove that bipartite graphs are class one.
THEOREM 14.17. If G is bipartite, then χ0 (G) = ∆(G).
PROOF. Let G be a bipartite graph. Towards a contradiction, suppose that χ0 (G) > ∆(G).
Let C be an optimal ∆(G)-edge-colouring of G. By assumption, C will not be a proper edge
colouring, so there must be some vertex u such that c(u) < d(u). By the Pigeonhole Principle,
some colour j must be used to colour at least two of the edges incident with u, and since there
are ∆(G) ≥ d(u) colours in total and only c(u) are used on edges incident with u, there must
be some colour i that is not used to colour any edge incident with u.
Consider only the edges of G that have been coloured with either i or j in the colouring C.
Since G is bipartite, these edges cannot include an odd cycle. We apply Lemma 14.14 to each
connected component formed by these edges to re-colour these edges . Our re-colouring will use
only colours i and j, and if a vertex v was incident to at least two edges coloured with either i
or j in C, then under the re-colouring, v will be incident with at least one edge coloured with i
and at least one edge coloured with j. Leave all of the other edge colours alone, and call this
new colouring C 0 .
We claim that C 0 is an improvement on C. Any vertex v that had at most one incident
edge coloured with either i or j under C, will still have exactly the same colours except that
the edge coloured i or j might have switched its colour to the other of i and j. In any case, we
will have c0 (v) = c(v). Any vertex v that had at least two incident edges coloured with either i
or j under C, will still have all of the same colours except that it will now have incident edges
coloured with both i and j, so c0 (v) ≥ c(v). Furthermore, we have c0 (u) > c(u) since the edges
124 14. Graph Colouring
incident with u now include edges coloured with both i and j, where before there were only
edges coloured with j. Thus, X X
c0 (v) ≥ c(v),
v∈V v∈V
so C 0 is an improvement on C, as claimed.
We have contradicted our assumption that C is an optimal ∆(G)-edge-colouring. This
contradiction serves to prove that χ0 (G) = ∆(G).
EXERCISES 14.18.
1) Prove that every tree is a class one graph.
2) Prove that every cycle of odd length is a class two graph.
3) Find a graph that contains a cycle of odd length, but is a class one graph.
4) For each of the following graphs, find the edge-chromatic number, determine whether
the graph is class one or class two, and find a proper edge-colouring that uses the
smallest possible number of colours.
(a) The two graphs in Exercise 13.19(2).
(b) The two graphs in Example 14.11.
(c) The skeleton of a dodecahedron (the leftmost of the two graphs drawn below).
(d) The Petersen graph (the rightmost of the two graphs drawn below).
You may assume, without proof, that the Petersen graph is class two.
5) Find a systematic approach to colouring the edges of complete graphs that demon-
strates that χ0 (K2n−1 ) = χ0 (K2n ) = 2n − 1.
6) Find a systematic approach to colouring the edges of complete bipartite graphs that
demonstrates that χ0 (Km,n ) = ∆(Km,n ) = max{m, n}.
EXERCISES 14.19. The following exercises illustrate some of the connections between Hamil-
ton cycles and edge-colouring.
1) Definition. A graph is said to be Hamilton-connected if there is a Hamilton path from
each vertex in the graph to each of the other vertices in the graph.
Prove that if G is bipartite and has at least 3 vertices, then G is not Hamilton-
connected.
[Hint: Prove this by contradiction. Consider the length of a Hamilton path and where it can
end.]
2) Suppose that G is a bipartite graph with V1 and V2 forming a bipartition. Show that
if |V1 | =
6 |V2 | then G has no Hamilton cycle.
14. Graph Colouring 125
3) Prove that if every vertex of G has valency 3, and G has a Hamilton cycle, then G is
class one.
[Hint: Use the corollary to Euler’s handshaking lemma, and find a way to assign colours to the
edges of the Hamilton cycle.]
SOLUTION. Choose some vertex v. Since the 5 edges incident with v are coloured with only
two colours, the generalized Pigeonhole Principle implies that three of these edges are the same
colour. For definiteness, let us say that three edges vu1 , vu2 , and vu3 are all red.
Now, u1 , u2 , and u3 are the vertices of a copy of K3 that is inside K6 . If all three edges of
this K3 are blue, then we have our desired monochromatic triangle (namely, a blue triangle).
So we may assume that one of the edges is red; say, u1 u2 is red. Since the edges vu1 and vu2
are also red, we see that v, u1 , and u2 are the vertices of a monochromatic triangle (namely, a
red triangle).
EXAMPLE 14.22.
1) We have R(k, 1) = 1 for all k. This is because K1 has no edges, so, for any colouring
of any Kn , it is true (vacuously) that all of the edges of K1 are blue.
2) We have R(k, 2) = k for all k. Namely, if some edge is blue, then there is a blue K2 ,
while if there are no blue edges, then the entire graph is a red Kk .
3) We have R(3, 3) = 6. To see this, note that Example 14.20
shows R(3, 3) ≤ 6, while the edge-colouring of K5 at right has
no monochromatic triangle (because the only monochromatic
cycles are of length 5), so R(3, 3) > 5.
4) We have R(k, `) = R(`, k) for all k and `. Namely, if every colouring of Kn has either
a red Kk or a blue K` , then we see that every colouring of Kn must have either a red
K` or a blue Kk , just by switching red and blue in the colouring.
126 14. Graph Colouring
PROOF. Let n = R(k − 1, `) + R(k, ` − 1), and suppose each edge of Kn is coloured either red
or blue. We wish to show there is either a red Kk or a blue K` .
Choose some vertex v of Kn . Then the number of edges incident with v is
n − 1 = R(k − 1, `) + R(k, ` − 1) − 1 > R(k − 1, `) − 1 + R(k, ` − 1) − 1 ,
so the very generalized Pigeonhole Principle implies that either R(k − 1, `) of these edges are
red, or R(k, ` − 1) of these edges are blue.
For definiteness, let us assume that the edges vu1 , vu2 , . . . , vur are all blue, where r =
R(k, ` − 1). Now, u1 , u2 , . . . , ur are the vertices of a copy of Kr that is inside Kn . Since
r = R(k, ` − 1), we know that this Kr contains either a red Kk or a blue K`−1 .
If it contains a red Kk , then we have the desired red Kk . So we may assume u1 , . . . , u`−1
are the vertices of a blue K`−1 . Since the edges vu1 , vu2 , . . . , vu`−1 are also blue, we see that
v, u1 , u2 , . . . , u`−1 are the vertices of the desired blue K` .
EXERCISES 14.24.
1) Show R(3, 4) > 6.
2) Using Proposition 14.23 and the values of R(k, `) given in Example 14.22, find the best
upper bound you can on R(k, `) for 3 ≤ k ≤ ` ≤ 6.
3) Show R(k, `) ≤ 2k+` for all k and `.
[Hint: Use Proposition 14.23 and induction on k + `.]
4) It is known that 40 ≤ R(3, 10) ≤ 42. Using this information, what can you say about
R(3, 11)?
5) Show there are at least two monochromatic triangles in every colouring of the edges of
K6 with two colours.
[Hint: Show that there must either be two red (say) triangles, or a red triangle and a blue edge
whose endvertices are not in the triangle. Then show that any colouring of the edges joining
the red triangle with the blue edge creates either a blue triangle or a second red triangle.]
Remark 14.25. The exact value of R(k, `) seems to be extremely difficult to find, except for
very small values of k and `. For example, although it has been proved that R(4, 4) = 18 and
R(4, 5) = 25, no one has been able to determine the precise value of R(k, `) for any situation in
which k and ` are both at least 5. The legendary combinatorist Paul Erdös (1913–1996) said
that it would be hopeless to try to calculate the exact value of R(6, 6), even with all of the
computer resources and brightest minds in the whole world working on the problem for a year.
(We do know that R(6, 6) is somewhere between 102 and 165.) For more information about the
values that have been calculated, see the Wikipedia article on Ramsey’s theorem.
14. Graph Colouring 127
EXERCISES 14.26. The edges of Kn can also be coloured with more than two colours.
1) Show every colouring of the edges of K17 with 3 colours has a monochromatic triangle.
2) Suppose there is a monochromatic triangle in every colouring of the edges of Kn with
c colours. Show that if N − 1 > (c + 1)(n − 1), then every colouring of the edges of KN
with c + 1 colours has a monochromatic triangle.
Similar arguments (combined with induction on the number of colours) establish the fol-
lowing very general result.
THEOREM 14.27. Ramsey’s Theorem Given c colours and fixed sizes n1 , . . . , nc ≥ 1, there is
an integer
r = R(n1 , . . . , nc )
such that for any c-colouring of the edges of Kr , there must be some i ∈ {1, . . . , c} such that
Kr has a subgraph isomorphic to Kni all of whose edges have been coloured with colour i.
Suppose now that |V2 | ≥ r1 (the proof is similar). Since r1 = R(n1 , n2 − 1), the subgraph
whose vertices are the elements of V2 has a subgraph that is either a red Kn1 or a blue Kn2 −1 .
In the former case, this subgraph is also in our original Kr1 +r2 and we are done. In the latter
case, the subgraph whose vertices are the elements of V2 ∪ {v} has a blue Kn2 and we are done.
By the Principle of Mathematical Induction, for every n1 , n2 ≥ 1, there is some integer
r = R(n1 , n2 ) such that for any colouring of the edges of Kr , there is a subgraph that is either
a red Kn1 or a blue Kn2 .
This second proof by induction completes the proof of the second base case for our original
induction on c, the number of colours. We are now ready for the inductive step for our original
proof by induction.
Inductive step: We begin with the inductive hypothesis. Let m ≥ 2 be arbitrary. Assume
that for every k1 , . . . , km ≥ 1, there is an integer r = R(k1 , . . . , km ) such that for any m-
colouring of the edges of Kr , there must be some i ∈ {1, . . . , m} such that Kr has a subgraph
isomorphic to Kki , all of whose edges have been coloured with colour i.
Let n1 , . . . , nm+1 be arbitrary. Take a complete graph on
vertices, and colour its edges with m + 1 colours. Temporarily consider the colours m and
m + 1 to be the same, resulting in a colouring of the edges with m colours. By our inductive
hypothesis, there must either be some i ∈ {1, . . . , m − 1} such that our Kr has a subgraph
isomorphic to Kni , all of whose edges have been coloured with colour i, or Kr has a subgraph
isomorphic to KR(nm ,nm+1 ) all of whose edges have been coloured with the mth colour (where
this mth colour is really the combination of the colours m and m + 1).
If there is some i ∈ {1, . . . , m − 1} such that our Kr has a subgraph isomorphic to Kni , all
of whose edges have been coloured with colour i, then we are done. The possibility remains
that our Kr has a subgraph isomorphic to KR(nm ,nm+1 ) all of whose edges have been coloured
with either colour m or colour m + 1. But by our base case for c = 2, this graph must have
either a subgraph isomorphic to Knm all of whose edges have been coloured with colour m, or a
subgraph isomorphic to Knm+1 all of whose edges have been coloured with colour m + 1. This
completes the inductive step.
By the Principle of Mathematical Induction, for every c ≥ 1 and fixed sizes n1 , . . . , nc ≥ 1,
there is an integer r = R(n1 , . . . , nc ) such that for any c-colouring of the edges of Kr , there
must be some i ∈ {1, . . . , c} such that Kr has a subgraph isomorphic to Kni all of whose edges
have been coloured with colour i.
EXERCISES 14.28.
1) Find R(2, 2, 3).
2) Find R(2, 4).
3) Find a 2-edge-colouring of K6 that does not have a K4 of either colour.
EXERCISE 14.29. (Schur’s Theorem) Let c ∈ N+ , and let N = R(3, . . . , 3) where there are c
entries (all equal to 3). If {A1 , A2 , . . . , Ac } is any partition of {1, 2, . . . , N } into c subsets, show
that some Ai contains three integers x, y, and z, such that x + y = z.
[Hint: The vertices of KN are 1, 2, . . . , N . Put colour i on each edge uv with |u − v| ∈ Ai . If u, v, w are
the vertices of a monochromatic triangle of colour i, with u > v > w, then {u − v, v − w, u − w} ⊆ Ai ,
and we have (u − v) + (v − w) = u − w.]
14. Graph Colouring 129
This represents a possible assignment of 4 colours to the vertices. The colour of each vertex
(red, green, blue, or yellow) is indicated by writing the first letter of the colour’s name on the
vertex).
b r b r
g y g y
b r b r
Notice that this colouring obeys the constraint that interfering towers are not assigned the
same frequencies.
EXAMPLE 14.35. Prove that for a graph G, χ(G) = 2 if and only if G is a bipartite graph
that has at least one edge.
130 14. Graph Colouring
SOLUTION. Proof. (⇒) Suppose that χ(G) = 2. Take a proper 2-colouring of G with colours
1 and 2. Let V1 denote the set of vertices of colour 1, and let V2 denote the set of vertices of
colour 2. Since the colouring is proper, there are no edges both of whose endvertices are in V1
(as these would be adjacent vertices both coloured with colour 1). Similarly, there are no edges
both of whose endvertices are in V2 . Thus, the sets V1 and V2 form a bipartition of G, so G is
bipartite. Since 2 colours were required to properly colour G, G must have at least one edge.
(⇐) Suppose that G is bipartite, and that V1 and V2 form a bipartition of G. Colour the
vertices in V1 with colour 1, and colour the vertices of V2 with colour 2. By the definition of a
bipartition, no pair of adjacent vertices can have been assigned the same colour. Thus, this is
a proper 2-colouring of G, so χ(G) ≤ 2. Since G has at least one edge, the endpoints of that
edge must be assigned different colours, so χ(G) ≥ 2. Thus χ(G) = 2.
SOLUTION. Since this graph has an edge whose endvertices must be assigned different colours,
we see that χ(C2n+1 ) ≥ 2. Since a cycle of odd length is not bipartite (see Theorem 14.13), Ex-
ample 14.35 shows that χ(C2n+1 ) 6= 2, so χ(C2n+1 ) ≥ 3. Let the cycle be (u1 , u2 , . . . , u2n+1 , u1 ).
Since the only edges in the graph are between consecutive vertices in this list, if we assign colour
1 to u1 , colour 2 to u2i for 1 ≤ i ≤ n, and colour 3 to u2i+1 for 1 ≤ i ≤ n, this will be a proper
3-colouring. Thus, χ(C2n+1 ) = 3.
DEFINITION 14.37. A graph G is k-critical if χ(G) = k, but for every proper subgraph H of
G, χ(H) < χ(G).
PROOF. Towards a contradiction, suppose that G is a disconnected k-critical graph, and let
G1 and G2 be (nonempty) subgraphs of G such that every vertex of G is in either G1 or G2 ,
and there is no edge from any vertex in G1 to any vertex in G2 . By the definition of k-critical,
χ(G1 ) < χ(G) and χ(G2 ) < χ(G). But if we colour G1 with χ(G1 ) colours and G2 with χ(G2 )
colours, since there is no edge from any vertex of G1 to any vertex of G2 , this produces a proper
colouring of G with
max(χ(G1 ), χ(G2 )) < χ(G)
colours. This contradiction serves to prove that every k-critical graph is connected.
PROOF. Towards a contradiction, suppose that G is k-critical and has a vertex v of valency at
most k − 2. By the definition of k-critical, G \ {v} must be (k − 1)-colourable. Now, since v has
no more than k − 2 neighbours, its neighbours can be assigned at most k − 2 distinct colours in
this colouring. Therefore, amongst the colours used in the (k − 1)-colouring of G \ {v}, there
must be a colour that is not assigned to any of the neighbours of v. If we assign this colour
to v, the result is a proper (k − 1)-colouring of G, contradicting χ(G) = k. This contradiction
serves to prove that every k-critical graph has minimum valency at least k − 1.
PROOF. Let G be an arbitrary graph. By deleting as many edges and vertices as it is possible
to delete without reducing the chromatic number (we can never increase the chromatic number
by deleting vertices or edges, see Exercise 14.43(1)), we see that G must have a subgraph H
that is χ(G)-critical. By Theorem 14.39, we see that
δ(H) ≥ χ(G) − 1.
Thus, every vertex of H has valency at least χ(G) − 1, so in G, these same vertices still have
valency at least χ(G) − 1. For any such vertex v, we have
∆(G) ≥ d(v) ≥ χ(G) − 1,
so χ(G) ≤ ∆(G) + 1.
We have already seen two families of graphs for which this bound is attained: for complete
graphs, we have
∆(Kn ) + 1 = (n − 1) + 1 = n = χ(Kn )
(see Proposition 14.34); and for cycles of odd length, we have
∆(C2n+1 ) + 1 = 2 + 1 = 3 = χ(C2n+1 )
(see Example 14.36). In fact, Brooks proved in 1941 that these are the only connected graphs
for which this bound is obtained.
THEOREM 14.41. Brooks’ Theorem If G is connected and for every n ≥ 1, G 6∼
= C2n+1 and
∼
6 Kn , then χ(G) ≤ ∆(G).
G=
We will not include the proof of this result in this course. This theorem does allow us to
determine the chromatic number of some graphs with very little work.
EXAMPLE 14.42. The following very famous graph is called the Petersen graph. It is an
exceptional graph in many ways, so when mathematicians are trying to come up with a proof
or a counterexample in graph theory, it is often one of the first examples they will check. Find
its chromatic number.
SOLUTION. We have ∆ = 3, and since this graph is neither a complete graph nor a cycle
of odd length, by Brooks’ Theorem this shows that χ ≤ 3. We can find a cycle of length 5
around the outer edge of the graph, so this graph is not bipartite but has an edge. Therefore
(by Example 14.35), χ > 2. Hence χ = 3.
EXERCISES 14.43.
1) Prove that if H is a subgraph of G then χ(G) ≥ χ(H).
2) Prove Proposition 14.34 by induction.
3) Prove Corollary 14.40 by induction for every graph on at least one vertex.
132 14. Graph Colouring
4) For each i, j ∈ {4, 5, 6}, suppose you are given a graph G that contains a subgraph
isomorphic to Ki and no vertex has more than j neighbours. What (if anything) can
you say about χ(G)? Can you say more if you know that G is connected and is neither
a complete graph nor a cycle of odd length?
EXERCISES 14.44. For each of the following graphs, determine its chromatic number by using
theoretical arguments to provide a lower bound, and then producing a colouring that meets the
bound. Do the same for the edge-chromatic number.
1) 4)
2)
5)
3)
6)
14. Graph Colouring 133
SUMMARY:
• Vizing’s Theorem
• graphs are bipartite if and only if they contain no cycle of odd length
• Ramsey’s Theorem
• graphs are bipartite if and only if they are 2-colourable
• Brooks’ Theorem
• Petersen graph
• Important definitions:
◦ proper k-edge-colouring, k-edge-colourable
◦ edge chromatic number, chromatic index
◦ class one graph, class two graph
◦ bipartite, bipartition
◦ complete bipartite graph
◦ proper k-colouring, k-colourable
◦ chromatic number
◦ k-critical
• Notation:
◦ χ0 (G)
◦ Km,n
◦ R(n1 , . . . , nc )
◦ χ(G)
Chapter 15
Planar graphs
15A. Planar graphs
Visually, there is always a risk of confusion when a graph is drawn in such a way that some of its
edges cross over each other. Also, in physical realisations of a network, such a configuration can
lead to extra costs (think about building an overpass as compared with building an intersection).
It is therefore helpful to be able to work out whether or not a particular graph can be drawn
in such a way that no edges cross.
DEFINITION 15.1. A graph is planar if it can be drawn in the plane (R2 ) so edges that do not
share an endvertex have no points in common, and edges that do share an endvertex have no
other points in common.
Such a drawing is called a planar embedding of the graph.
e b
d c
d
b a
One of v1 , v2 , and v3 is not a corner of this region, and in fact lies outside of it while v5 lies
inside of it, making it impossible to draw the edge from this vertex to v5 .
The proof is similar if v4 and v5 lie on the outside of the boundary determined by the 3-cycle
(v1 , v2 , v3 , v1 ).
However, both K5 and K3,3 can be embedded onto the surface of what we call a torus (a
doughnut shape), with no edges meeting except at mutual endvertices. Embeddings are shown
in Figures 15.1 and 15.2.
The dotted edge wraps around through the hole in the torus.
You might think at this point that every graph can be embedded on the torus without edges
meeting except at mutual endvertices, but this is not the case. In fact, for any surface there are
graphs that cannot be embedded in that surface (without any edges meeting except at mutual
endvertices).
For any embedding of a planar graph, there is another embedded planar graph that is closely
related to it, which we will now describe. Notice that a planar embedding partitions the plane
into regions.
DEFINITION 15.5. The regions into which a planar embedding partitions the plane, are called
the faces of the planar embedding.
136 15. Planar graphs
The dotted edge wraps around through the hole in the torus.
EXAMPLE 15.6. In these drawings, we have labeled the faces of the two planar embeddings
with f1 , f2 , etc., to show them clearly.
f1
f1 f2 f5
f2
f3 f6
f4 f5 f3
f4
NOTATION 15.7. We use F (G) (or simply F if the graph is clear from the context) to denote
the set of faces of a planar embedding.
DEFINITION 15.8. We say that an edge is incident with a face of a planar embedding, if it
lies on the boundary of the face (or inside the face).
For a planar embedding of G, the dual graph or planar dual, G∗ , is defined by V (G∗ ) =
F (G), and fi ∼ fj if and only if there is an edge of G that is incident with both fi and fj .
It is possible that the dual graph of a planar embedding will not be a simple graph, even if
the original graph was simple.
EXAMPLE 15.9. Here we show how to find the planar duals of the embeddings given in Ex-
ample 15.6. We include the original embedding as above; the grey vertices and dashed edges
are the vertices and edges of the dual graph.
15. Planar graphs 137
Note that the second graph has loops and multiedges. Note also that although f1 and f5
meet at a vertex in the embedding of the first graph, they are not adjacent in the dual since
they do not share a common edge.
Some other useful observations:
• |E(G)| = |E(G∗ )|, and every dashed edge crosses exactly one black edge;
• the valency of the vertex fi in G∗ is equal to the number of edges you trace, if you
trace around the perimeter of the face fi in G (so edges that dangle inside the face get
counted twice).
PROPOSITION 15.10. The dual graph of a planar embedding has a natural planar embedding,
so is a planar graph. Furthermore, (G∗ )∗ = G.
Both of these facts follow fairly directly from the definitions.
EXAMPLE 15.11. Be careful! – Two different planar embeddings of the same graph may have
nonisomorphic dual graphs, as we show here.
f2
f1 f2 f3 f4 f1 f3 f4
In the planar dual of the embedding on the left, f1 will have valency 3; f2 and f3 will have
valency 4; and f4 will have valency 7. In the planar dual of the embedding on the right, f1 will
have valency 3; f2 will have valency 5; f4 will have valency 4, and f3 will have valency 6. Since
the lists 3, 4, 4, 7 and 3, 4, 5, 6 are not permutations of each other, the planar duals cannot be
isomorphic.
Before moving on to other related topics, we present a classification of planar graphs. This
is a theorem by Kuratowski (from whose name the notation for complete graphs is taken). He
proved this result in 1930.
We need one new definition.
DEFINITION 15.12. An edge uv can be subdivided by placing a vertex somewhere along its
length. Technically, this means deleting uv, adding a new vertex x, and adding the edges ux
and vx.
138 15. Planar graphs
EXAMPLE 15.13. An example is shown in Figure 15.3. The white vertices are the new ones.
a b
h c
g d
f e
SOLUTION. Here is a subdivision of K3,3 in the given graph. The white vertices are the vertices
that are subdividing edges. Unnecessary edges have been deleted. The bipartition consists of
{a, c, e} and {b, g, h}.
a b
h c
g d
f e
EXERCISES 15.16.
1) Prove that if a graph G has a subgraph H that is not planar, then G is not planar.
Deduce that for every n ≥ 6, Kn is not planar.
15. Planar graphs 139
2) Find a planar embedding of the following graph, and find the dual graph of your
embedding:
a b
f c
e d
3) Find a planar embedding of the following graph, and find the dual graph of your
embedding:
a b
f c
e d
4) The graph in Example 15.15 also has a subgraph that is a subdivision of K5 . Find
such a subgraph.
5) Prove that the Petersen graph is not planar.
[Hint: Use Kuratowski’s Theorem.]
6) Find planar embeddings of the two graphs pictured below. (These graphs are obtained
by deleting an edge from K5 and deleting an edge from K3,3 , respectively.)
PROOF 1. We will prove this formula by induction on the number of faces of the embedding.
Let G be a planar embedding of a connected graph (or multigraph, with or without loops).
Base case: If |F | = 1 then G cannot have any cycles (otherwise the interior and exterior of
the cycle would be 2 distinct faces). So G must be a connected graph that has no cycles, i.e.,
a tree. By Theorem 12.27 we know that we must have |E| = |V | − 1, so
|V | − |E| + |F | = |V | − (|V | − 1) + 1 = 2.
140 15. Planar graphs
A tree cannot have any loops or multiple edges, as these form cycles.
Inductive step: We begin by stating our inductive hypothesis. Let k ≥ 1 be arbitrary, and
assume that for any planar embedding of a connected graph (or multigraph, with or without
loops) with k faces, |V | − |E| + |F | = 2.
Let G be a planar embedding of a connected graph with k + 1 ≥ 2 faces. Since trees
have only one face, G must have a cycle. Choose any edge e that is in a cycle of G, and let
H = G \ {e}. Clearly, we have
|E(H)| = |E(G)| − 1
and |V (H)| = |V (G)|. Also,
|F (H)| = |F (G)| − 1 = k
since the edge e being part of a cycle must separate two faces of G, which are united into one
face of H. Furthermore, since e was in a cycle and G is connected, by Proposition 12.21 H is
connected, and H has a planar embedding induced by the planar embedding of G. Therefore
our inductive hypothesis applies to H, so
2 = |V (H)| − |E(H)| + |F (H)|
= |V (G)| − (|E(G) − 1) + (|F (G)| − 1)
= |V (G)| − |E(G)| + |F (G)|
This completes the inductive step.
By the Principle of Mathematical Induction, |V | − |E| + |F | = 2 for any planar embedding
of a connected graph (or multigraph, with or without loops).
The above proof is unusual for a proof by induction on graphs, because the induction is
not on the number of vertices. If you try to prove Euler’s formula by induction on the number
of vertices, deleting a vertex might disconnect the graph, which would mean the induction
hypothesis doesn’t apply to the resulting graph.
However, there is a different graph operation that reduces the number of vertices by 1, and
keeps the graph connected. Unfortunately, it may turn a graph into a multigraph, so it can only
be used to prove a result that holds true for multigraphs as well as for graphs. This operation
is called edge contraction.
DEFINITION 15.18. Let G be a graph with an edge uv. The graph G0 obtained by contracting
the edge uv has vertices
V (G0 ) = (V (G) \ {u, v}) ∪ {u0 },
where u0 is a new vertex. The edges are
E(G0 ) = [E(G) \ {ux : ux ∈ E(G)}] \ {vx : vx ∈ E(G)} ∪ {u0 y | uy ∈ E(G) or vy ∈ E(G)}.
If you think of vertices u and v as being connected by a very short elastic that has been
stretched out in G, then you can think of G0 as the graph you get if you allow the elastic to
contract, combining the vertices u and v into a “new” vertex u0 .
Notice that if G is connected, then the graph obtained by contracting any edge of G will also
be connected. However, if uv is the edge that we contract, and u and v have a mutual neighbour
x, then in the graph obtained by contracting uv, there will be a multiple edge between u0 and x.
Also, if G has a planar embedding, then after contracting any edge there will still be a planar
embedding. If u 6= v, then contracting uv reduces the number of vertices by one, reduces the
number of edges by one, and does not change the number of faces.
Now we can use this operation to prove Euler’s formula by induction on the number of
vertices.
15. Planar graphs 141
PROOF 2. Let G be a planar embedding of a connected graph (or multigraph, with or without
loops).
Base case: If |V | = 1 then G has one vertex. Furthermore, every edge is a loop. Every loop
involves 1 edge, and encloses 1 face. This graph will therefore have one more face than it has
loops (since it has one face even if there are no loops). Thus,
|V | − |E| + |F | = 1 − e + (e + 1) = 2.
Inductive step: We begin by stating our inductive hypothesis. Let k ≥ 1 be arbitrary, and
assume that for any planar embedding of a connected graph (or multigraph, with or without
loops) with k vertices, |V | − |E| + |F | = 2.
Let G be a planar embedding of a connected graph with k + 1 ≥ 2 vertices. Since the graph
is connected and has at least two vertices, it has at least one edge uv, with u 6= v. Let G0 be
the graph we obtain by contracting uv. Then G0 is a planar embedding of a connected graph
(or multigraph, with or without loops) on k vertices, so our inductive hypothesis applies to G0 .
Therefore,
2 = |V (G0 )| − |E(G0 )| + |F (G0 )|
= (|V (G)| − 1) − (|E(G) − 1) + |F (G)|
= |V (G)| − |E(G) + |F (G)|
Contraction of edges has some other very important uses in graph theory. Before looking
at some corollaries of Euler’s Formula, we’ll explain one well-known theorem that involves edge
contraction and planar graphs.
DEFINITION 15.19. Let G be a graph. Then H is a minor of G if we can construct H from
G by deleting or contracting edges, and deleting vertices.
In 1937, Wagner proved a theorem quite similar to Kuratowski’s.
THEOREM 15.20. Wagner’s Theorem A graph is planar if and only if it has no minor iso-
morphic to K5 or K3,3 .
It is possible to prove Wagner’s Theorem as an easy consequence of Kuratowski’s Theorem,
since if G has a subgraph that is a subdivision of K5 or K3,3 then contracting all but one piece of
each subdivided edge gives us a minor that is isomorphic to K5 or K3,3 . Nonetheless, Wagner’s
Theorem is important in its own right, as the first example of the much more recent and very
powerful work by Neil Robertson and Paul Seymour on graph minors.
A family is said to be minor-closed if given any graph in the family, any minor of the graph is
also in the family. Planar graphs are an example of a minor-closed family, since the operations of
deletion (of edges or vertices) and contraction of edges preserve a planar embedding. Robertson
and Seymour proved the remarkable result that if a family of graphs is minor-closed, then the
family can be characterised by a finite set of “forbidden minors.” That is, for any such family
F, there is a finite set L of graphs, such that G ∈ F if and only if no minor of G appears in L.
Wagner’s Theorem tells us that when F is the family of planar graphs, L = {K5 , K3,3 }.
Euler’s Formula has some important corollaries.
COROLLARY 15.21. Let G be a connected graph. Then every planar embedding of G has the
same number of faces.
142 15. Planar graphs
PROOF. We have |V | − |E| + |F | = 2. Since |V | and |E| do not depend on the choice of
embedding, we have |F | = 2 + |E| − |V | cannot depend on the choice of embedding.
Euler’s Formula (and its corollaries) give us a much easier way to prove that K5 and K3,3
are non-planar.
15. Planar graphs 143
EXERCISES 15.26.
1) Use induction to prove an Euler-like formula for planar graphs that have exactly two
connected components.
2) Euler’s formula can be generalised to disconnected graphs, but has an extra variable
for the number of connected components of the graph. Guess what this formula will
be, and use induction to prove your answer.
3) Find and prove a corollary to Euler’s formula for disconnected graphs, similar to Corol-
lary 15.22. (Use your answer to question 2.)
4) For graphs embedded on a torus, |V | − |E| + |F | has a different (but constant) value,
as long as all of the faces “look like” discs. (If you are familiar with topology, the faces
must be embeddable into a plane, rather than looking like a torus. So putting a planar
embedding of a graph down on one side of a torus doesn’t count.) What is this value?
5) Definition. We say that a planar embedding of a graph is self-dual if it is isomorphic
to its planar dual.
Prove that if a planar embedding of the connected graph G is self-dual, then |E| =
2|V | − 2.
6) Definition. The complement of G is the graph with the same vertices as G, but whose
edges are precisely the non-edges of G. (That is, u is adjacent to v in the complement
of G if and only u is not adjacent to v in G.) Therefore, if Gc is the complement of G,
then E(K|V (G)| ) is the disjoint union of E(G) and E(Gc ).
Show that if G is a simple planar graph with at least eleven vertices, then the comple-
ment of G is not planar.
7) Find a planar graph G with |V | = 8 whose complement is also planar.
8) For each of the following sets of conditions, either draw a connected, simple graph G
in the plane that satisfies the conditions, or explain how you know that there isn’t one.
(a) The graph has 15 vertices and 12 edges.
(b) The graph has 10 vertices and 33 edges.
(c) The graph has 5 vertices and 8 edges.
(d) The graph has 6 vertices and 9 edges, and the embedding has 6 faces.
144 15. Planar graphs
Traditionally, map-makers colour the different states so as to ensure that if two states share
a border, they are not coloured with the same colour. (This makes it easier to distinguish the
borders.) If two states simply meet at a corner, then they may be coloured with the same
colour.
Using additional colours used to add to the cost of producing the map. Also, if there are too
many colours they become harder and harder to distinguish amongst. The question is, without
knowing in advance what the map will look like, is there a bound on how many colours will be
required to colour it? If so, what is that bound? In other words, what is the largest number of
colours that might be required to colour some map?
Well over a century ago, mathematicians observed that it never seemed to require more
than 4 colours to colour a map. The map shown above does require 4 colours, since the central
rectangular state (marked with an asterisk) and the three states that surround it must all
receive different colours (each shares a border with each of the others). Unfortunately, they
couldn’t prove that no more would ever be required, although a number of purported proofs
were published and later found to have errors.
Although the bound of 4 eluded many attempts at proof, in 1890 Percy John Heawood
successfully proved that 5 colours suffice to colour any map. (His method was based on an
incorrect proof of the Four Colour Theorem by Kempe, from 1879.) This result is known as
the Five Colour Theorem. Its proof is slightly technical but not difficult, and we will give it in
a moment. First we will give a very short proof that 6 colours suffice.
Notice that if we turn the map into a graph by placing a vertex wherever borders meet,
and an edge wherever there is a border, this problem is equivalent to finding a proper vertex
colouring of the planar dual of this graph. Thus, what we will actually prove is that the vertices
of any planar graph can be properly coloured using 6 (or in the subsequent result, 5) colours.
There is a detail that we are skimming over here: the planar dual could have loops, which
would make it impossible to colour the graph. However, this can only happen if there is a face
of the original map that meets itself along a border, which would never happen in a map. The
planar dual might also have multiedges, but this does not affect the number of colours required
to properly colour the graph, so we can delete any multiedges and assume that we are dealing
with a simple planar graph.
PROPOSITION 15.27. Every planar graph is properly 6-colourable.
PROOF. Towards a contradiction, suppose that there is a planar graph that is not properly
6-colourable. By deleting edges and vertices, we can find a subgraph G that is a 7-critical
planar graph.
By Corollary 15.23, we must have δ(G) ≤ 5 since G is planar. But by Theorem 14.39, we
must have
δ(G) ≥ 7 − 1 = 6
15. Planar graphs 145
since G is 7-critical. This contradiction serves to prove that every planar graph is properly
6-colourable.
THEOREM 15.28. Five Colour Theorem Every planar graph is properly 5-colourable.
PROOF. Towards a contradiction, suppose that there is a planar graph that is not properly
5-colourable. By deleting edges and vertices, we can find a subgraph G that is a 6-critical
planar graph. Since G is planar, Corollary 15.23 tells us that δ(G) ≤ 5. We also know from
Theorem 14.39 that δ(G) ≥ 6−1 = 5 since G is 6-critical. Let v be a vertex of valency δ(G) = 5.
By the definition of a k-critical graph, G \ {v} can be properly 5-coloured. Since G itself
cannot be properly 5-coloured, the neighbours of v must all have been assigned different colours
in the proper 5-colouring of G \ {v}. Let’s label the neighbours of v as v1 , v2 , v3 , v4 , and v5
as they appear clockwise around v. We will call the colour of v1 blue, the colour of v2 purple,
the colour of v3 yellow, and the colour of v4 green, as shown in the picture. Here is a picture
(where, because this text is printed in black-and-white, we have put the first letter of a colour
onto a vertex, instead of actually colouring the vertex).
v1
b
v5 p v2
g y
v4 v3
Consider the subgraph consisting of the vertices coloured blue or yellow (and all edges
between such vertices). If v1 and v3 are not in the same connected component of this subgraph,
then in the connected component that contains v1 , we could interchange the colours yellow
and blue. Since we are doing this to everything in a connected component of the yellow-blue
subgraph, the result will still be a proper colouring, but v1 now has colour yellow, so v can be
coloured with blue. This contradicts the fact that G is 6-critical, so it must be the case that v1
and v3 are in the same connected component of the yellow-blue subgraph. In particular, there
is a walk from v1 to v3 that uses only yellow and blue vertices. By Proposition 12.16, there is
in fact a path from v1 to v3 that uses only yellow and blue vertices.
Similarly, if we consider the subgraph consisting of the vertices coloured purple or green
(and all edges between such vertices), we see that there must be a path from v2 to v4 that uses
only purple or green vertices.
There is no way to draw the yellow-blue path from v1 to v3 and the purple-green path from
v2 to v4 , without the two paths crossing each other. Since the graph is planar, they must cross
each other at a vertex, u. Since u is on the yellow-blue path, it must be coloured either yellow
or blue. Since u is on the purple-green path, it must be coloured either purple or green. It’s
not possible to satisfy both of these conditions on the colour of u. This contradiction serves to
prove that no planar 6-critical graph exists, so every planar graph is properly 5-colourable.
In fact, Appel and Haken proved the Four Colour Theorem in 1976.
THEOREM 15.29. Four Colour Theorem Every planar graph is properly 4-colourable.
Their proof involved considering a very large number of cases – so many that they used
a computer to analyse them all. Although computers are often used in mathematical work
now, this was the first proof that could not reasonably be verified by hand. It was viewed with
suspicion for a long time, but is now generally accepted.
146 15. Planar graphs
One of the methods by which mathematicians attempted unsuccessfully to prove the Four
Colour Theorem seemed particularly promising, and has led to a lot of interesting work in its
own right. We require a couple of definitions to explain the connection.
DEFINITION 15.30. A cubic graph is a graph for which all of the vertices have valency 3.
DEFINITION 15.31. A bridge in a connected graph is an edge whose deletion disconnects the
graph.
THEOREM 15.32. The problem of 4-colouring a planar graph is equivalent to the problem of
3-edge-colouring a cubic graph that has no bridges.
We’ll prove one direction of the equivalence stated in this theorem; the other direction is a
bit more complicated.
PROOF. Suppose that every planar graph can be properly 4-coloured, and that G is a (simple)
bridgeless cubic graph, embedded in the plane. We’ll show that there is a proper 3-edge-
colouring of G. Since G is bridgeless, we don’t run into the problem of a loop in the planar
dual, so the Four Colour Theorem applies to the faces of G. Properly colour the faces of G
with colours red, green yellow, and black. Every edge of G lies between faces of two distinct
colours, by the definition of a proper colouring of a map. Colour the edges of G according to
the following table: if the colours of the faces separated by the edge e are the colours listed in
the left-hand column, then use the colour listed in the right-hand column to colour e.
Face colours Edge colour
green, black dashed
yellow, black dotted
red, black solid
green, yellow solid
green, red dotted
red, yellow dashed
Let v be an arbitrary vertex. We will show that the three edges incident with v must all
receive different colours. Since 3 edges meet at v, three faces also meet at v, and every pair of
these faces share an edge. Thus the three faces that meet at v must all receive different colours.
There are four different cases, depending on which colour is not used for a face at v. We show
what happens in the following picture, using R, G, Y, and B to indicate the face colours, and
colouring the edges according to the table above in each case.
R Y R Y R G Y G
G B B B
In each case, the three edges incident with v are assigned different colours, so this is a
proper 3-edge colouring of G.
This theorem was proven by Tait in 1880; he thought that every cubic graph with no bridges
must be 3-edge-colourable, and thus that he had proven the Four Colour Theorem. In fact,
Vizing’s Theorem tells us that any cubic graph can be 4-edge-coloured, so we would only need
to reduce the number of colours by 1 in order to prove the Four Colour Theorem. The problem
therefore boils down to proving that there are no bridgeless planar cubic graphs that are class
two.
In 1881, Petersen published the Petersen graph that we saw previously in Example 14.42.
15. Planar graphs 147
This graph is cubic and has no bridges, but is not 3-edge-colourable (this can be proved
using a case-by-case analysis). Thus, there exist bridgeless cubic graphs that are class two!
Many people have tried to find other examples, as classifying these could provide a proof of the
Four Colour Theorem.
For many years, Martin Gardner wrote a column in the Scientific American about inter-
esting math problems and puzzles. As the Four Colour Theorem is easy to explain without
technical language, it was a topic he wrote about. When writing about the importance of
bridgeless cubic class two graphs, he decided they needed a more appealing name. Since they
seemed rare and elusive, he called them snarks, after Lewis Carroll’s poem “The Hunting of
the Snark.” The name has stuck.
DEFINITION 15.33. A snark is a bridgeless cubic class two graph.
Two infinite families and a number of individual snarks are known. There is no reason to
believe that these are all of the snarks that exist. By the Four Colour Theorem, we know that
there are no planar snarks; if we could find a direct proof that there are no planar snarks, this
would provide a new proof of the Four Colour Theorem.
EXERCISES 15.34.
1) Prove that if a cubic graph G has a Hamilton cycle, then G is a class one graph.
2) Properly 4-colour the faces of the map given at the start of this section.
3) The map given at the start of this section can be made into a cubic graph, by placing
a vertex everywhere two borders meet (including the coast as a border) and edges
where there are borders. Use the method from the proof of Theorem 15.32 to properly
3-edge-colour this cubic graph, using your 4-colouring of the faces.
4) Prove that a graph G that admits a planar embedding has an Euler tour if and only if
every planar dual of G is bipartite.
5) Prove that if a graph G that admits a planar embedding in which every face is sur-
rounded by exactly 3 edges, G is 3-colourable if and only if it has an Euler tour.
148 15. Planar graphs
SUMMARY:
• Kuratowski’s Theorem, Wagner’s Theorem
• Euler’s Formula
• |E| ≤ 3|V | − 6 for a planar graph
• colouring maps
• the Five Colour Theorem
• the Four Colour Theorem
• Important definitions:
◦ planar graph, planar embedding
◦ face
◦ dual graph, planar dual
◦ subdividing an edge, subdivision of a graph
◦ edge contraction, contracting an edge
◦ minor
◦ cubic graph
◦ bridge
◦ snark
Part III
Design
Theory
Chapter 16
Latin squares
16A. Latin squares and Sudokus
You can think of a Latin square as a Sudoku puzzle that can be of any (square) size, and does
not have the requirement that every value appear in each of the outlined smaller subsquares.
DEFINITION 16.1. A Latin square of order n is an n × n array whose entries are elements of
a set N of cardinality n, with the property that every element of N appears exactly once in
each row and each column.
Notice that in the above example, we placed the numbers 1, 2, 3, and 4 in the first row, in
that order. For each subsequent row, we shifted the numbers one place to the right (wrapping
around). This same technique (placing the numbers from 1 through n across the first row) will
work to construct a Latin square of order n.
So you might think (with reason) that Latin squares aren’t very interesting. However, even
knowing that there is a Latin square of every possible order and they are easy to construct,
there remain some interesting related questions.
Some of these questions are related to Sudokus. If we fill in some entries of a Latin square,
are there conditions on these entries that guarantee that this can be completed to a full Latin
square? Are there conditions under which we can be sure that a partial Latin square has a
unique completion to a full Latin square?
Some of these questions have easy answers that are not what we are really looking for.
For example, if we give you all but one entry of a Latin square (or Sudoku), then if it can be
completed at all, the completion will be unique. However, some interesting mathematical work
has been done on these problems, both for Latin squares and for Sudokus.
There are no known examples in which a Sudoku puzzle with 16 or fewer squares pre-filled,
can be completed uniquely. However, there are tens of thousands of (non-isomorphic) ways of
pre-filling 17 entries of a Sudoku puzzle, that have a unique completion. See Gordon Royle’s
web page http://staffhome.ecm.uwa.edu.au/~00013890/sudokumin.php for a complete list
of those that are known.
Looking only at “non-isomorphic” examples is important, because there are many ways
of creating Latin squares (or Sudoku puzzles) that are essentially the same. The following
operations take a Latin square to another Latin square that is structurally essentially the same:
150
16. Latin squares 151
• Permuting of the symbols used in the set N . For example, changing every 1 to a 2 and
every 2 to a 1.
• Interchanging any two rows.
• Interchanging any two columns.
• Making all of the rows into columns, and all of the columns into rows.
EXERCISES 16.3.
1) Prove that interchanging two rows of a Latin square, yields a Latin square.
2) Complete the following Latin square. Is the completion unique?
1 4
1
3
3) Use the method described at the start of this chapter to create a Latin square of order
5. What 3 of the operations listed above that change a Latin square to an isomorphic
Latin square, are required to arrive at the following result?
5 1 4 2 3
1 3 5 4 2
4 5 2 3 1
2 4 3 1 5
3 2 1 5 4
4) Show there are exactly two different Latin squares of order 3 whose first row is 1, 2, 3.
5) Show there are exactly twelve different Latin squares of order 3 whose entries are the
numbers 1, 2, 3.
[Hint: Use Problem 4.]
6) There are four different Latin squares of order 4 whose first row is 1, 2, 3, 4 and whose
first column is also 1, 2, 3, 4. That is, there are only four ways to complete the following
Latin square:
1 2 3 4
2 − − −
3 − − −
4 − − −
Find all four.
[Hint: Each of the possibilities for the second entry of the second row can be completed in only
one or two ways.]
So here, we are looking at positions in the structure of Latin squares, and trying to ensure
that every ordered pair appears in each position. Notice that since the set N has n elements,
the total number of ordered pairs possible is n2 (there are n choices for the first entry and
n choices for the second entry). A Latin square has n2 positions since it has n rows and n
columns. Thus, if every possible ordered pair appears in each position, then each ordered pair
must appear exactly once.
Once again, Euler was involved in the origins of this problem. In fact, the name Latin
square comes from his terminology. In 1782, he posed the problem of arranging 36 officers into
a 6 × 6 square. The officers come from 6 different regiments (which he denoted with the Latin
characters a, b, c, d, e, and f ) and each holds one of 6 possible ranks (which he denoted with
the Greek characters α, β, γ, δ, ε, and ζ). No two officers from the same regiment hold the
same rank. The question he posed was, is it possible to organise the officers into the square
so that in each row and each column, there is precisely one officer from each regiment, and
precisely one officer of each rank? Since he was using Greek and Roman letters to denote the
classes, he called this a “Graeco-Latin square.” He chose the first step to consist of arranging
the regiments, i.e. for each regiment to set aside 6 positions in the square to be filled with
officers from that regiment. Subsequently, he would try to assign ranks to the officers in these
6 positions. Since the regiments were denoted by Latin characters, he called this first step a
“Latin square.” The Graeco-Latin square of his question is a pair of orthogonal Latin squares
of order 6, since there is to be one officer from each regiment who holds each of the possible
ranks.
Euler could not find a solution to this problem. Since there is also no pair of orthogonal
Latin squares of order 2 (and possibly for other reasons), he conjectured that there is no pair
of orthogonal Latin squares of order n for any n ≡ 2 (mod 4). Although Euler was correct
that there is no pair of orthogonal Latin squares of order 6, his conjecture was not true. In
1959–1960, Bose, Shrikhande, and Parker first found constructions for pairs of orthogonal Latin
squares of orders 22 and 10, and then found a general construction that can produce a pair of
orthogonal Latin squares of order n for every n > 6 with n ≡ 2 (mod 4).
1 2 3 1 2 3
3 1 2 2 3 1
2 3 1 3 1 2
We see that the ordered pairs (1, 1), (2, 2) and (3, 3) appear in the first row; the pairs (3, 2),
(1, 3), and (2, 1) appear in the second row; and the pairs (2, 3), (3, 1), and (1, 2) appear in the
third row. Every possible ordered pair whose entries lie in {1, 2, 3} has appeared.
There is a nice pattern to the squares given in this example. The first follows the general
construction we mentioned at the start of this chapter. For the second, each row has been
shifted one place to the left (rather than to the right) from the one above it. This construction
does actually work for n odd, but never for n even. For example, when n = 4, it would give
1 2 3 4 1 2 3 4
4 1 2 3 2 3 4 1
3 4 1 2 3 4 1 2
2 3 4 1 4 1 2 3
You can see that the ordered pair (1, 1) occurs in two positions: row 1, column 1, and row 3,
column 3. So this pair of Latin squares is definitely not orthogonal. In fact, the first of these
squares has no Latin square that is orthogonal to it. However, there is a pair of orthogonal
16. Latin squares 153
PROOF. We may assume that N = {1, . . . , n}. In each of the Latin squares in S, we can
independently permute the symbols of N . As was noted above, the result will still be a set
of MOLS. We permute the symbols so that the first row of each of the Latin squares has the
entries 1, 2, . . . , n in that order.
Now, if we take any i ∈ N and consider any pair of the Latin squares, the ordered pair (i, i)
appears somewhere in the first row. Consider the first entry of the second row in each square
of S. None of these entries can be 1, since 1 has already appeared in the first column of each
of the Latin squares. No two of the Latin squares can have the same entry j in this position,
since the ordered pair (j, j) has already appeared in the jth position of the first row of this pair
of squares, so can’t appear again in the first position of the second row. So there cannot be
more squares in S, than the n − 1 distinct entries from N \ {1} that could go into this position.
Thus, |S| ≤ n − 1, as claimed.
The next natural question is, is it possible to achieve n − 1 MOLS of order n? We have
already seen that the answer is yes in one very small case, since we found 2 MOLS of order 3.
In fact, there are infinitely many values of n for which there are n − 1 MOLS of order n.
The following result can be generalised to prime powers using some basic field theory that
you should understand if you have taken Math 3400. However, for the purposes of this course,
we will avoid the explicit field theory and prove the result only for primes.
We do require a bit of modular arithmetic for this result. As modular arithmetic will also
be useful for some of our later results, here is a quick review of some key points.
DEFINITION 16.8. Performing calculations modulo n means replacing the result with the
remainder you would get upon dividing that result by n. In other words, if the result of a
computation is n or larger, replace the result by its remainder upon division by n.
NOTATION 16.9. If a and b have the same remainder upon division by n, then we write
a ≡ b (mod n).
There are two key facts from modular arithmetic that we will require. The first is that if
a ≡ b (mod n) and 0 ≤ a, b < n, then we must have a = b.
The other is that if qa ≡ qb (mod n) and n and q have a greatest common divisor of 1, then
a ≡ b (mod n). In the special case where n is prime, as long as q is not a multiple of n then n
and q will always have a greatest common divisor of 1.
THEOREM 16.10. For any prime p, there are p − 1 MOLS of order p.
PROOF. We will use N = {0, . . . , p−1}. In order to ensure that the results of our computations
will be in N , all of the calculations given in this result should be taken modulo p.
The squares will be {S1 , . . . , Sp−1 }. For k ∈ {1, . . . , p},
0 1 ... p−1
k k+1 ... k + (p − 1)
Sk =
2k 2k + 1 ... 2k + (p − 1)
.. .. ..
. . .
(p − 1)k (p − 1)k + 1 . . . (p − 1)k + (p − 1)
We first verify that each Sk is a Latin square. The entries in each row are easily seen to
be distinct. If the entries in the first column are distinct, then we can see that the entries in
every other column will be distinct. Suppose that 0 ≤ i, j ≤ p − 1 and that ik ≡ jk (mod p).
Then since every k ∈ {1, . . . , p − 1} has a greatest common divisor of 1 with p, we see that
i ≡ j (mod p). Since 0 ≤ i, j ≤ p − 1, this forces i = j. So the entries in the first column of Sk
are all distinct. Thus, every Sk is a Latin square.
16. Latin squares 155
Suppose that for some 1 ≤ i, j ≤ p − 1, the squares Si and Sj have the same ordered pair
in two positions: row k1 , column m1 , and row k2 , column m2 . Then by the formulas given for
the entries of each Latin square, we must have
Since (k2 − k1 )i ≡ (k2 − k1 )j (mod p), and 1 ≤ i, j ≤ p − 1, either i = j (so we chose the same
Latin square twice instead of choosing a pair of distinct Latin squares), or k2 − k1 ≡ 0 (mod p).
Since k1 and k2 are row numbers, they are between 1 and p so this forces k1 = k2 . Furthermore,
in this case we must also have m2 − m1 ≡ 0 (mod p), and we see that this also forces m1 = m2 .
Thus, the two positions in which the same ordered pair appeared, were actually the same
position chosen twice.
This shows that {Sk | 1 ≤ k ≤ p − 1} is indeed a set of p − 1 MOLS.
EXAMPLE 16.11. Here are the first 8 of the 10 MOLS of order 11, found using the formula
given in the proof above.
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
1 2 3 4 5 6 7 8 9 10 0 2 3 4 5 6 7 8 9 10 0 1
2 3 4 5 6 7 8 9 10 0 1 4 5 6 7 8 9 10 0 1 2 3
3 4 5 6 7 8 9 10 0 1 2 6 7 8 9 10 0 1 2 3 4 5
4 5 6 7 8 9 10 0 1 2 3 8 9 10 0 1 2 3 4 5 6 7
5 6 7 8 9 10 0 1 2 3 4 10 0 1 2 3 4 5 6 7 8 9
6 7 8 9 10 0 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 0
7 8 9 10 0 1 2 3 4 5 6 3 4 5 6 7 8 9 10 0 1 2
8 9 10 0 1 2 3 4 5 6 7 5 6 7 8 9 10 0 1 2 3 4
9 10 0 1 2 3 4 5 6 7 8 7 8 9 10 0 1 2 3 4 5 6
10 0 1 2 3 4 5 6 7 8 9 9 10 0 1 2 3 4 5 6 7 8
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
3 4 5 6 7 8 9 10 0 1 2 4 5 6 7 8 9 10 0 1 2 3
6 7 8 9 10 0 1 2 3 4 5 8 9 10 0 1 2 3 4 5 6 7
9 10 0 1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 9 10 0
1 2 3 4 5 6 7 8 9 10 0 5 6 7 8 9 10 0 1 2 3 4
4 5 6 7 8 9 10 0 1 2 3 9 10 0 1 2 3 4 5 6 7 8
7 8 9 10 0 1 2 3 4 5 6 2 3 4 5 6 7 8 9 10 0 1
10 0 1 2 3 4 5 6 7 8 9 6 7 8 9 10 0 1 2 3 4 5
2 3 4 5 6 7 8 9 10 0 1 10 0 1 2 3 4 5 6 7 8 9
5 6 7 8 9 10 0 1 2 3 4 3 4 5 6 7 8 9 10 0 1 2
8 9 10 0 1 2 3 4 5 6 7 7 8 9 10 0 1 2 3 4 5 6
156 16. Latin squares
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
5 6 7 8 9 10 0 1 2 3 4 6 7 8 9 10 0 1 2 3 4 5
10 0 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 10 0
4 5 6 7 8 9 10 0 1 2 3 7 8 9 10 0 1 2 3 4 5 6
9 10 0 1 2 3 4 5 6 7 8 2 3 4 5 6 7 8 9 10 0 1
3 4 5 6 7 8 9 10 0 1 2 8 9 10 0 1 2 3 4 5 6 7
8 9 10 0 1 2 3 4 5 6 7 3 4 5 6 7 8 9 10 0 1 2
2 3 4 5 6 7 8 9 10 0 1 9 10 0 1 2 3 4 5 6 7 8
7 8 9 10 0 1 2 3 4 5 6 4 5 6 7 8 9 10 0 1 2 3
1 2 3 4 5 6 7 8 9 10 0 10 0 1 2 3 4 5 6 7 8 9
6 7 8 9 10 0 1 2 3 4 5 5 6 7 8 9 10 0 1 2 3 4
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
7 8 9 10 0 1 2 3 4 5 6 8 9 10 0 1 2 3 4 5 6 7
3 4 5 6 7 8 9 10 0 1 2 5 6 7 8 9 10 0 1 2 3 4
10 0 1 2 3 4 5 6 7 8 9 2 3 4 5 6 7 8 9 10 0 1
6 7 8 9 10 0 1 2 3 4 5 10 0 1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 10 0 1 7 8 9 10 0 1 2 3 4 5 6
9 10 0 1 2 3 4 5 6 7 8 4 5 6 7 8 9 10 0 1 2 3
5 6 7 8 9 10 0 1 2 3 4 1 2 3 4 5 6 7 8 9 10 0
1 2 3 4 5 6 7 8 9 10 0 9 10 0 1 2 3 4 5 6 7 8
8 9 10 0 1 2 3 4 5 6 7 6 7 8 9 10 0 1 2 3 4 5
4 5 6 7 8 9 10 0 1 2 3 3 4 5 6 7 8 9 10 0 1 2
We’ve now seen that it is possible to find p − 1 MOLS of order p for any prime p, and that
the proof can be generalised to prime powers. However, as we’ve already discussed in relation
to Euler’s original problem, there are orders for which the bound of n − 1 MOLS of order n
cannot be attained: in fact, for order 6 it is not possible even to find a pair of orthogonal Latin
squares.
If you are interested in or familiar with some finite geometry, the existence of n − 1 MOLS
of order n is equivalent to the existence of a projective plane of order n. Projective planes,
in turn, are a special kind of design. For an interesting article about some of these rela-
tionships, see https://www.maa.org/sites/default/files/pdf/upload_library/22/Ford/
Lam305-318.pdf. There is also some information about this in Sections 18C and 18D.
EXERCISES 16.12.
1) Find the two MOLS of order 11 that are not included in Example 16.11, but are
orthogonal to each other and to the squares listed there.
2) Find a third Latin square of order 4 that is orthogonal to both of the orthogonal Latin
squares of order 4 that were given earlier in this section.
3) Here is a Latin square of order 8, and some entries for a second Latin square of order
8. Complete the second square so as to obtain a pair of orthogonal Latin squares.
1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8
2 1 4 3 6 5 8 7 3 4 8 5 6
3 4 1 2 7 8 5 6 5 7 2 3
4 3 2 1 8 7 6 5 7 6
5 6 7 8 1 2 3 4 4 1 8
6 5 8 7 2 1 4 3 2 5
7 8 5 6 3 4 1 2 8 1
8 7 6 5 4 3 2 1 6 7 3
16. Latin squares 157
4) Write down the six mutually orthogonal Latin squares S1 , . . . , S6 of order 7 that are
constructed by letting p = 7 in the proof of Theorem 16.10.
EXAMPLE 16.14. The university is striking a student committee on the subject of tutorials.
For each of the 5 Faculties, they ask students to elect one representative who is taking classes
from that faculty. They do not want one student trying to represent more than one faculty.
The candidates are:
• Joseph, who is taking courses in Arts and Science, Fine Arts, Management, and Edu-
cation;
• René, who is taking courses in Health Sciences;
• Claire, who is taking courses in Education and Health Sciences;
• Sandra, who is taking courses in Management, Fine Arts, and Health Sciences;
• Laci, who is taking courses in Education and Health Sciences; and
• Jing, who is taking courses in Education.
Can the committee be filled?
SOLUTION. The answer is no. For the three Faculties of Arts & Science, Fine Arts, and
Management, there are only two possible student representatives: Joseph (who could represent
any of the three), and Sandra (who could represent either Fine Arts or Management). So it is
not possible to elect one student to represent each of the five Faculties, without allowing one of
these students to fill two roles.
In Example 16.14, we observed that we could find a collection of the sets to be represented,
that collectively had fewer possible representatives than there are sets in the collection. It is
easy to see that if this happens, there cannot be a system of distinct representatives for the
sets.
What Philip Hall proved is the converse: unless we have an obstruction of this type, it is
always possible to fine a system of distinct representatives.
THEOREM 16.15. Hall’s Theorem The collection of sets T1 , . . . , Tn has a system of distinct
representatives if and only if for every 1 ≤ k ≤ n, the union of any k of the sets has cardinality
at least k.
This theorem is often referred to as “Hall’s Marriage Theorem,” as one of the problems it
solves can be stated as follows. Suppose we have a collection of men and a collection of women.
Each of the women has a list of men she likes (from the collection). When is it possible to marry
each of the women to a man that she likes? (The context is historical, and the assumption of
the time was that every woman would want to marry a man.)
158 16. Latin squares
We have seen that one of the two implications of Hall’s Theorem is easy to prove. We will
not try to prove the other implication here, but will focus on using the result. Here are some
examples and exercises. For completeness, we provide a proof of Hall’s Theorem at the end of
this chapter.
EXAMPLE 16.16. Let A1 = {a, b, c, d}, A2 = {b, c}, A3 = {b}, A4 = {b, c}. Does this collection
of sets have a system of distinct representatives? If so, find one; if not, explain why.
SOLUTION. The answer is that this collection of sets has no system of distinct representatives,
because the union of three sets A2 , A3 , and A4 has only two elements: b and c.
EXAMPLE 16.17. Let A1 = {a, d}, A2 = {a, c}, A3 = {b, c}, A4 = {c, d}. Does this collection
of sets have a system of distinct representatives? If so, find one; if not, explain why.
SOLUTION. This collection of sets does have a system of distinct representatives: take a for
A1 , c for A2 , b for A3 , and d for A4 . For clarity, we underline the representatives in the following
list of the sets: A1 = {a, d}, A2 = {a, c}, A3 = {b, c}, A4 = {c, d}.
(In fact, it also has another system of distinct representatives: take d for A1 , a for A2 , b for
A3 , and c for A4 : A1 = {a, d}, A2 = {a, c}, A3 = {b, c}, A4 = {c, d}. )
EXERCISES 16.18. For each collection of sets, determine whether or not it has a system of
distinct representatives. If so, find one; if not, explain why.
1) A1 = {x}, A2 = {y, z}, A3 = {x, y}.
2) A1 = {u, v, w, x, y, z}, A2 = {v, w, y}, A3 = {w, x, y}, A4 = {v, w, x, y}, A5 = {v, x, y},
A6 = {v, y}.
3) A1 = {x}, A2 = {y}, A3 = ∅.
4) A1 = {x, z}, A2 = {y}, A3 = {x, y, z}.
5) T1 = {a, b, c, d}, T2 = {a, b, c}, T3 = {a}, T4 = {c}.
6) U1 = {x, y}, U2 = {y, z}, U3 = ∅.
7) V1 = {e, f }, V2 = {e, g}, V3 = {e, h}, V4 = {f, g}, V5 = {h, i}.
8) W1 = {+, −, ×, ÷, 0}, W2 = {+, −, ×}, W3 = {+, ×}, W4 = {×, −}, W5 = {+, −}.
Let’s return to our original question about Latin squares. To answer this, we first give an
important general consequence of Hall’s Theorem.
PROPOSITION 16.19. Suppose T1 , . . . , Tn is a collection of sets each of which contains exactly
r elements. Further suppose that no element appears in more than r of the sets. Then this
collection has a system of distinct representatives.
PROOF. By Hall’s Theorem, we must show that for every 1 ≤ k ≤ n, the union of any k of
the sets T1 , . . . , Tn has cardinality at least k. Let k ∈ {1, . . . , n} be arbitrary, and arbitrarily
choose k of the sets Tj1 , . . . Tjk . If k ≤ r then since each Tji has r elements, their union must
have at least r ≥ k elements, as desired.
Suppose on the other hand that k > r. Amongst the k sets of r elements, a total of kr
elements appear (counting each element every time it appears). Since each element appears
in at most r of the sets, it must be the case that at least k distinct elements appear. This
completes the proof.
THEOREM 16.20. Suppose that m rows of a Latin square of order n have been filled, where
m < n, and that to this point no entry appears more than once in any row or column. Then
another row can be added to the Latin square, maintaining the condition that no entry appears
more than once in any row or column.
PROOF. For 1 ≤ i ≤ n, let Ti be the set of elements that have not yet appeared in column i
(from the entries in the first m rows). So Ti can be thought of as the set of allowable entries
for the ith column of the new row. Notice that each Ti has cardinality n − m (the number
of rows that are still empty). The task of finding a new row all of whose entries are distinct,
and whose ith entry comes from the set Ti of allowable entries for that column, is equivalent
to finding a system of distinct representatives for the sets T1 , . . . , Tn . Thus, we must show that
the collection T1 , . . . , Tn has a system of distinct representatives.
Notice also that every element has appeared once in each of the first m rows, and thus has
appeared in precisely m of the columns. Therefore, there are exactly n − m of the columns in
which it has not yet appeared. In other words, each element appears in exactly n − m of the
sets.
We can now apply Proposition 16.19, with r = n − m to see that our sets do have a system
of distinct representatives. This can be used to form a new row for the Latin square.
COROLLARY 16.21. Suppose that m rows of a Latin square of order n have been filled, where
m < n, and that to this point no entry appears more than once in any row or column. This
structure can always be completed to a Latin square.
PROOF. As long as m < n, we can repeatedly apply Theorem 16.20 to deduce that it is
possible to add a row. Once you actually find a row that can be added (note that the statement
of Hall’s Theorem does not explain how to do this), do so. Eventually this process will result
in a complete square.
Hall’s Theorem can also be used to prove a special case of a result we proved previously,
Theorem 14.17. The special case we can prove with Hall’s Theorem, is the case where every
vertex has the same valency.
THEOREM 16.22. If G is a bipartite graph in which every vertex has the same valency, then
any bipartition sets V1 and V2 have the same cardinality, and there is a set of |V1 | edges that
can be properly coloured with the same colour.
PROOF. Let k be the valency of every vertex, and for some arbitrary bipartition sets V1 and
V2 , let n = |V1 |. By a slight adaptation of Euler’s handshaking lemma, taking into account the
fact that every edge has exactly one of its endvertices in V1 , we see that nk = |E|. By the same
argument, k|V2 | = |E|, which forces |V2 | = n = |V1 |. Since the bipartition was arbitrary, the
first statement follows.
Let V1 = {v1 , . . . , vn }. For every 1 ≤ i ≤ n, let
Ti = {u ∈ V | u ∼ vi }.
A system of distinct representatives for the sets T1 , . . . , Tn will produce n = |V1 | edges that can
be properly coloured with the same colour.
Observe that every set Ti has cardinality k (since this is the valency of every vertex), and
every vertex appears in exactly k of the sets (again because this is the valency of the vertex).
Therefore, by Proposition 16.19, there is a system of distinct representatives for T1 , . . . , Tn .
Hence we can find n = |V1 | edges that can be properly coloured with the same colour.
160 16. Latin squares
COROLLARY 16.23. If G is a bipartite graph in which every vertex has the same valency k,
then its edges can be properly coloured using k colours.
PROOF. Repeat the following step k times: find a set of edges that can be properly coloured.
Colour them with a new colour, and delete them from the graph.
At each stage, Theorem 16.22 tells us providing that every vertex has the same valency, we
can find a set of edges that are properly coloured, one of which is incident with every vertex of
the graph. Since the valency of every vertex is reduced by exactly one when we delete such a
set of edges, at each stage every vertex will have the same valency.
To conclude the chapter, we provide a proof of Hall’s Theorem. As previously noted, one
direction is obvious, so we prove only the other direction.
THEOREM 16.24 Hall’s Theorem. The collection of sets T1 , . . . , Tn has a system of distinct
representatives if for every 1 ≤ k ≤ n, the union of any k of the sets has cardinality at least k.
EXERCISES 16.25.
1) Onyx is doing some research on what people learn from visiting different countries.
She has a set of questions that are to be answered by someone who has visited the
country. Before fully launching the study, she wants to try the questions out on some
of her friends. Since the questions are the same for different countries, she doesn’t want
one person to answer the questions for more than one country, as that could bias the
results. Of her close friends, the following people have visited the following countries:
• England: Adam, Ella, Justin
• Wales: Adam, Justin, Faith, Cayla
• Scotland: Bryant, Justin, Ella
• Ireland: Adam, Bryant, Justin
• Germany: Cayla, Bryant, Justin, Faith, Denise
• France: Ella, Justin, Bryant
• Italy: Adam, Ella, Bryant
Prove that Onyx cannot find seven different friends, each of whom has visited a different
one of these countries.
2) Can the following be completed to a 4 × 4 Latin square? Does Hall’s Theorem apply
to this? If not, why not?
1 2 3 4
4 1 2 3
2 4
3) Show (by example) that it is possible to have a bipartite graph in which the bipartition
sets have the same cardinality k and the valency of every vertex is either 3 or 4, but
no set of k edges can be properly coloured with a single colour.
4) How do you know (without actually finding a completion) that the following can be
completed to a Latin square of order 7 ?
1 2 3 4 5 6 7
2 4 7 6 1 5 3
3 7 4 2 6 1 5
4 6 2 5 3 7 1
a b c d e f
162 16. Latin squares
(b)
u v w x y z
a b c d e f
(c)
u v w x y z
a b c d e f
SUMMARY:
• Hall’s (Marriage) Theorem
• a partial Latin square containing m rows can always be completed.
• Important definitions:
◦ Latin square
◦ orthogonal Latin squares
◦ MOLS (mutually orthogonal Latin squares)
◦ system of distinct representatives (SDR)
Chapter 17
Designs
17A. Balanced Incomplete Block Designs (BIBD)
Suppose you have 7 possible treatments for a disease, that you hope may work well singly or
in combination. You would like to try out every possible combination of them, but the number
of (non-empty) subsets of the set of 7 treatments is 27 − 1 = 127, and you have only 7 mice
in the lab who have this disease. You believe that using a pair of the treatments together will
have a more significant impact than adding more ofthe treatments, but even trying every pair
of treatments on a different mouse would require 72 = 21 mice.
Here is a strategy you could try: give each of the mice 3 of the treatments, according to the
following scheme. For 1 ≤ i ≤ 7, the treatments given to mouse i will be the elements of the
ith set in the following list:
{1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, {2, 5, 7}, {3, 4, 7}, {3, 5, 6}.
Careful perusal of this scheme will show that every pair of treatments is used together on
precisely one of the mice.
DEFINITION 17.1. A design is a pair (V, B), where V is a finite set of points (varieties) and
B is a collection of subsets of V , called blocks of the design.
This definition of a design is too broad to be of much interest without additional constraints,
but a variety of different constraints have been studied.
NOTATION 17.2. We use v to denote |V | and b to denote |B|.
DEFINITION 17.3. A regular design is a design in which every point appears in the same
number of blocks, r.
A uniform design is a design in which every block contains the same number of points, k.
A balanced design is a design in which every pair of points appear together in the same
number of blocks, λ.
EXAMPLE 17.4. In our disease treatments for the mice, we have V = {1, 2, 3, 4, 5, 6, 7},
B = {{1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, {2, 5, 7}, {3, 4, 7}, {3, 5, 6}}.
This is a regular, uniform, balanced design. In this design, v = 7, b = 7, r = 3, k = 3, and
λ = 1.
A regular, uniform, balanced design may be referred to as a (b, v, r, k, λ)-design. So our
disease treatments for the mice formed a (7, 7, 3, 3, 1)-design.
A (b, v, r, k, λ)-design is called complete if v = k. In this case, every block will contain every
point. A (b, v, r, k, λ)-design is called trivial if k = 1. In this case, every block consists of a
single point, and no points appear together in a block. The case k = 2 is also fairly trivial
163
164 17. Designs
v
since in this case the blocks of the design must consist of the 2 pairs of elements of v, each
occurring λ times.
DEFINITION 17.5. A balanced incomplete block design (BIBD) is a regular, uniform, bal-
anced design that is not complete. So it is a (b, v, r, k, λ)-design with k < v.
Although this definition includes the possibility k = 1 or k = 2, these are not interesting
cases, and can usually be ignored.
EXAMPLE 17.6. Here is another BIBD. This one has parameters (20, 16, 5, 4, 1).
{a, b, c, d}, {e, f, g, h}, {i, j, k, l}, {m, n, o, p}, {a, e, i, m}, {a, f, j, n}, {a, g, k, o},
{a, h, l, p}, {b, e, j, o}, {b, f, i, p}, {b, g, l, m}, {b, h, k, n}, {c, e, l, o}, {c, f, k, p},
{c, g, i, n}, {c, h, j, m}, {d, e, k, n}, {d, f, l, m}, {d, g, j, p}, {d, h, i, o}
COMBINATORIAL PROOF. For the first equation, we count the total number of appearances
of each point in the design (including repetitions) in two ways. This is another example of
counting ordered pairs from a cartesian product, as we have discussed previously.
First, there are b blocks, each of which has k points in it. So the answer will be bk.
Second, there are v points, each of which appears r times. So the answer will be vr.
Thus, vr = bk.
For the second equation, we fix a point p, and count the number of points with which p
appears in a block, in two ways.
First, p appears in r blocks. In each of these, there are k − 1 points besides p. So the answer
will be r(k − 1).
Second, for every point p0 ∈ V with p0 6= p, the point p0 appears with p in λ different blocks.
Since there are v − 1 choices for p0 , the answer will be λ(v − 1).
Thus, r(k − 1) = λ(v − 1).
blocks. Now, any edge of the λKv must appear in some Kk (the one coloured with the colour
of that edge). Thus for any pair of points, these vertices are joined by λ edges each of which
appears in some Kk , so these points must appear together in λ of the Kk subgraphs, i.e λ of
the blocks.
Similarly, given a BIBD(v, k, λ), and a multigraph λKv , label the vertices of Kv with the
points of the design. For each block of the design, use a new colour to colour the edges of a Kk
that connects the points in that block. There will be enough uncoloured edges joining these
points, since every pair of points appear together in exactly λ blocks, and there are λ edges
joining the corresponding vertices. In fact, careful counting can show that this will result in
colouring every edge of the multigraph.
This is nicest in the case where λ = 1, when the BIBD corresponds to an edge-colouring of
Kv .
A colouring of the edges of a graph (or multigraph) is often referred to as a decomposition
of the graph (or multigraph), since we can think of the colour classes as sets of edges whose
union forms the entire edge set of the graph.
These provide alternate ways of thinking of designs that may be more intuitive, and are
certainly more visual.
Equations (17.8) and (17.9) lead to numerical conditions on v, k, and λ that must be
satisfied in order for a BIBD(v, k, λ) to exist.
THEOREM 17.11. A BIBD(v, k, λ) cannot exist unless
v−1 v(v − 1)
λ and λ
k−1 k(k − 1)
are integers.
PROOF. By Equation (17.8), every point of the design must appear in
λ(v − 1)/(k − 1)
blocks. Since a point can only appear in an integral number of blocks, the first result follows.
Similarly, By Equation (17.9), there must be
λv(v − 1)
k(k − 1)
blocks in the design. Since there can’t be a fractional number of blocks, the second result
follows.
Although these conditions are necessary to the existence of a BIBD, there is no guaran-
tee that a BIBD with specified parameters will exist, even if those parameters satisfy these
conditions.
EXAMPLE 17.12. The parameters v = 15, k = 5, λ = 2 satisfy the conditions of Theo-
rem 17.11, but there is no BIBD(15, 5, 2).
We will not prove that such a design does not exist as the proof would be tedious and
unenlightening. We will verify that the parameters satisfy the necessary conditions.
We have
λ(v − 1)/(k − 1) = 2(14)/4 = 7,
and
λv(v − 1)
= 2 · 15 · 14/20 = 21.
k(k − 1)
Both of these are integers, so if a design were to exist, each point would appear in 7 blocks,
and there would be 21 blocks. A computer search can verify that no such design exists.
166 17. Designs
EXERCISES 17.13.
1) Show that for any BIBD(v, k, λ), the number of edges of λKv is equal to the number
of edges of Kk times the number of blocks of the design.
2) Suppose there is a BIBD(16, 6, 3). How many blocks does it have? In how many of
those blocks does each point appear?
3) Find an edge-colouring of K5 so that the edges of any colour form a K2 . What are the
parameters of the design to which this corresponds?
4) Here are the blocks of a BIBD with λ = 1:
B1 = {1, 2, 3} B2 = {1, 4, 7} B3 = {1, 5, 9} B4 = {1, 6, 8}
B5 = {4, 5, 6} B6 = {2, 5, 8} B7 = {2, 6, 7} B8 = {2, 4, 9}
B9 = {7, 8, 9} B10 = {3, 6, 9} B11 = {3, 4, 8} B12 = {3, 5, 7}.
EXAMPLE 17.18. The collection {1, 2, 5}, {1, 3, 10}, {1, 7, 15} is a difference collection for n =
19. The differences we attain appear in the following table.
Difference set i j j − i, i − j
D1 1 2 ±1
D1 1 5 ±4
D1 2 5 ±3
D2 1 3 ±2
D2 1 10 ±9
D2 3 10 ±7
D3 1 7 ±6
D3 1 15 ±14 ≡ ±5 (mod 19)
D3 7 15 ±8
Suppose we have a difference collection for v in which each set D1 , . . . , Dm has the same
cardinality. Use Di + ` to denote the set
{d + ` (mod v) | d ∈ Di },
performing the modular arithmetic so as to ensure that Di + ` ⊆ {1, . . . , v}. Then the sets
{Di + ` | 1 ≤ i ≤ m, 0 ≤ ` ≤ v − 1}
form a BIBD(v, |D1 |, 1).
In the above example, taking the 57 sets {1, 2, 5} + `, {1, 3, 10} + `, and {1, 7, 15} + `, where
0 ≤ ` ≤ 18, gives a BIBD(19, 3, 1).
Let’s go over this construction again, thinking about the graph version of the problem. For
simplicity, we’ll look only at the special case λ = 1. So our object is to colour the edges of the
168 17. Designs
complete graph Kv so as to ensure that every colour class is a Kk . If we draw the vertices of
the graph in a circle, and think of the length of an edge as being one more than the number of
vertices between its endvertices as you travel around the circle in whichever direction is shorter,
then for every possible length between 1 and (v − 1)/2, Kv has v edges of that length. (This is
where the trouble arises if v is even: there are only v/2 edges of length v/2.) Furthermore, if
we rotate any edge by one step around the graph (i.e. move both of its endpoints one step in
the same direction) repeatedly, after v such rotations we will have moved the edge onto every
other edge of that length.
These ideas demonstrate that if we can come up with a set of Kk s, such that every edge
length appears in exactly one of the Kk s, then by taking each one of these as well as every
possible rotation of each one of these, as a colour class, we find our desired edge-colouring of
Kv .
A picture is worth a thousand words. The example above is equivalent to edge-colouring
K19 so that every colour class forms a K3 , since v = 19 and k = 3. The edge lengths in K19
are {1, . . . , 9}. We will show three K3 s, such that every edge length from {1, . . . , 9} appears in
exactly one of them. By rotating each of them, giving each rotation a new colour, we obtain 57
K3 s that use every edge of K19 exactly once. We’ve labeled the vertices 1 through 19 to make
the edge lengths easier to work out. This textbook is printed in black-and-white, so, instead
of drawing actual colours on the edges, we will draw solid edges for blue, dotted edges for red,
and dashed edges for green.
19 1 2
18 3
4
17
5
16
6
15
7
14
8
13 9
12 10
11
The solid (or blue) triangle has edges of lengths 1, 3, and 4; the dotted (or red) triangle has
edges of lengths 2, 7, and 9; and the dashed (or green) triangle has edges of lengths 6, 8, and 5.
A design created using this method is called a cyclic design, since a small number of “starter
blocks” are being rotated cyclically (in the graph) to find the remaining blocks of the design.
Notice that for a cyclic design to exist, since each set in the difference collection leads to v
blocks in the final design, b must be a multiple of v.
Although these methods can successfully create designs with many different sets of parame-
ters, they are not nearly enough to allow us to determine the parameters for which BIBDs exist.
We noted previously that the necessary conditions given in Theorem 17.11 are not sufficient
to guarantee the existence of a BIBD with a particular set of parameters. However, there is a
very powerful result along these lines, known as Wilson’s Theorem. It tells us that if we fix k,
there are only finitely many values for v that satisfy the necessary conditions but for which no
BIBD(v, k, 1) exists. Then by Method 1 (repeating blocks), if a BIBD(v, k, 1) exists, then so
does a BIBD(v, k, λ) for any λ. Here is a formal statement of Wilson’s Theorem.
THEOREM 17.19. Wilson’s Theorem Given k, there is an integer v(k) such that for every
v > v(k) that satisfies the three conditions:
• v ∈ Z;
17. Designs 169
3) By adding two more sets to the sets {1, 3, 7} and {1, 6, 13}, you can create a dif-
ference collection for 25 in which each of the sets has 3 elements, and thus a cyclic
BIBD(25, 3, 1). Find two sets to add.
4) Use a difference set to construct a cyclic (11, 11, 5, 5, 2) design.
5) Show that the collection C = {0, 1, 3}, {0, 4, 5}, {0, 4, 7}, {0, 5, 7} is a difference col-
lection for 13. Construct the design and give its parameters.
6) Determine whether the given set D is a difference set for the given value of n.
If it is a difference set, find the parameters of the resulting cyclic BIBD.
(a) D = {1, 2, 4, 10} for n = 13.
(b) D = {2, 4, 5, 6, 10} for n = 21.
7) Prove that in any cyclic design, there exists an integer c such that b = cv, ck(k − 1) =
λ(v − 1), and r = ck. What is the significance of c in terms of the design?
8) Explain why a BIBD with v = 6, b = 10, k = 3, r = 5, and λ = 2 cannot be cyclic.
9) Does the condition you proved in Problem 7 show that a BIBD with v = 61, b = 305,
k = 4, r = 20, and λ = 1 cannot be cyclic?
Since v is the number of points of a design, it must be positive, so dividing through by v does
not reverse the inequality. Thus,
λ(v − 1)
≥ 1.
k(k − 1)
Since k is the number of points in each block, both k and k −1 must be positive (we are ignoring
the trivial case k = 1), so multiplying through by k(k −1) does not reverse the inequality. Thus,
λ(v − 1) ≥ k(k − 1).
PROOF OF FISHER’S INEQUALITY. Suppose we have an arbitrary BIBD(v, k, λ). Let B be
an arbitrary block of this design. For each value of i between 0 and k (inclusive), let ni denote
the number of blocks B 0 6= B such that |B 0 ∩ B| = i. (When we say B 0 6= B we allow the blocks
to be equal as sets if the block B is a repeated block of the design; we are only insisting that
B 0 not be the exact same block of the design as B.)
The following equations involving ni are consequences of easy combinatorial proofs, together
with the definition of ni :
k
X
(17.22) ni = b − 1,
i=0
because both sides of this equation count every block except B.
k
X
(17.23) ini = k(r − 1),
i=0
because both sides of this equation count the number of times elements of B appear in some
other block of the design.
k
X
i(i − 1)ni = k(k − 1)(λ − 1),
i=2
because both sides of this equation count the number of times all of the ordered pairs of elements
from B appear together in some other block of the design. Note that when i = 0 or i = 1, we
have i(i − 1)ni = 0, so in fact
k
X k
X
(17.24) i(i − 1)ni = i(i − 1)ni = k(k − 1)(λ − 1).
i=0 i=2
Adding Equations 17.23 and 17.24 gives
k
X
(17.25) i2 ni = k(k − 1)(λ − 1) + k(r − 1).
i=0
Now comes the part of the proof where something mysterious happens, and for reasons that
are not at all apparent, the result we want will emerge. To fully understand a proof like this
one requires deeper mathematics, but even seeing a proof is useful to convince ourselves that
the result is true.
Take the polynomial in x given by
k
X k
X k
X k
X k
X
(x − i)2 ni = (x2 − 2xi + i2 )ni = x2 ni − 2x ini + i2 ni .
i=0 i=0 i=0 i=0 i=0
Using Equations 17.22, 17.23, and 17.25, we see that this is equal to
x2 (b − 1) − 2xk(r − 1) + k(k − 1)(λ − 1) + k(r − 1).
17. Designs 171
Notice that the format in which this polynomial started was a sum of squares times non-negative
integers, so its value must be non-negative for any x ∈ R.
Using the quadratic formula, ax2 + b0 x + c = 0 has roots at
−b0 ± (b0 )2 − 4ac
p
.
2a
If a quadratic polynomial has two real roots, then there is a region in which its values are
negative. Since this polynomial is non-negative for every x ∈ R, it can have at most one real
root, so (b0 )2 − 4ac ≤ 0. Substituting the actual values from our polynomial, this means that
(−2k(r − 1))2 − 4(b − 1)(k(k − 1)(λ − 1) + k(r − 1)) ≤ 0.
Hence,
k 2 (r − 1)2 − k(b − 1)((k − 1)(λ − 1) + r − 1) ≤ 0.
Let’s rewrite the b in terms of v, r, and k. By Theorem 17.7, we have bk = vr, so
k(b − 1) = bk − k = vr − k.
Hence
k 2 (r − 1)2 − (vr − k)((k − 1)(λ − 1) + r − 1) ≤ 0.
Expand the second term slightly, and multiply both sides of the inequality by v − 1:
k 2 (r − 1)2 (v − 1) − (vr − k)(k − 1)(λ − 1)(v − 1) − (vr − k)(r − 1)(v − 1) ≤ 0.
In the middle expression, we have (λ − 1)(v − 1). By Theorem 17.7, we know that λ =
r(k − 1)/(v − 1), so
r(k − 1) − (v − 1)
λ−1= .
v−1
Therefore,
(λ − 1)(v − 1) = r(k − 1) − v + 1.
Thus, we have
k 2 (r − 1)2 (v − 1) − (vr − k)(k − 1)(rk − r − v + 1) − (vr − k)(r − 1)(v − 1) ≤ 0.
The next step is a lot of work to do by hand. Fortunately there is good math software that can
perform routine tasks like this quickly. If we expand this inequality fully, remarkably it has a
nice factorisation:
r(k − r)(v − k)2 ≤ 0.
Now, r > 0 for any design, and (v − k)2 is a square, so must be nonnegative. Therefore, this
inequality forces k − r ≤ 0, so k ≤ r. Hence r/k ≥ 1. Using Theorem 17.7, we have
b = vr/k ≥ v,
as desired.
Notice that if k is fixed, then only finitely many values of v do not meet Fisher’s Inequality,
so satisfying this inequality did not need to be added as a condition to Wilson’s Theorem.
EXERCISES 17.26.
1) Find values for v, k and λ that satisfy Theorem 17.11 but do not satisfy Fisher’s
Inequality. What can you say about the existence of a design with these parameters?
2) Suppose that λ = 1 and k = 20. How big must v be to satisfy Fisher’s Inequality?
What is the smallest value for v that satisfies all of the necessary conditions?
3) Suppose that λ = 2 and k = 20. How big must v be to satisfy Fisher’s Inequality?
What is the smallest value for v that satisfies all of the necessary conditions?
4) Explain how you know there does not exist a BIBD with v = 46, b = 23, and k = 10.
172 17. Designs
5) Explain how you know there does not exist a BIBD with v = 8, b = 10, k = 4, and
r = 5.
6) If B is a BIBD with v = 22, then what can you say about the value of b?
SUMMARY:
• equivalence between designs and (multi)graph colouring/decomposition problem
• necessary conditions for a BIBD
• construction methods for designs
• Wilson’s Theorem
• Fisher’s Inequality
• Important definitions:
◦ design
◦ blocks
◦ balanced, regular, uniform
◦ BIBD
◦ complementary design
◦ difference collection
• Notation:
◦ b, v, r, k, λ
Chapter 18
More designs
18A. Steiner and Kirkman triple systems
In 1844, W.S.B. Woolhouse, editor of the Ladies and Gentleman’s Diary, posed that publica-
tion’s annual prize problem:
Determine the number of combinations that can be made of n symbols, p
symbols in each, with this limitation, that no combination of q symbols which
may appear in any one of them shall be repeated in any other.
If we take q = 2 then this is essentially a design with k = p and v = n, although it need not
be balanced; some pairs might appear once while other pairs do not appear. Although some
responses were printed in 1845, they were not satisfactory, and in 1846 by Woolhouse repeated
the question for the special case q = 2 and p = 3.
In 1847, Rev. Thomas Kirkman (previously mentioned in Chapter 13) found a complete
solution to this problem in the case where the design is balanced (with λ = 1), and made some
progress towards solving the complete problem. In our terminology, his solution completely
determined the values of v for which a BIBD(v, 3, 1) exists.
Although Steiner did not study triple systems in 1853, he came up with Kirkman’s result
independently, and his work was more broadly disseminated in mathematical circles, so these
structures still carry his name. Despite this, as we shall see in the next section, there is a
related problem that has been named after Kirkman.
DEFINITION 18.1. A triple system is a (regular) balanced design in which every block has
cardinality 3; that is, a BIBD(v, 3, λ).
A Steiner triple system is a triple system with λ = 1.
EXAMPLE 18.2. The cyclic BIBD(19, 3, 1) given in Example 17.18 is a Steiner triple system.
So is the design on 7 points given by
{1, 2, 3}, {1, 4, 5}, {1, 6, 7}, {2, 4, 6}, {2, 5, 7}, {3, 4, 7}, {3, 5, 6}.
NOTATION 18.3. Since the only variable in a Steiner triple system is v, for such a system on
v points we use the notation STS(v).
Triple systems might seem like a very special case of designs, and it would be reasonable to
wonder why we have chosen to single these out for special study and attention. The answer is
that triple systems can be thought of as the smallest interesting examples of designs, since (as
noted previously) if k = 1 there are no pairs in any block and the design is trivial; and if k = 2
then the blocks are simply copies of every possible pair from the set V . So triple systems are a
natural starting point when we are learning about designs: they include examples that are are
not too big or complicated to understand, but are non-trivial.
173
174 18. More designs
If you are now convinced that triple systems are worth studying, you might still be wondering
about Steiner triple systems in particular. We’ve seen that the method of repeating blocks allows
us to construct a triple system for any λ if we first have a triple system with λ = 1, so Steiner
triple systems will be the rarest kind of triple system, and are therefore of particular interest.
In the remainder of this section, we will prove Kirkman’s result characterising the values
of v for which an STS(v) exists. To do this, we will require two results about the existence of
special kinds of Latin squares. There are many connections in combinatorics!
The special kinds of Latin squares we require will be symmetric: that is, the entry in row i
and column j must equal the entry in row j, column i. We will also specify the entries on the
main diagonal: the positions for which the row number and the column number are the same.
LEMMA 18.4. For every odd n, there is a symmetric Latin square of order n with 1, 2, . . . , n
appearing in that order down the main diagonal.
EXAMPLE 18.5. When n = 11, here is the (symmetric) Latin square constructed in the proof
of Lemma 18.4:
1 7 2 8 3 9 4 10 5 11 6
7 2 8 3 9 4 10 5 11 6 1
2 8 3 9 4 10 5 11 6 1 7
8 3 9 4 10 5 11 6 1 7 2
3 9 4 10 5 11 6 1 7 2 8
9 4 10 5 11 6 1 7 2 8 3
4 10 5 11 6 1 7 2 8 3 9
10 5 11 6 1 7 2 8 3 9 4
5 11 6 1 7 2 8 3 9 4 10
11 6 1 7 2 8 3 9 4 10 5
6 1 7 2 8 3 9 4 10 5 11
You can see that this construction will not work when n is even, since the values of some of
the entries given in the formulas would not be integers. In fact, it is not possible to construct
a symmetric Latin square of order n with the entries 1, . . . n down the main diagonal when n is
even. Fortunately, it is possible to construct something similar that will achieve what we will
require.
LEMMA 18.6. For every even n, there is a symmetric Latin square of order n with the values
1, . . . , n/2, 1, . . . , n/2 appearing in that order down the main diagonal.
18. More designs 175
EXAMPLE 18.7. When n = 10, here is the (symmetric) Latin square constructed in the proof
of Lemma 18.6:
1 6 2 7 3 8 4 9 5 10
6 2 7 3 8 4 9 5 10 1
2 7 3 8 4 9 5 10 1 6
7 3 8 4 9 5 10 1 6 2
3 8 4 9 5 10 1 6 2 7
8 4 9 5 10 1 6 2 7 3
4 9 5 10 1 6 2 7 3 8
9 5 10 1 6 2 7 3 8 4
5 10 1 6 2 7 3 8 4 9
10 1 6 2 7 3 8 4 9 5
We are now ready to characterise the values of v for which there is an STS(v).
THEOREM 18.8. An STS(v) exists if and only if v ≡ 1, 3 (mod 6).
PROOF. We prove the two implications separately.
(⇒) Suppose that an STS(v) exists. Then by Theorem 17.11, the values
v−1 v−1 v(v − 1) v(v − 1)
λ = and λ =
k−1 2 k(k − 1) 6
must be integers. The first of these conditions tells us that v must be odd, so must be 1, 3, or
5 (mod 6). If v ≡ 5 (mod 6), then v = 6q + 5 for some q, so
v(v − 1)/6 = (6q + 5)(6q + 4)/6.
Since neither 6q + 5 nor 6q + 4 is a multiple of 3, this will not be an integer. Thus, the second
condition eliminates the possibility v ≡ 5 (mod 6). Therefore, v ≡ 1, 3 (mod 6).
(⇐) Suppose that v ≡ 1, 3 (mod 6). We give separate constructions of Steiner triple systems
on v points, depending on the congruence class of v. We will use the graph theoretic approach
to the problem, so our goal is to find colour classes for the edges of Kv such that each colour
class consists of a K3 .
v ≡ 3 (mod 6) Say v = 6q + 3. Label the vertices of K6q+3 with
u1 , . . . , u2q+1 ; v1 , . . . , v2q+1 ; and w1 , . . . , w2q+1 .
By Lemma 18.4, there is a Latin square of order 2q + 1 in which for every 1 ≤ i ≤ 2q + 1, the
entry i appears in position (i, i).
For 1 ≤ i, j ≤ 2q + 1 with i 6= j, if the entry in position (i, j) of this Latin square is `, then
use new colours to colour the edges that join the vertices in each of the following sets:
{ui , uj , v` }; {vi , vj , w` }; and {wi , wj , u` }.
176 18. More designs
Since the Latin square was symmetric, both position (i, j) and position (j, i) give rise to the
same colour classes. Since we consider every pair i 6= j, every edge of the form ui uj , vi vj , or
wi wj has been coloured (we must have i 6= j for such an edge to exist). Since the square is
Latin, every possible entry ` occurs somewhere in row i, so every edge of the form ui v` , vi w` ,
or wi u` has been coloured, except that we did not look at the entry of the Latin square in the
position (i, j), where i = j. We know that the entry in position (i, i) is i, so the edges of the
form ui vi , vi wi , and wi ui are the only edges that have not yet been coloured.
For each 1 ≤ i ≤ 2q + 1, make the edges joining ui , vi , and wi into one colour class.
Now all of the edges of K6q+3 have been coloured, and each colour class forms a K3 , so we
have constructed a Steiner triple system.
v ≡ 1 (mod 6) Say v = 6q + 1. Label the vertices of K6q+1 with
u1 , . . . , u2q ; v1 , . . . , v2q ; and w1 , . . . , w2q ; x.
By Lemma 18.6, there is a Latin square of order 2q in which for every 1 ≤ i ≤ q, the entry i
appears in position (i, i), and for every q + 1 ≤ i ≤ 2q, i − q appears in position (i, i).
For 1 ≤ i, j ≤ 2q with i 6= j, if the entry in position (i, j) of this Latin square is `, then use
new colours to colour the edges that join the vertices in each of the following sets:
{ui , uj , v` }; {vi , vj , w` }; and {wi , wj , u` }.
Since the Latin square was symmetric, both position (i, j) and position (j, i) give rise to the
same colour classes. Since we consider every pair i 6= j, every edge of the form ui uj , vi vj , or
wi wj has been coloured (we must have i 6= j for such an edge to exist). Since the square is
Latin, every possible entry ` occurs somewhere in row i, so every edge of the form ui v` , vi w` ,
or wi u` has been coloured, except that we did not look at the entry of the Latin square in the
position (i, j), where i = j. We know that the entry in position (i, i) is i (if i ≤ q) or i − q (if
i > q), so the only edges that have not yet been coloured are the edges of the form ui vi , vi wi ,
and wi ui when i ≤ q and ui vi−q , vi wi−q , and wi ui−q when i > q, as well as every edge incident
with x.
For each 1 ≤ i ≤ q, make the edges joining ui , vi , and wi into one colour class. Observe
that amongst the remaining edges that are not incident with x, every vertex other than x is an
endvertex of precisely one of the edges. For example, if i ≥ q then ui vi−q is one of these edges,
while if i < q, wi+q ui is one of these edges, so either way, ui is an endvertex of precisely one of
these edges. Therefore, if for every q + 1 ≤ i ≤ 2q we use new colours to colour the edges that
join the vertices in each of the following sets:
{ui , vi−q , x}; {vi , wi−q , x}; and {wi , ui−q , x},
every edge incident with x (as well as all of our other remaining edges) will have been coloured.
Now all of the edges of K6q+1 have been coloured, and each colour class forms a K3 , so we
have constructed a Steiner triple system.
EXAMPLE 18.9. We will use the method of Theorem 18.8 to construct an STS(15).
We have 15 = 6(2) + 3, so q = 2. The points of our design will be ui , vi , and wi for
1 ≤ i ≤ 2q + 1 = 5, and we will require a symmetric Latin square of order 5. Here is the square:
1 4 2 5 3
4 2 5 3 1
2 5 3 1 4
5 3 1 4 2
3 1 4 2 5
18. More designs 177
After solving Woolhouse’s problem, Kirkman noticed that his construction of an STS(15)
had a very nice property. He challenged others to come up with this solution in the following
problem that he published in the 1850 edition of the Ladies and Gentleman’s Diary:
Fifteen young ladies in a school walk out three abreast for seven days in suc-
cession: it is required to arrange them daily so that no two shall walk twice
abreast.
This has become known as Kirkman’s Schoolgirl Problem.
Although this problem begins by requiring an STS(15), it has the additional requirement
that it must be possible to partition the blocks of this design (the rows of young ladies) into
seven groups (of five blocks each) so that every point (young lady) appears exactly once in each
group. This extra requirement comes from the fact that each of the young ladies must walk out
every day, and can only be in one row in any given day.
DEFINITION 18.10. A BIBD is a resolvable design if the blocks of the design can be parti-
tioned into sets, each of which forms a partition of the point set of the BIBD.
A Kirkman triple system is a resolvable Steiner triple system.
Notice that since each block has 3 points in it, a Kirkman triple system is only possible if
v/3 is an integer. Since a Kirkman triple system is also a Steiner triple system, this means that
we must have v ≡ 3 (mod 6).
There are seven non-isomorphic Kirkman triple systems of order 15.
Kirkman triple systems are also known to exist whenever v ≡ 3 (mod 6).
THEOREM 18.11 (Chaudhury-Wilson, 1971). There is a Kirkman triple system whenever
v ≡ 3 (mod 6).
EXERCISES 18.12.
1) For v = 37, give the Latin square you would have to use in order to construct a Steiner
triple system using the method described in the proof of Theorem 18.8.
2) For v = 39, give the Latin square you would have to use in order to construct a Steiner
triple system using the method described in the proof of Theorem 18.8.
3) For v = 19, use the method described in the proof of Theorem 18.8 to construct a
Steiner triple system.
4) Is the STS(15) constructed in Example 18.9 a Kirkman triple system? Explain your
answer.
[Hint: Think of Pigeonhole-type arguments.]
5) Find all values of λ for which a triple system on six varieties exists. For each such value
of λ, either give a design or explain how to construct it.
[Hint: Begin by showing that if such a design exists, its parameters are (2r, 6, r, 3, 2r/5). Then
determine what values r can take on. Finally use some results about how to construct designs.]
6) Construct an STS(13) design. Show your work.
7) Let v = 21.
178 18. More designs
(a) Write down the Latin square that you would use to construct a Steiner triple sys-
tem (for this value of v) using the method described in the proof of Theorem 18.8.
(b) For the resulting Steiner triple system, which triples contain:
(i) both u1 and u3 ?
(ii) both v2 and w7 ?
(iii) both u3 and w4 ?
(iv) both v5 and w5 ?
(v) w3 ?
8) Let v = 27.
(a) Write down the Latin square that you would use to construct a Steiner triple sys-
tem (for this value of v) using the method described in the proof of Theorem 18.8.
(b) For the resulting Steiner triple system, which triples contain:
(i) both v3 and u8 ?
(ii) both u4 and w4 ?
(iii) both u5 and w4 ?
(iv) v2 ?
(v) both v2 and v5 ?
18B. t-designs
In a BIBD, every pair appears together λ times. In the notation of Woolhouse’s problem, q = 2.
What about larger values of q? (We’ll still only consider the case where every q-set appears an
equal number of times λ, so the design must be balanced, but we will include the more general
situation that λ ≥ 1.)
DEFINITION 18.13. A t-(v, k, λ) design is a design on v points with blocks of cardinality k,
such that every t-subset of V appears in exactly λ blocks.
So far, all we have looked at have been 2-designs.
THEOREM 18.14. In a t-(v, k, λ) design,
k−i v−i
is a divisor of λ for every 0 ≤ i ≤ t − 1.
t−i t−i
PROOF. We first consider the special case where i = 0. Notice that in each of the b blocks,
there are kt subsets of cardinality t that appear in that block. So in the entire design, b kt
subsets of cardinality
t appear.
There exist vt subsets of cardinality t from the v points of V , and each appears in λ blocks,
so in the entire design, λ vt subsets of cardinality t appear.
Thus, b kt = λ vt .
The necessary conditions given in Theorem 18.14 are not sufficient to guarantee the existence
of a BIBD with a particular set of parameters. However, Keevash’s Theorem tells us that if
we fix k and t, there are only finitely many values for v that satisfy the necessary conditions
but for which no t − (v, k, 1) design exists. His proof was probabilistic, so does not produce
constructions for any designs. Here is a formal statement of Keevash’s Theorem.
THEOREM 18.18. Keevash’s Theorem Given k and t, there is an integer v(k, t) such that for
every v > v(k, t) that satisfies the conditions:
• v ∈ Z; and
• for every 0 ≤ i ≤ t − 1,
k−i v−i
is a divisor of λ .
t−i t−i
EXERCISES 18.19.
1) Substituting t = 2 into the equations of Theorem 18.14 doesn’t immediately look like
either of the equations in Theorem 17.7. Use the equations of Theorem 17.7 to deduce
that
k v
is a divisor of λ .
2 2
2) If v = 15 and λ = 1, what are all possible values of k and t ≥ 2 for which t-designs
might exist? Do not include any trivial t−(v, t, 1) design, so you may assume v > k > t.
3) Is it possible for a 3-(16, 6, 1) design to exist? If so, how many blocks will it have?
What will the value of r be?
4) Let B be the (7, 3, 1)-design. Define a new design D as follows, on the varieties
{1, . . . , 8}. It has 14 blocks, of two types:
(I) the blocks of B but with variety 8 added to each; and
(II) the blocks of the complementary design to B.
Prove that this is a Steiner system with t = 3, k = 4 and v =
8. Use the structure
of B and its complement to show that λ = 1; do not check all 83 possible 3-subsets of
{1, . . . , 8}.
5) Define a design as follows. Label the edges of the complete graph K6 ; these will be the
varieties of the design. The blocks are of two types:
• (I) any set of three edges from K6 that can be properly coloured with the same
colour; and
• (II) any set of three edges that form a triangle in K6 .
Determine the parameters of this t-design (including the highest value of t for
which this is a t-design, and justifying each value you determine), and show that this
is a Steiner system.
6) Might a 3 − (20, 5, 8) design exist according to the necessary conditions we have de-
termined (Theorem 18.14)? State the formulas that must be satisfied and show your
work.
18. More designs 181
If you haven’t taken geometry classes in university, you may not know that we can apply
these axioms to finite sets of points, and discover structures that we call finite Euclidean ge-
ometries, or more commonly, affine planes. To avoid some trivial situations, we also require
that the structure has at least three points, and that not all of the points lie on a single line.
The following definition probably seems obvious.
DEFINITION 18.20. We say that two lines are parallel if no point lies on both lines.
We’ve made special note of this definition because in the finite case, “parallel” lines might be
drawn in such a way that they don’t look parallel according to our usual understanding of the
term. Since each line has only a finite number of points on it, two lines L1 and L2 are parallel
as long as none of the points on L1 also lies on L2 , even if in a particular drawing in appears
that these lines will meet if we extend them. In the figure below, lines L1 and L2 have three
points each, and the lines are parallel.
L1
L2
DEFINITION 18.21. A (finite) affine plane consists of a (finite) set of points, a (finite) set of
lines, and an incidence relation between the points and the lines. The incidence relation must
satisfy these Euclidean axioms:
• Any two points lie together on a unique line.
• For any line L, and any point p that does not lie on the line L, there is a unique line
L0 that passes through p and is disjoint from L (that is, it is parallel to L).
• There are at least three points that are not all on the same line.
For the purposes of this book, we will only consider finite affine planes, so assume from now
on that the set of points is finite. It is not very obvious, but the parallel postulate (together
with the final axiom) ensure that it is not possible to have a line that doesn’t contain any
points, so the set of lines will also be finite.
There is a very nice bijective argument that can be used to show that the number of points
on any two lines is equal. Before presenting this, we show that there cannot be a line that
contains only one point.
PROPOSITION 18.22. In a finite affine plane, no line contains only one point.
PROOF. The following diagram may be a helpful visual aid as you read through the proof
below.
182 18. More designs
p
L
q
r
L0 M
Towards a contradiction, suppose that there were a line L that contained only a single point,
p. By the final axiom, there are at least two other points in the finite affine plane, q and r, that
do not both lie on a line with p. By the first axiom, there is a line L0 that contains both p and
q (but by our choice of q and r, L0 does not contain r). Now by the parallel postulate, there is
a line M through r that is parallel to L0 . Furthermore, there is a unique line through p that is
parallel to M . But we know that M is parallel to L0 ; in addition, M does not contain p, so it
is also parallel to L; this is a contradiction.
We can now show that every line contains the same number of points.
PROPOSITION 18.23. In a finite affine plane, if one line contains exactly n points, then every
line contains exactly n points.
PROOF. Again, we begin with a diagram that may be a helpful visual aid to understanding
this proof.
L0
p
q
L
M M0 M 00
Let L be a line that contains exactly n points, and let L0 be any other line of the finite affine
plane. By Proposition 18.22, we know that n > 1, and that L0 also contains at least two points
(we observed above that no line can be empty of points). Since any two points lie together on a
unique line, if L and L0 meet, they meet in a single point, so there is a point p of L that is not
in L0 , and a point q of L0 that is not in L. By the first axiom, there is a line M that contains
the points p and q.
We define a map ψ from points of L to points of L0 as follows. Let ψ(p) = q. For any other
point p0 of L (with p0 6= p), by the parallel postulate there is a unique line M 0 through p0 that
is parallel to M . Since M passes through q and is parallel to M 0 , it is the unique line with
this property, so in particular, L0 cannot be parallel to M 0 . Therefore, M 0 has a unique point
of intersection, say q 0 , with L0 . Define ψ(p0 ) = q 0 . Since M 0 and q 0 were uniquely determined,
the map ψ is well-defined (that is, there is no ambiguity about which point of L0 is found to be
ψ(p0 )).
We claim that ψ is a bijection between the points of L and the points of L0 ; proving this will
complete the proof. We first show that ψ is one-to-one. Suppose that ψ(p1 ) = q1 , ψ(p2 ) = q2 ,
and q1 and q2 are actually the same point of L0 . Then by the definition of ψ, q1 is on some
line M1 that is parallel to M , and contains p1 , while q2 is on some line M2 that is parallel to
M , and contains p2 . Since q1 = q2 , the parallel postulate tells us that we must have M1 = M2 .
This line can only meet L in a single point, so we must have p1 = p2 . Thus, ψ is one-to-one.
To show that ψ is onto, let q 00 be any point of L0 with q 00 6= q (we already know that q has
a pre-image, p). By the parallel postulate, there is a unique line M 00 through q 00 that is parallel
to M . Since M is the unique line through p that is parallel to M 00 , we see that L is not parallel
18. More designs 183
to M 00 , so L must meet M 00 at some point that we will call p00 . Now by the definition of ψ, we
have ψ(p00 ) = q 00 . Thus, q 00 has a pre-image, so ψ is onto.
We refer to the number of points on each line of a finite affine plane as the order of the
plane. We can now figure out how many points are in a finite affine plane of order n.
PROOF. Since the plane has at least three points, not all of which lie on the same line, it has
at least two lines L and L0 that intersect at a point q but are not equal. We know that each of
these lines contains n points. By the parallel postulate, for each of the n − 1 points on L0 that
is not on L, there is a line through that point that is parallel to L. Now, L and these n − 1 lines
that are parallel to L each contain n points, and since they are all parallel (it is an exercise,
see below, to prove that if M is parallel to L and N is parallel to L, then N is parallel to M ),
these points are all distinct. Therefore the plane has at least n2 points.
Consider any point p that is not on L. By the parallel postulate, there must be a line P
through p that is parallel to L. Now, L is the unique line through q that is parallel to P , so in
particular, L0 is not parallel to P . Therefore, L0 and P have a point of intersection, which is
one of the n − 1 points of L0 that is not on L. So P was one of the n − 1 lines that we found
in our first paragraph, meaning that p is one of the n2 points that we found there. Thus, the
plane has exactly n2 points.
You might be wondering by now why we are spending so much time looking at affine planes,
when they are a geometric structure. Despite the fact that they come from geometry, finite
affine planes can be thought of as a special kind of design.
Think of the points of a finite affine plane as points of a design, and the lines as blocks,
with a point being in a block if it is incident with (on) the corresponding line. The first axiom
for the incidence relation guarantees that every pair of points appear together in exactly one
block, so our design has λ = 1. By Proposition 18.23, we see that an affine plane of order n is
uniform, with k = n. By Proposition 18.24, an affine plane of order n has v = n2 . Although
we have not included a proof of this, it can also be shown that this design is regular, so it is in
fact a BIBD(n2 , n, 1).
Using
k v
b =λ
t t
from Theorem 18.14, we see that in a finite affine plane of order n looked at as a design, we
2
have b n2 = n2 , so bn(n − 1) = n2 (n2 − 1). Hence b = n(n + 1). In other words, a finite affine
EXAMPLE 18.25. A finite affine plane of order 3 has 32 = 9 points. Each line has 3 points,
and there are 3(4) = 12 lines. Since each line has three points, every line lies in a parallel class
consisting of three mutually parallel lines, so there are four such parallel classes. We can choose
two of the parallel classes of lines to be “horizontal” and “vertical” lines. The other two classes
will be the two types of diagonal lines. We can’t draw all of these as straight lines, so we have
drawn one parallel class of lines as sets of three points joined by dashes, and the other as sets
of three points joined by dots.
184 18. More designs
The dashes and dots that join sets of points that aren’t in a straight line may not provide
a very clear image of what’s going on; it is probably clearer to think of the diagonal lines
as “wrapping around” when they go off the bottom, top, or either side of the image, and
reappearing on the opposite side.
There is a nice connection between affine planes and mutually orthogonal Latin squares.
THEOREM 18.26. There is an affine plane of order n > 1 if and only if there are n−1 mutually
orthogonal Latin squares of order n.
PROOF. (⇒) An affine plane of order n has n + 1 classes of parallel lines (each class containing
n lines). Consider two of these sets as the horizontal lines and the vertical lines: H1 , . . . , Hn
and V1 , . . . , Vn . Label a point as (i, j) if it lies at the intersection of Vi and Hj . Since each of
the n2 points lies on a vertical line and on a horizontal line, and since every pair of points lie
together on only one line, this is actually a bijection between {1, . . . , n} × {1, . . . , n} and the
points of the affine plane; that is, this provides n2 coordinates that uniquely determine the n2
points of the plane.
Consider any one of the remaining parallel classes of n lines, L1 , . . . , Ln . Observe that every
point of the affine plane lies on precisely one of these lines. Create a Latin square from this
parallel class by placing k in position (i, j) of the Latin square if and only if the point (i, j) of
the affine plane lies on line Lk . Since every line of L1 , . . . , Ln meets every line of H1 , . . . , Hn
exactly once (by the axioms of an affine plane), each entry will appear exactly once in each
row. Similarly, since every line of L1 , . . . , Ln meets every line of V1 , . . . , Vn exactly once (by
the axioms of an affine plane), each entry will appear exactly once in each column. So we have
indeed created a Latin square.
We will now show that the n − 1 Latin squares created by this method (using the n − 1
parallel classes of lines that remain after excluding the ones we have designated as horizontal
and vertical lines) are mutually orthogonal. We’ll do this by considering two arbitrary Latin
squares, L (coming from the lines L1 , . . . , Ln ) and M (coming from the lines M1 , . . . , Mn ). In
position (i, j), the entry of L being i0 means that line Li0 passes through the point (i, j) (which
is the intersection of lines Vi and Hj ). Similarly, this entry of M being j 0 means that line Mj 0
passes through the point (i, j) (which is the intersection of lines Vi and Hj ). Since the lines Li0
and Mj 0 have a unique point of intersection, there cannot be any other positions in which the
entry of L is i0 while the entry of M is j 0 . Thus, each ordered pair (i0 , j 0 ) ∈ {1, . . . , n}×{1, . . . , n}
must appear in exactly one position as the entries of L and M (in that order), and hence L and
M are orthogonal. Since they were arbitrary, we have n − 1 mutually orthogonal Latin squares.
(⇐) The converse of this proof uses the same idea, in the opposite direction. Given n − 1
mutually orthogonal n by n Latin squares, take the n2 coordinate positions to be the points of
our affine plane. Define two parallel classes of lines (each containing n lines) to be the points
whose first coordinate is equal (so all of the points with first coordinate 1 form one line, and
all of the points with first coordinate 2 form a second line, etc.), and the points whose second
coordinate is equal. Each of the n − 1 Latin squares determines an additional parallel class of n
lines: namely, each line consists of the points for which the entry of the Latin square has some
fixed value. Since n > 1, there are clearly at least three points that are not all on the same
18. More designs 185
line. We leave it as an exercise to prove that any two points lie together in a unique line, and
that the parallel postulate is satisfied.
EXAMPLE 18.27. Use the formula from the proof of Theorem 16.10 to construct 6 MOLS of
order 7. Use the construction given in the proof of Theorem 18.26 to construct an affine plane
of order 7 from your squares.
0 1 2 3 4 5 6 0 1 2 3 4 5 6
1 2 3 4 5 6 0 2 3 4 5 6 0 1
2 3 4 5 6 0 1 4 5 6 0 1 2 3
3 4 5 6 0 1 2 6 0 1 2 3 4 5
4 5 6 0 1 2 3 1 2 3 4 5 6 0
5 6 0 1 2 3 4 3 4 5 6 0 1 2
6 0 1 2 3 4 5 6 0 1 2 3 4 5
0 1 2 3 4 5 6 0 1 2 3 4 5 6
3 4 5 6 0 1 2 4 5 6 0 1 2 3
6 0 1 2 3 4 5 1 2 3 4 5 6 0
2 3 4 5 6 0 1 5 6 0 1 2 3 4
5 6 0 1 2 3 4 2 3 4 5 6 0 1
1 2 3 4 5 6 0 6 0 1 2 3 4 5
4 5 6 0 1 2 3 3 4 5 6 0 1 2
0 1 2 3 4 5 6 0 1 2 3 4 5 6
5 6 0 1 2 3 4 6 0 1 2 3 4 5
3 4 5 6 0 1 2 5 6 0 1 2 3 4
1 2 3 4 5 6 0 4 5 6 0 1 2 3
6 0 1 2 3 4 5 3 4 5 6 0 1 2
4 5 6 0 1 2 3 2 3 4 5 6 0 1
2 3 4 5 6 0 1 1 2 3 4 5 6 0
The affine plane will have 72 = 49 points, and we will denote these as ordered pairs (a, b),
where a, b ∈ {1, . . . , 7} and consider them to represent the 49 positions in a 7 by 7 Latin square.
There will be 7(8) = 56 lines, in 8 parallel classes of seven lines each. Although we could draw
the affine plane, you’ve already seen from the affine plane of order 3 that a black-and-white
image all of which is pre-drawn can be more confusing than helpful, so instead we will list each
of the 56 lines as a set of 7 points.
The first parallel class will represent the horizontal rows:
{(1, 1), (2, 1), (3, 1), (4, 1), (5, 1), (6, 1), (7, 1)}, {(1, 2), (2, 2), (3, 2), (4, 2), (5, 2), (6, 2), (7, 2)},
{(1, 3), (2, 3), (3, 3), (4, 3), (5, 3), (6, 3), (7, 3)}, {(1, 4), (2, 4), (3, 4), (4, 4), (5, 4), (6, 4), (7, 4)},
{(1, 5), (2, 5), (3, 5), (4, 5), (5, 5), (6, 5), (7, 5)}, {(1, 6), (2, 6), (3, 6), (4, 6), (5, 6), (6, 6), (7, 6)},
{(1, 7), (2, 7), (3, 7), (4, 7), (5, 7), (6, 7), (7, 7)}
and similarly the second parallel class will represent the vertical rows:
{(1, 1), (1, 2), (1, 3), (1, 4), (1, 5), (1, 6), (1, 7)}, {(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (2, 7)},
{(3, 1), (3, 2), (3, 3), (3, 4), (3, 5), (3, 6), (3, 7)}, {(4, 1), (4, 2), (4, 3), (4, 4), (4, 5), (4, 6), (4, 7)},
{(5, 1), (5, 2), (5, 3), (5, 4), (5, 5), (5, 6), (5, 7)}, {(6, 1), (6, 2), (6, 3), (6, 4), (6, 5), (6, 6), (6, 7)},
{(7, 1), (7, 2), (7, 3), (7, 4), (7, 5), (7, 6), (7, 7)}.
The remaining six parallel classes will each represent one of the Latin squares. In the next
parallel class, the first line consists of all of the points where the entry of the first Latin square
186 18. More designs
is 0; the second consists of all the points where the entry is 1, and so on.
{(1, 1), (7, 2), (6, 3), (5, 4), (4, 5), (3, 6), (2, 7)}, {(2, 1), (1, 2), (7, 3), (6, 4), (5, 5), (4, 6), (3, 7)},
{(3, 1), (2, 2), (1, 3), (7, 4), (6, 5), (5, 6), (4, 7)}, {(4, 1), (3, 2), (2, 3), (1, 4), (7, 5), (6, 6), (5, 7)},
{(5, 1), (4, 2), (3, 3), (2, 4), (1, 5), (7, 6), (6, 7)}, {(6, 1), (5, 2), (4, 3), (3, 4), (2, 5), (1, 6), (7, 7)},
{(7, 1), (6, 2), (5, 3), (4, 4), (3, 5), (2, 6), (1, 7)}.
The next parallel class comes from the second Latin square (reading across, so the second square
is the second one in the first line):
{(1, 1), (6, 2), (4, 3), (2, 4), (7, 5), (5, 6), (3, 7)}, {(2, 1), (7, 2), (5, 3), (3, 4), (1, 5), (6, 6), (4, 7)},
{(3, 1), (1, 2), (6, 3), (4, 4), (2, 5), (7, 6), (5, 7)}, {(4, 1), (2, 2), (7, 3), (5, 4), (3, 5), (1, 6), (6, 7)},
{(5, 1), (3, 2), (1, 3), (6, 4), (4, 5), (2, 6), (7, 7)}, {(6, 1), (4, 2), (2, 3), (7, 4), (5, 5), (3, 6), (1, 7)},
{(7, 1), (5, 2), (3, 3), (1, 4), (6, 5), (4, 6), (2, 7)}.
From the third Latin square:
{(1, 1), (5, 2), (2, 3), (6, 4), (3, 5), (7, 6), (4, 7)}, {(2, 1), (6, 2), (3, 3), (7, 4), (4, 5), (1, 6), (5, 7)},
{(3, 1), (7, 2), (4, 3), (1, 4), (5, 5), (2, 6), (6, 7)}, {(4, 1), (1, 2), (5, 3), (2, 4), (6, 5), (3, 6), (7, 7)},
{(5, 1), (2, 2), (6, 3), (3, 4), (7, 5), (4, 6), (1, 7)}, {(6, 1), (3, 2), (7, 3), (4, 4), (1, 5), (5, 6), (2, 7)},
{(7, 1), (4, 2), (1, 3), (5, 4), (2, 5), (6, 6), (3, 7)}.
From the fourth Latin square:
{(1, 1), (4, 2), (7, 3), (3, 4), (6, 5), (2, 6), (5, 7)}, {(2, 1), (5, 2), (1, 3), (4, 4), (7, 5), (3, 6), (6, 7)},
{(3, 1), (6, 2), (2, 3), (5, 4), (1, 5), (4, 6), (7, 7)}, {(4, 1), (7, 2), (3, 3), (6, 4), (2, 5), (5, 6), (1, 7)},
{(5, 1), (1, 2), (4, 3), (7, 4), (3, 5), (6, 6), (2, 7)}, {(6, 1), (2, 2), (5, 3), (1, 4), (4, 5), (7, 6), (3, 7)},
{(7, 1), (3, 2), (6, 3), (2, 4), (5, 5), (1, 6), (4, 7)}.
From the fifth Latin square:
{(1, 1), (3, 2), (5, 3), (7, 4), (2, 5), (4, 6), (6, 7)}, {(2, 1), (4, 2), (6, 3), (1, 4), (3, 5), (5, 6), (7, 7)},
{(3, 1), (5, 2), (7, 3), (2, 4), (4, 5), (6, 6), (1, 7)}, {(4, 1), (6, 2), (1, 3), (3, 4), (5, 5), (7, 6), (2, 7)},
{(5, 1), (7, 2), (2, 3), (4, 4), (6, 5), (1, 6), (3, 7)}, {(6, 1), (1, 2), (3, 3), (5, 4), (7, 5), (2, 6), (4, 7)},
{(7, 1), (2, 2), (4, 3), (6, 4), (1, 5), (3, 6), (5, 7)}.
And finally,
{(1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)}, {(2, 1), (3, 2), (4, 3), (5, 4), (6, 5), (7, 6), (1, 7)},
{(3, 1), (4, 2), (5, 3), (6, 4), (7, 5), (1, 6), (2, 7)}, {(4, 1), (5, 2), (6, 3), (7, 4), (1, 5), (2, 6), (3, 7)},
{(5, 1), (6, 2), (7, 3), (1, 4), (2, 5), (3, 6), (4, 7)}, {(6, 1), (7, 2), (1, 3), (2, 4), (3, 5), (4, 6), (5, 7)},
{(7, 1), (1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7)}.
comes from the sixth Latin square.
Every affine plane that we know of, has as its order some prime power. We have previously
seen (through the connection to MOLS) that there are affine planes of every prime order. Many
design theorists have tried to answer the question of whether or not the order of an affine plane
must always be a prime power, but the answer is not yet known. In fact, it is not currently
known whether or not there is an affine plane of order 12.
EXERCISES 18.28.
1) Prove that if L, M , and N are lines of an affine plane, and L is parallel to both M and
N , then M is parallel to N .
2) Draw a finite affine plane of order 5. How many lines does it have?
3) How many points, and how many lines are in a finite affine plane of order 19?
4) Prove the omitted details from the proof of Theorem 18.26: that is, that the given
construction yields a structure that satisfies the axioms of an affine plane.
18. More designs 187
5) Draw an affine plane of order 5. Use the construction given in the proof of Theo-
rem 18.26 to produce 4 mutually orthogonal Latin squares of order 5 from your plane.
You have seen this structure already in this course; it is the same as the BIBD(7, 3, 1) that
appeared in Example 17.4.
The following is a very interesting connection. We will not try to present the proof here,
but it is a natural extension of the similar result that we proved for affine planes.
THEOREM 18.31. There is a finite projective plane with n + 1 points on each line, if and only
if there is a complete set of n − 1 MOLS of order n.
EXERCISES 18.32.
1) Is every design with λ = 1 a projective plane? If not, what condition could fail?
2) Which (if any) of the designs we have seen in this course, are projective planes?
3) From our results on MOLS, for what values can you be sure that a projective plane
exists?
4) From our results on MOLS, for what values can you be sure that a projective plane
does not exist?
188 18. More designs
5) What can you determine about the parameters of a design that corresponds to a pro-
jective plane?
SUMMARY:
• construction of Steiner triple systems
• structure of affine planes
• connection between affine planes and MOLS
• Important definitions:
◦ triple system, Steiner triple system
◦ resolvable design, Kirkman triple system
◦ t-design
◦ affine plane
◦ projective plane
• Notation:
◦ STS(v)
Chapter 19
EXAMPLE 19.2. Perhaps the word 0110 tells an automated factory to close the 2nd and 3rd
valves. If we send that message over a wireless network, interference (or some other issue) might
change one of the bits, so the factory receives the message 0010. As a result, the factory closes
only the 3rd valve, and leaves the 2nd valve open. This could have disastrous consequences, so
we would like to do something to avoid such problems.
EXAMPLE 19.3. One simple solution is to append a check-bit to the end of the message. To
do this, we set three rules:
1) We require all messages to have a certain length. (For example, let’s say that all
messages must have exactly 5 bits.)
2) We require all messages to have an even number of 1s.
3) We agree that the final bit of the message (called a “parity check-bit”) will not convey
any information, but will be used only to guarantee that Rule 2 is obeyed. (Thus, each
message we send will have 4 bits of information, plus the check bit.)
In particular, if we wish to send the message 0110 (which already has an even number of 1s),
then we append 0 to the end, and send the message 01100. If, say, the 2nd bit gets changed
in transmission, so the factory receives the message 00100, then the factory’s computer control
can see that this cannot possibly be the intended message, because it has an odd number of 1s.
So the factory can return an error message, asking us to send our instructions again.
Remark 19.4. As a real-life example, bar-code scanners used by cashiers employ the above
principle: if the check-bit is not correct, then the scanner does not beep, so the cashier knows
that the item needs to be rescanned.
EXERCISE 19.5. Under the rules of Example 19.3, which of the following strings are allowed
to be sent as a message?
00110, 10101, 00000, 11011.
189
190 19. Designs and Codes
It is sometimes not feasible to have a message re-sent (for example, if it spends a long time
in transit), so it would be much better to have a system that enables the recipient to correct
transmission errors, not just detect them.
EXAMPLE 19.6 (Triple-repetition code). We could agree to send each bit of our message
3 times. For example, if we want to send the message 0110, then we would transform (or “en-
code”) it as 000111111000. If, say, the 2nd bit gets garbled, so the factory receives 010111111000,
then it knows there was a problem in the transmission of the first 3 bits, because they are not
all the same. Furthermore, since most of these bits are 0, the factory can figure out that we
probably meant to say 000, and correctly decode the entire message as 0110.
The triple-repetition code works, but it is very inefficient, because only one-third of the
bits we send are conveying information — most of the bits are check-bits that were added to
correct the possible errors. After developing some theory, we will see some codes that are able
to correct every single-bit error, but use far fewer check bits.
EXERCISE 19.7. Let Tn be the set of all ternary sequences of length n (so every entry is 0,
1, or 2). Write a recurrence relation for cn , the number of code words from Tn that have no
2 consecutive zeros. Use generating functions to solve your recurrence relation, deriving an
explicit formula for cn .
EXAMPLE 19.9. For clarity, we underline the bits in the second string that differ from the
corresponding bit in the first string:
• d(11111, 11101) = 1
• d(11100, 01001) = 3
• d(10101, 01010) = 5
• d(10101, 10101) = 0
19. Designs and Codes 191
Remark 19.10. When two bits are “transposed” (or “switched”), meaning that a string 01 gets
changed to 10 (or vice-versa), this counts as two bits being different, because a 0 is changed to
a 1 and a 1 is changed to a 0, even though you might think of the switch as being only a single
operation.
EXERCISE 19.11. Compute the Hamming distance between the following pairs of words:
{110, 011}, {000, 010}, {brats, grass}, {11101, 00111}.
Remark 19.14. Part (4) of the Exercise is called the triangle inequality, because it says that
the length of one side of a triangle is always less than (or equal to) the sum of the lengths of
the other two sides.
DEFINITION 19.15. The minimum distance of a code C (denoted d(C)) is the smallest Ham-
ming distance between two distinct elements of C.
EXAMPLE 19.16.
1) d {10, 010, 011} = 1 (because d(010, 011) = 1).
2) d {000, 011, 101, 110} = 2.
3) d {10001, 11111} = 3.
EXERCISE 19.17. What is the minimum distance of each of the following codes?
1) {tell, tale, sale, date}
2) {mon, tue, wed, thu, fri, sat, sun}
3) {00000, 01011, 10101, 10110, 10011}
Making the minimum distance of a code C large is the key to ensuring that it can detect
(or correct) large errors. We will make this idea very explicit in our next two results:
THEOREM 19.18. A code C can detect all possible errors affecting at most k bits if and only
d(C) > k.
192 19. Designs and Codes
Although a minimum distance of k allows us to detect errors that affect at most k bits, it
isn’t sufficient to allow us to correct all such errors. For the purposes of correcting errors, we
require the minimum distance to be twice this large.
THEOREM 19.19. A code C can correct all possible errors affecting at most k bits if and only
d(C) > 2k.
PROOF. We will prove the contrapositive:
there exists an error that is not properly corrected,
d(C) ≤ 2k ⇐⇒
and affects only 2k (or fewer) bits.
(⇐) Suppose there is a situation in which:
• a codeword x is sent,
• a message y is received,
• with only 2k incorrect bits, and
• the receiver decodes the message incorrectly, as some codeword z 6= x.
It must be the case that z is the closest codeword to y (or, at least, it ties for being the closest),
so d(z, y) ≤ d(x, y) = k. Then, using Exercise 19.13, we have
d(x, z) ≤ d(x, y) + d(y, z) = d(x, y) + d(z, y) ≤ k + k = 2k.
So d(C) ≤ 2k (because x, z ∈ C).
(⇒) By assumption, there exist x, y ∈ C with x 6= y, but d(x, y) ≤ 2k. Let r = dd(x, y)/2e ≤
d2k/2e = k. (In other words, r is obtained by rounding d(x, y)/2 up to the nearest integer.)
Now suppose codeword x is sent. Since d(x, y) ≤ 2k, the message y could be received, with
no more than 2k incorrect bits. Construct z from x by changing only r of the d(x, y) bits that
are incorrect in y, so
d(x, z) = r and d(z, y) = d(x, y) − r.
By the definition of r, we have r ≤ d(x, y) ≤ 2r, so
d(z, y) = d(x, y) − r ≤ 2r − r = r ≤ d(x, y).
Therefore z is at least as close to y as x is, so the recipient has no way of knowing that x is the
message that was sent. So it was not possible to correct the 2k (or fewer) errors.
19. Designs and Codes 193
EXERCISES 19.20.
1) Suppose that a code C has a minimum distance of 7.
(a) How many errors can it detect?
(b) How many errors can it correct?
2) Suppose that a code C has a minimum distance of 6.
(a) How many errors can it detect?
(b) How many errors can it correct?
EXERCISE 19.21. Let Bn represent the set of binary strings of length n. Prove that a code
from B10 that has more than 2 words, cannot correct 3 errors. Hypothesize a generalisation of
this result to codes on Bn with more than 2 words.
Multiplying a k-bit string by G yields the same string, with r check bits appended at the end.
We let C be the set of all possible strings Gx, and we call G the generator matrix of this code.
Remark 19.24. In the next section, we will see how to choose G so that the resulting code C
can correct errors.
Although many important error-correcting codes are constructed by other methods, we will
only discuss the ones that come from generator matrices (except in Section 19E).
DEFINITION 19.25. Any code that comes from a generator matrix G (by the General Method
described above) is said to be a binary linear code.
EXAMPLE 19.26. Find all the codewords of the binary linear code C corresponding to the
generator matrix
I 1 0 1
G = 3 , with A = .
A 0 1 1
SOLUTION. We have
1 0 0
0 1 0
I
G= 3 =
A 0 0 1
.
1 0 1
0 1 1
We use this matrix to encode each of the 23 = 8 binary strings of length 3:
0 0 0 0
0 0
0 0
0 1
0 1
G 0 = 0 ,
G 0 = 1 ,
G 1 = 0 ,
G 1 =
1 ,
0 0 1 1 0 0 1 1
0 1 1 0
1 1 1 1
1 0
1 0
1 1
1 1
G 0 =
0 ,
G 0 =
1 ,
G 1 =
0 ,
G 1 =
1 .
0 1 1 0 0 1 1 0
0 1 1 0
Ik
EXERCISE 19.27. Encode each of the given words by using the generating matrix G =
A
associated to the given matrix A.
1 1 0 0
1) A = . Words to encode: 0101, 0010, 1110.
1 0 0 1
1 1 0
1 0 1
2) A =
0
. Words to encode: 110, 011, 111, 000.
1 1
1 1 1
19. Designs and Codes 195
The generator matrix provides an easy way to encode messages for sending, but it is hard
to use it to decode a message that has been received. For that, the next section will introduce
a slightly different matrix. From this new matrix, it will be easy to determine whether the
corresponding code can correct every single-bit error.
NOTATION 19.28. A binary linear code is of type (n, k) (or we say C is an (n, k) code) if its
Ik
generator matrix G = is an n × k matrix. In other words, G encodes messages of length k
A
as codewords of length n, which means that the number of check bits is n − k. We usually use r
to denote the number of check bits, so r = n − k. Then A is an r × k matrix.
EXERCISE 19.29. How many codewords are there in a binary linear code of type (n, k)?
I
DEFINITION 19.30. If G = k is the generator matrix of a binary linear code C, and A is
A
an r × k matrix (so C is of type (k + r, k)), then the parity-check matrix of C is
P = [A Ir ].
EXAMPLE 19.31.
1) For the code C of Example 19.26, the matrix A is 2 × 3, so r = 2. Therefore, the
parity-check matrix of C is
1 0 1 1 0
P = [A Ir ] = [A I2 ] = .
0 1 1 0 1
EXERCISE 19.32. Suppose the generator matrix of the binary linear code C is
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
.
1 0 1 1
1 0 0 1
0 1 1 1
What is the parity-check matrix of this code?
The parity-check matrix can be used to check whether a message we received is a valid
codeword:
PROPOSITION 19.33. A column vector x is a codeword if and only if P x = 0.
196 19. Designs and Codes
PROOF. (⇒) Since x is a codeword, we have x = Gm for some (k-bit) message m. This means
that
Ik m
x = Gm = m= .
A Am
Then
m
P x = [A Ir ] = Am + Am = 2Am ≡ 0 (mod 2).
Am
m
(⇐) Suppose P x = 0. Write x = , where
y
• m is the first k rows of x, and
• y is the remaining r = n − k rows of x.
Then
m
0 = P x = [A Ir ] = Am + y .
y
This means y = −Am = Am (mod 2), so
m m I
x= = = k m = Gm,
y Am A
so x ∈ C.
EXAMPLE 19.34. Here is a simple illustration of Proposition 19.33. For the code in which
every codeword is required to have an even number of 1s, Example 19.31(2) tells us that the
parity-check matrix is P = [1 1 1 1]. Hence, for any 4-bit string x1 x2 x3 x4 , we have
x1
x2
P x = [1 1 1 1]
x3 = [x1 + x2 + x3 + x4 ].
x4
This is 0 (mod 2) if and only if there are an even number of 1s in x, which is what it means to
say that x is a codeword.
EXAMPLE 19.35. Use the parity-check matrix to determine whether each of these words is in
the code C of Example 19.26:
11111, 10101, 00000, 11010.
SOLUTION. From Example 19.31(1), we know that the parity-check matrix of this code is
1 0 1 1 0
P = .
0 1 1 0 1
We have:
1
1
1·1+0·1+1·1+1·1+0·1 1 0
• P 1 =
= 6= , so 11111 is not a codeword.
1 0 · 1 + 1 · 1 + 1 · 1 + 0 · 1 + 1 · 1 1 0
1
1
0
1 · 1 + 0 · 0 + 1 · 1 + 1 · 0 + 0 · 1 0
•P 1 = 0 · 1 + 1 · 0 + 1 · 1 + 0 · 0 + 1 · 1 = 0 , so 10101 is a codeword.
0
1
19. Designs and Codes 197
0
0
1·0+0·0+1·0+1·0+0·0 0
• P 0 =
= , so 00000 is a codeword.
0 0 · 0 + 1 · 0 + 1 · 0 + 0 · 0 + 1 · 0 0
0
1
1
1 · 1 + 0 · 1 + 1 · 0 + 1 · 1 + 0 · 0 0 0
•P 0 = 0 · 1 + 1 · 1 + 1 · 0 + 0 · 1 + 1 · 0 = 1 6= 0 , so 11010 is not a codeword.
1
0
(These answers can be verified by looking at the list the elements of C in the solution of
Example 19.26.)
It is evident from the parity-check matrix whether a code corrects every single-bit error:
THEOREM 19.36. A binary linear code C can correct every single-bit error if and only if the
columns of its parity-check matrix are all distinct and nonzero.
PROOF. Suppose a codeword x is transmitted, but the ith bit gets changed, so a different
string y is received. Let ei be the string that is all 0s, except that the ith bit is 1, so y = x + ei .
Then
P y = P (x + ei ) = P x + P ei = 0 + P ei = P ei
is the ith column of P .
Therefore, if all the columns of P are nonzero, then P y is nonzero, so the receiver can detect
that there was an error. If, in addition, all of the columns of P are distinct, then P y is equal
to the ith column of P , and not equal to any other column, so the receiver can conclude that
the error is in the ith bit. Changing this bit corrects the error.
Conversely, if either the ith column of P is zero, or the ith column is equal to the jth
column, then either P ei = 0 or P ei = P ej . Therefore, when the codeword 00 . . . 0 is sent, and
an error changes the ith bit, resulting in the message ei being received, either P ei = 0, so the
receiver does not detect the error (and erroneously concludes that the message ei is what was
sent), or cannot tell whether the error is in the ith bit (and message 0 was sent) or the error
is in the j th bit (and message ei + ej was sent). In either case, this is a single-bit error that
cannot be corrected.
◦ If P y is not equal to any of the columns of P , then at least two of the bits of y
are wrong. Do not try to correct the error.
EXERCISES 19.39.
1) The parity-check matrix of a certain binary linear code is
1 0 1 0 1 0 0 0
1 0 0 1 0 1 0 0
.
0 1 0 1 0 0 1 0
0 1 1 1 0 0 0 1
(a) Decode each of the following received words: 10001111, 11110000, 01111101.
(b) Find the generator matrix of the code.
2) The parity check matrix of a certain binary linear code is
1 1 0 1 0 0
0 1 1 0 1 0 .
1 0 1 0 0 1
Remark 19.41. Generalizing Example 19.40, a binary linear code is called a Hamming code if
the columns of its parity-check matrix P = [A Ir ] are a list of all the 2r − 1 nonzero binary
vectors of length r (in some order, and without repetition). Every Hamming code can correct all
single-bit errors. Because of their high efficiency, Hamming codes are often used in real-world
applications. But they only correct single-bit errors, so other binary linear codes (which we will
not discuss) need to be used in situations where it is likely that more than one bit is wrong.
EXERCISES 19.42.
1) Explain how to make a binary linear code of type (29, 24) that corrects all single-bit
errors.
2) Explain why it is impossible to find a binary linear code of type (29, 25) that corrects
all single-bit errors.
3) For each k ≤ 20, find the smallest possible number r of check bits in a binary linear
code that will let you send k-bit messages and correct all single-bit errors. (That is,
for each k, we want a code of type (n, k) that corrects all single-bit errors, and we want
r = n − k to be as small as possible.)
4) What is the smallest possible number r of check bits in a binary linear code that will
let you send 100-bit messages and correct all single-bit errors?
PROPOSITION 19.44. A BIBD(v, k, 1) can be used to produce a code that can correct up to
k − 2 errors.
200 19. Designs and Codes
PROOF. Let B and B 0 be blocks of the design, and let b, b0 be the corresponding binary strings
of length k as described at the start of this section. If the blocks have no points in common,
then d(b, b0 ) = 2k. If the blocks have 1 entry in common, then
d(b, b0 ) = 2(k − 1)
(the strings differ in the k − 1 positions corresponding to points that are in B but not in B 0 ,
and in the k − 1 positions corresponding to points that are in B 0 but not in B). Since λ = 1,
the blocks cannot have more than one point in common. So in any case,
d(b, b0 ) ≥ 2(k − 1).
Since b and b0 were arbitrary output words of the code (because B and B 0 were arbitrary blocks),
this means that d(C) ≥ 2(k − 1). This is greater than 2(k − 2), so Theorem 19.19 tells us that
the code can correct any k − 2 errors.
EXERCISES 19.45.
1) If you use a BIBD to create a code whose words have length 10, that is 4-error-
correcting. How many words will your code have?
2) How many errors can be corrected by a code that comes from a BIBD(21, 4, 1)?
3) Recall the 2-(8, 4, 3) design given in Exercise 17.20(2). It is possible to show that this
is also a 3-(8, 4, 1) design; for the purposes of this problem, you may assume that this
is true. If we convert these blocks to binary strings to form code words for a code, how
many errors can this code correct?
19. Designs and Codes 201
SUMMARY:
• Important definitions:
◦ binary string
◦ code, codeword
◦ Hamming distance
◦ minimum distance of a code
◦ detect errors, correct errors
◦ encode, decode
◦ generator matrix
◦ parity-check matrix
◦ binary linear code of type (n, k)
◦ Hamming code
• Notation:
◦ d(x, y)
◦ d(C)
Ik
◦G=
A
◦ P = [A Ir ]
Index
(n, k) code, 195 combination multiple edge,
type (n, k), 195 r-combination, 21 multiedge, 87
combinatorial identity, 29 endvertices, 88
adjacent, 88 Combinatorial Proofs, 29 equivalence relation, 93
affine plane, 181 complement, 166 Erdös-Szekeres Theorem,
arcs, 99 complementary design, 75
166 Euler tour, 109
balanced, 163 complete graph, 90 Euler trail, 109
balanced incomplete block connected, 100 Euler’s Formula, 139
design (BIBD), 164 connected component, 100 Euler’s handshaking
Bell number, 69 contracting the edge uv, lemma, 92
binary linear code, 194 140 for digraphs, 100
binomial coefficients, 24 critical
generalised, 50 k-critical, 130 faces, 135
Binomial Theorem, 24 cubic graph, 146 factorial
Generalised, 51 cycle, 104 n factorial, 19
bipartite, 121 Fibonacci sequence, 39
complete bipartite degree, 88 Fisher’s Inequality, 169
graph, 121 degree sequence, 95 Five Colour Theorem, 145
bipartition, 121 delete the edge e, 90 forest, 105
bits, 189 delete the vertex v, 90 Four Colour Theorem, 145
blocks, 163 derangement, 65
generating function, 49
bridge, 146 design, 163
exponential, 69
Brooks’ Theorem, 131 t-(v, k, λ) design, 178
generator matrix, 193, 194
resolvable, 177
Catalan number, 66 graph, 87
difference collection, 167
choose directed graph, digraph,
difference set, 167
n choose r, 22 99
dual graph, 136
chromatic index, 120 simple, 87
chromatic number, 129 edge Hall’s Theorem, 157
class one graph, 121 subdivided, 137 Hamilton cycle, 113
class two graph, 121 edge chromatic number, Hamilton path, 113
closure, 116 120 Hamming code, 199
code, 190 edge-colourable Hamming distance, 190
codewords, 190 k-edge-colourable, 120
colourable edge-colouring improvement, 123
k-colourable, 129 proper incident with, 88
colouring k-edge-colouring, 120 incident with a face, 136
proper k-colouring, 129 edges, 87 Inclusion-Exclusion, 79
202
Index 203
204
Appendix A
Solutions to
selected exercises
For the reader’s convenience, solutions below are given with full work shown as well as a final
numerical solution. Typically the final numerical solution would not be expected, but makes it
easier to verify an answer that has been reached using a different method.
Solutions to Exercise 2.19. It is sometimes possible to turn a use of the sum rule into a
use of the product rule, or vice versa, so you might get different answers that could be correct.
The answers below represent one natural way of solving each problem.
1) Use both rules. There are two cases that should be added together: the number of
numbers that have two digits, and the number of numbers that have four digits. For
each of these cases, use the product rule to determine how many numbers have this
property. (The answer is 9 · 10 + 9 · 103 = 9, 090. Note that in order for a number to
have exactly k digits, the leading digit cannot be zero.)
2) Use only the product rule. There are 6 outcomes from the red die, and for each of
these, there are 6 outcomes from the yellow die, for a total of 6 · 6 = 36 outcomes.
2 3 2 4
To find the
coefficient
of a b c d , we must take r = 2 and s = 2. This gives us
5 2 3 6 2 4 5 6 2 3 2 4
the term a b c d = a b c d . Thus, the coefficient of a2 b3 c2 d4 is
2 2 2 2
5 6
= 10 · 15 = 150.
2 2
4) Using the Binomial Theorem, we see that
5 4
5 2 4
X 5 r 5−r X 4 s 2 4−s
(a + b) + (a + b ) = a b + a (b ) .
r s
r=0 s=0
Counting
method 2: From the n dogs, choose k who will be the finalists. This can
n
be done in ways. For each of these ways, we can look at the remaining n − k dogs
k
n−k
and choose r − k to be the competitors who will not be finalists, in ways.
r−k
n n−k
Thus, there are a total of ways to choose the dogs.
k r−k
Since both of these solutions
count
the
answer to the same problem, the answers
n r n n−k
must be equal, so we have = .
r k k r−k
3) Since the judges must choose at least one project from each age group, this is equivalent
to a problem in which they are choosing only six projects to advance, with no restric-
tions
on how
they choose
them.
They can choose six projects from three categories in
3 3+6−1 8
= = = 28 ways.
6 6 6
Solutions to Exercise 5.6.
1) COMBINATORIAL PROOF. We will count the number of ways of choosing k items
from a menu that has n different entries (including mac and cheese),
in two ways.
n
Counting method 1: By definition, the answer to this is .
k
Counting method 2: We divide our count into two cases, according to whether or
not we choose any orders of mac and cheese. If we do not choose any mac and cheese,
then we must choose our k items from the other n − 1 entries on the menu. We can
n−1
do this in ways. If we do choose at least one order of mac and cheese,
k
then we must choose the other k − 1 items from amongst the n entries on the menu
(with
mac and cheese still being an option for additional choices). We can do this in
n
ways. By the sum rule, the total number of ways of making our selection
k − 1
n−1 n
is + .
k k−1
Since
bothof these
methods
are counting
the same thing, the answers must be
n n−1 n
equal, so = + .
k k k−1
210 Solutions for Chapter 6
2) PROOF. Base cases: We will have four base cases: n = 12, n = 13, n = 14, and n = 15.
For n = 12, I can get $12 onto my gift card by buying three increments of $4, since
4 + 4 + 4 = 12.
For n = 13, I can get $13 onto my gift card by buying two increments of $4 and
one of $5, since 4 + 4 + 5 = 13.
For n = 14, I can get $14 onto my gift card by buying two increments of $5 and
one of $4, since 4 + 5 + 5 = 14.
For n = 15, I can get $15 onto my gift card by buying three increments of $5, since
5 + 5 + 5 = 12.
Inductive step: We begin with the (strong) inductive hypothesis. Let k ≥ 15 be
arbitrary, and assume that for every integer i with k − 3 ≤ i ≤ k, I can put $i onto my
gift card.
Now I want to deduce that I can put $(k+1) onto my gift card. Using the inductive
hypothesis in the case i = k − 3, I see that add can put $(k − 3) onto my gift card by
buying increments of $4 or $5. Now if I buy one additional increment of $4, I have put
a total of $(k − 3 + 4) = $(k + 1) onto my gift card, as desired. This completes the
proof of the inductive step.
By the (strong) Principle of Mathematical Induction, I can put any amount of
dollars that is at least $12 onto my gift card.
Using the Generalised Binomial Theorem (and substituting y = −x), the coefficient
of x in (1 − x)−5 is
0
0 −5 0 0 5+0−1
(−1) = (−1) (−1) = 1.
0 0
Similarly, the coefficient of x6 in (1 − x)−5 is
6 −5 6 6 5+6−1 10
(−1) = (−1) (−1) = = 210.
6 6 6
Thus, the number of ways in which Trent can roll a total
of 11 on his five dice is the
10
coefficient of x11 in our generating function, which is − 5 = 205. The probability
6
of this happening is 205 divided by the total number of outcomes of his roll, which is
65 = 7776, so 205/7776, or about 2.5%.
C(x) = c0 + c1 x + c2 x2 + c3 x3 + c4 x4 + · · ·
xC(x) = c0 x + c1 x2 + c2 x3 + c3 x4 + · · ·
x2 C(x) = c0 x2 + c1 x3 + c2 x4 + · · ·
so
(1 − x − 2x2 )C(x) = C(x) − xC(x) − 2x2 C(x)
∞
X
= c0 + (c1 − c0 )x + (cn − cn−1 − 2cn−2 )xn
n=2
= c0 + (c1 − c0 )x,
Solutions for Chapter 8 215
since (by the recurrence relation) we have cn − cn−1 − 2cn−2 = 0 for n ≥ 2. Therefore
c0 + (c1 − c0 )x
C(x) = .
1 − x − 2x2
Since c0 = 2 and c1 = 0, this means
2 + (0 − 2)x 2 − 2x
C(x) = 2
= .
1 − x − 2x (1 + x)(1 − 2x)
We now use partial fractions. Write
2 − 2x A B A(1 − 2x) + B(1 + x) (A + B) + (B − 2A)x
= + = = .
(1 + x)(1 − 2x) 1 + x 1 − 2x (1 + x)(1 − 2x) (1 + x)(1 − 2x)
Equating the coefficients in the numerators yields the equations
2 = A + B, −2 = B − 2A.
B = 2A − 2 = 2(4/3) − 2 = 2/3.
So
2 − 2x A B 4/3 2/3 4 1 2 1
C(x) = = + = + = + .
(1 + x)(1 − 2x) 1 + x 1 − 2x 1 + x 1 − 2x 3 1+x 3 1 − 2x
From the generalized binomial theorem, we know:
1
• The coefficient of xn in = (1 + x)−1 is
1+x
−1 n 1+n−1 n n
= (−1) = (−1) = (−1)n .
n n n
1
• The coefficient of xn in = (1 − 2x)−1 is
1 − 2x
−1 1+n−1 n n
(−2)n = (−1)n (−2)n = (−1)2n 2 = 2n .
n n n
4 2
Therefore cn , the coefficient of xn in C(x), is (−1)n + · 2n .
3 3
∞
X
3) Let E(x) = en xn be the generating function of {en }. Then
n=0
E(x) = e0 + e1 x + e2 x2 + e3 x3 + e4 x4 + · · ·
xE(x) = e0 x + e1 x2 + e2 x3 + e3 x4 + · · ·
1
= 1 + x + x2 + x3 + x4 + · · ·
1−x
216 Solutions for Chapter 9
so
2 1
(1 − 3x)E(x) + = E(x) − 3xE(x) + 2 ·
1−x 1−x
∞
X
= (e0 + 2) + (en − 3en−1 + 2)xn
n=1
= (e0 + 2),
since (by the recurrence relation) we have en − 3en−1 + 2 = 0 for n ≥ 1. Therefore
2
(e0 + 2) −
E(x) = 1 − x = (e0 + 2)(1 − x) − 2 .
1 − 3x (1 − 3x)(1 − x)
Since e0 = 2, this means
(2 + 2)(1 − x) − 2 2 − 4x
E(x) = = .
(1 − 3x)(1 − x) (1 − 3x)(1 − x)
We now use partial fractions. Write
2 − 4x A B A(1 − x) + B(1 − 3x) (A + B) − (A + 3B)x
= + = = .
(1 − 3x)(1 − x) 1 − 3x 1 − x (1 − 3x)(1 − x) (1 − 3x)(1 − x)
Equating the coefficients in the numerators yields the equations
2 = A + B, −4 = −(A + 3B).
Adding the two equations tells us that 2 − 4 = (A + B) − (A + 3B) = −2B, so B = 1.
Then the first equation tells us that A = 2 − B = 2 − 1 = 1. So
2 − 4x A B 1 1
E(x) = = + = + .
(1 − 3x)(1 − x) 1 − 3x 1 − x 1 − 3x 1 − x
From the generalized binomial theorem, we know that the coefficient of xn in
1 1
is 3n , and the coefficient of xn in is 1. Therefore en , the coefficient of xn
1 − 3x 1−x
in E(x), is 3n + 1.
and
k
X k
X
ck+1 = ci c(k+1)−i−1 = ci ck−i .
i=0 i=0
Using the inductive hypothesis, we have cj > 0 for every j such that 0 ≤ j ≤ k. Putting
these together gives that ck+1 is a sum of k + 1 terms where each term has the form
ci ck−i with 0 ≤ i ≤ k. Since 0 ≤ k − i ≤ k, we see that ci > 0 and ck−i > 0 so that
ci ck−i > 0. Hence
k
X
ck+1 = ci ck−i > 0.
i=0
4
X 3 3 3 3 3
B4 = B4−k = B3 + B2 + B1 + B0
k−1 0 1 2 3
k=1
= 5 + 3(2) + 3(1) + 1(1) = 15.
3) If bi = (i + 1)!/2 then the expanded exponential generating function for this sequence
is
∞ ∞ ∞
X bi xi X (i + 1)!xi X
= = (i + 1)xi /2.
i! 2i!
i=0 i=0 i=0
This is
∞ ∞
!
1X 1 X 1
(i + 1)xi = (i + 1)xi = .
2 2 2(1 − x)2
i=0 i=0
218 Solutions for Chapter 10
Base case: n = 1. Let G be a digraph with no loops or multiarcs, and with only
−
one vertex v1 . Then there are no arcs in G, so |A(G)| = 0 = d+
G (v1 ) = dG (v1 ). So the
desired conclusion is true when n = 1.
We now establish the induction step. Assume that n ≥ 1, the formula holds
for every digraph with n vertices that has no loops or multiarcs, and G is a digraph
with n + 1 vertices that has no loops or multiarcs.
Pick an arbitrary vertex u of G. Let
• N + be the set of outneighbours of u, and N − the set of inneighbours of u,
• s = |N + | = d+
G (u) be the number of arcs that begin at u,
• t = |N − | = d−
G (u) be the number of arcs that end at u, and
• G0 be the digraph obtained from G by deleting u and its s + t incident arcs.
Note that:
• V (G0 ) = V (G) r {u}, so G0 has n vertices.
• |A(G0 )| = |A(G)| − s − t.
• For v ∈ V (G0 ) r N − , we have d+ +
G0 (v) = dG (v) (because the outneighbours of v
0
in G are exactly the same as the outneighbours of v in G).
• For v ∈ N − , we have d+ +
G0 (v) = dG (v) − 1 (because u is counted as an outneighbour
of v in G, but it is not in G0 so it cannot be counted as an outneighbour in G0 ).
• Similar statements hold with N − replaced by N + .
Hence
X X X X
d+
G (v) = d+
G (v) + d+
G (v) + d+
G (v)
v∈V (G) v∈V (G)r(N − ∪{u}) v∈N − v∈{u}
X X
d+ d+ +
= G0 (v) + G0 (v) + 1 + dG (u)
v∈V (G)r(N − ∪{u}) v∈N −
X X
= d+ d+ + |N − | + d+ (u)
G0 (v) + G0 (v) G
v∈V (G)rN − ∪{u} v∈N −
X
= d+
G0 (v) + t + s
v∈V (G0 )
0
= |A(G )| + s + t (induction hypothesis)
= |A(G)|.
222 Solutions for Chapter 12
X
Similarly, we can argue that d− G(v) = |A(G)|. This completes the inductive
v∈V (G)
step and the proof.
3) Beginning at the top and working clockwise, label the vertices of the digraph a, b, c,
d, and e. Then:
• a has outvalency 2 and invalency 1;
• b has outvalency 2 and invalency 2;
• c has outvalency 1 and invalency 2;
• d has outvalency 2 and invalency 2;
• e has outvalency 1 and invalency 1.
Solutions to Exercise 12.12.
2) This graph is connected. To see this, note that (a, j, g, v, e, d, i, h, c, b) is a walk
that passes through all of the vertices of G, so it is possible to walk from a to
any other vertex. Therefore, the connected component that contains a is V (G) =
{a, b, c, d, e, f, g, h, i, j}.
There are several walks of length 5 from a to f . One example is (a, g, a, j, g, f ).
3) This graph is not connected. To see this, note that there are no edges from any
vertex in {a, d, e, f, g, j} to any vertex in {b, c, h, i}. Indeed the connected component
that contains a is {a, d, e, f, g, j}. (The walk (a, d, e, f, g, j) passes through all of these
vertices, but none of these vertices are adjacent to any vertex that is not in the subset.)
There are several walks of length 3 from a to d. One example is (a, d, a, d).
Solutions to Exercise 12.22.
1) (a) There are many paths of length 3. One example is (a, b, c, h).
(b) (b, c, f, b) is a cycle of length 3.
(c) (a, b, c, b) is neither a path nor a cycle. It is not a path because the vertices are
not all distinct. (Namely, the vertex b occurs twice.) It is not a cycle, because the
first vertex (namely, a) is not the same as the final vertex (namely, b).
3) PROOF. Let (u = u1 , u2 , . . . , v = uk , u) be a cycle of G in which u and v appear as
consecutive vertices. Let G0 = G \ {uv}.
Let x and y be arbitrary vertices of G. Since G is connected, there is a walk
(x = x1 , x2 , . . . , xm = y) from x to y in G. If this walk does not contain the edge uv
then it is also a walk in G0 . If it does contain the edge uv, then we can find some i
with 1 ≤ i ≤ m − 1 such that either xi = u and xi+1 = v, or vice versa. For every
such i, replace the pair (xi , xi+1 ) in the walk by either (u = u1 , u2 , . . . , v = uk ) or
(v = uk , uk−1 , . . . , u = u1 ) (as appropriate, depending on whether xi = u or xi = v).
The result is a walk from x to y that does not use the edge uv, so is in G0 . Since x
and y were arbitrary vertices of G0 , for any two vertices x and y of G0 there is an x − y
walk, so by definition, G0 is connected.
v has only one neighbour, so such a walk would not be a path. Thus, the x − y path
cannot use the vertex v, so it is still a path in T \ {v}. Since x and y were arbitrary
vertices, this shows that T \ {v} is connected. This completes the proof.
5 10,13
4 12
8,14 1,6,15
9 7
3 2,11
f c
e d
(b) The closure of this graph is K6 . We can easily see from this that the graph does
have a Hamilton cycle.
(To see that the closure is K6 , observe that every vertex of the graph has valency
at least 2. Thus, the two vertices of valency 4 can be joined to each of their non-
neighbours. After doing so, every vertex has valency at least 3, so every vertex
can be joined to every other vertex.)
3) Let G be the graph that has been shown here. Using the notation of Theorem 13.9, let
S = {a, f }. Then |S| = 2, but G \ S has 3 connected components: {b, e}, {c, h}, and
{d, g}. Since 3 > 2, G cannot have a Hamilton cycle.
224 Solutions for Chapter 14
Therefore
R(k, `) ≤ R(k − 1, `) + R(k, ` − 1) (Proposition 14.23)
(k−1)+` k+(`−1)
≤2 +2 (induction hypothesis)
= 2k+`−1 + 2k+`−1
= 2 · 2k+`−1
= 2k+` .
This completes the proof.
4) Since R(k, `) ≤ R(k 0 , `0 ) whenever k ≤ k 0 and ` ≤ `0 , we have
40 ≤ R(3, 10) ≤ R(3, 11).
Also, since R(k, `) ≤ R(k − 1, `) + R(k, ` − 1) and R(2, `) = `, we have
R(3, 11) ≤ R(3 − 1, 11) + R(3, 11 − 1) = R(2, 11) + R(3, 10) ≤ 11 + 42 = 53.
So 40 ≤ R(3, 11) ≤ 53.
Solutions to Exercise 14.26.
2) PROOF. We assume that N − 1 > (c + 1)(n − 1). Consider an arbitrary colouring of
the edges of KN with c + 1 colours. Fix a vertex v. Since v has N − 1 > (n − 1)(c + 1)
incident edges, the generalised pigeonhole principle tells us that there must be some
set of at least n edges incident with v that are all coloured with the same colour, say
colour i. Look at the induced subgraph of KN on the n other endpoints of these edges.
If any edge xy of this induced subgraph is coloured with colour i, then all of the edges
of the triangle {v, x, y} have been coloured with colour i, so KN has a monochromatic
triangle.
If on the other hand no edge of the induced subgraph has been coloured with
colour i, then the induced subgraph is a Kn whose edges have been coloured with
the remaining c colours. By hypothesis, every such colouring has a monochromatic
triangle. This completes the proof.
However, R(2, 2, 3) = 3. This is because if any edges are dotted or dashed, then there
is a dotted or dashed K2 ; if no edges are dotted or dashed, then every edge is solid, so
there is a solid K3 .
2) We will show that R(2, 4) = 4. We are looking for the smallest value of n such that
every edge-colouring of Kn with dashed or solid lines has either a dashed K2 or a solid
K4 . The following colouring shows that R(2, 4) > 3;
However, in K4 if any edge is dashed, then there is a dashed K2 , while if no edges are
dashed, then there is a solid K4 .
226 Solutions for Chapter 15
4) The fact that G contains a subgraph isomorphic to Ki implies that χ(G) ≥ i. The fact
that ∆(G) ≤ j implies that
χ(G) ≤ ∆(G) + 1 ≤ j + 1.
So 4 ≤ i ≤ χ(G) ≤ j + 1 ≤ 7.
If we also know that G is connected and is neither a complete graph nor a cycle of
odd length, then χ(G) ≤ ∆(G) ≤ j, so 4 ≤ i ≤ χ(G) ≤ j ≤ 6 in this case.
3) We show a planar embedding of the graph, the planar embedding with the dual graph
shown in grey, and the dual graph.
Solutions for Chapter 15 227
b b
e f e f
c a c a
d d
4) The value for |V | − |E| + |F | on a torus is 0. For example, consider the graph on 5
vertices consisting of two cycles of length 3 that meet at a vertex. Draw this graph
on a torus so that one cycle goes through the hole in the middle, and one cycle goes
around the outside edge of the torus. This embedding has one face, since the first cycle
cuts the torus into something resembling a cylinder, and the second cuts the cylinder
into a rectangle. There are 5 vertices and 6 edges, so |V | − |E| + |F | = 5 − 6 + 1 = 0,
as claimed.
R Y R Y
Y G R B G
R
R Y G
1 2 3 4
2 1 4 3
3 4 1 2
4 3 2 1
3)
1 2 3 4 5 6 7 8
3 4 1 2 7 8 5 6
5 6 7 8 1 2 3 4
7 8 5 6 3 4 1 2
4 3 2 1 8 7 6 5
2 1 4 3 6 5 8 7
8 7 6 5 4 3 2 1
6 5 8 7 2 1 4 3
• The last entry in the third row must also be 1, because 2, 3, and 4 already appear
in either the third row or the last column.
So we cannot complete the third row: we are forced to have 1 appear twice in this row,
but that is not allowed.
Hall’s Marriage Theorem does not apply to this situation, because, as we have
seen, the third column and fourth column must both choose their entry for the third
row from the set {1}, which has less than two elements. (Theorem 16.20 does not apply
because the partial Latin square does not consist only of complete rows — it has a row
that has only been partially filled in.)
1) Many examples are possible (but they may be hard to find). For example, let
v = 16, k = 6, and λ = 1.
Then
v−1 16 − 1
λ =1· =3
k−1 6−1
and
v(v − 1) 16(16 − 1) 16 · 15
λ =1· = =8
k(k − 1) 6(6 − 1) 6·5
λ(v − 1) 1 · (16 − 1)
r= = = 3.
k−1 6−1
vr 16 · 3
b= = = 8.
k 6
1 · (v − 1) ≥ 20(20 − 1) = 380,
and
are integers, the conditions in Theorem 17.11 are also satisfied. So 381 is the smallest
value for v that satisfies all three conditions.
232 Solutions for Chapter 18
blocks that have two w-girls and a u-girl. But this means that we have six w-girls,
which is not allowed.
Therefore, there is no way to partition the blocks of this design into seven groups
of five blocks so that every girl appears exactly once in each group.
Since the consecutive factors in the denominator include 6 and 9, if they also include
another multiple of 3 then the numerator must be divisible by 34 , but it is not. This
leaves the possibility that t = 4 so the factors in the denominator are 4 through 11,
but this is divisible by 52 , which the numerator is not. Thus, k = 7 is not possible.
If k = 6 then
14 · 13 · 12 · 11 · 10 · 9 · 8 · 7 · 6
y= .
(15 − t)(14 − t)(13 − t)(12 − t)(11 − t)(10 − t)(9 − t)(8 − t)(7 − t)
1) PROOF. Let L, M , and N be lines of an affine plane such that L is parallel to both
M and N ; that is, no point lies on both L and M or on both L and N . Let p be
an arbitrary point on M . Since L and M are parallel, p does not lie on L. By the
parallel postulate, there is a unique line through p that is parallel to L; this line is M .
Therefore N cannot contain p. Since our choice of p on M was arbitrary, no point of
M can also lie on N , so M and N are parallel.
3) A finite affine plane of order 19 has 192 = 361 points, and 19(19 + 1) = 380 lines.
5) Without colours it is difficult to effectively draw this plane so that the parallel classes
can be clearly seen. We will use solid vertical lines; solid horizontal lines; dashed lines;
dotted lines; solid grey lines; and dotted grey lines to represent the six parallel classes
of lines, but some of these may be difficult to distinguish. Note that the lines that
are neither vertical nor horizontal will “turn corners” or zig-zag to join their sets of 5
points.
We obtain the following 4 MOLS of order 5 from this affine plane, by using the vertical
and horizontal lines to create the coordinates. To make things easier to see, we will
have the positions in the Latin squares correspond visually to the positions in the 5 by
5 array of points that we have drawn, so the top-left entry in the Latin squares will
come from the top-left point of the array, etc. We will number the lines in each parallel
class so as to ensure that the entries in the top row of each square are 1, 2, 3, 4, and
5, in that order. The first square corresponds to the dashed lines; the second to the
dotted lines; the third to the solid grey lines, and the fourth to the dashed grey lines.
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
2 3 4 5 1 5 1 2 3 4 3 4 5 1 2 4 5 1 2 3
3 4 5 1 2 4 5 1 2 3 5 1 2 3 4 2 3 4 5 1
4 5 1 2 3 3 4 5 1 2 2 3 4 5 1 5 1 2 3 4
5 1 2 3 4 2 3 4 5 1 4 5 1 2 3 3 4 5 1 2
Solutions for Chapter 19 237
4) PROOF. Let x, y, and z be words of the same length. Suppose that d(x, z) = k, so
that x and z differ in k positions. Suppose that d(x, y) = i, so y differs from x in i
positions. If i ≥ k then since d(y, z) ≥ 0 by part (1), we have d(x, z) ≤ d(x, y) + d(y, z).
Otherwise, there must be some list of at least k − i positions in which x differs from z
but does not differ from y. In each of these positions, since y has the same entry as x,
y must have a different entry than z. Therefore d(y, z) ≥ k − i. Now d(x, y) + d(y, z) ≥
i + k − i = k = d(x, z), completing the proof.