Discrete Mathematics and Combinatory
Discrete Mathematics and Combinatory
1
Chapter One
Elementary counting principles
1.1 Basic counting principles
There are two basic counting principles. The first one involves addition and the
Second one multiplication.
Sum Rule: If no two events can occur at the same time, then one of the events can occur
in:
+ + +・ ・ ・ ways.
Product Rule: If the events occur one after the other, then all the events can occur in the
order indicated in:
・ ・ . . . ways.
(b) The number n of ways a student can choose just one of the courses is:
n=3+4+2=9
Example 2. A guest at a formal dinner has 4 entrée choices and 2 dessert
choices. If a guest’s dinner is entirely determined by these two choices, then
how many different dinner choices are there?
Solution. The total number of dinner choices is given by the product
4 · 2 = 8.
2
The reason can be seen in the tree Figure each of the 4 branches connected
to the root of that tree splits off into 2 more branches. The 8 different ends represent
the various possible pairings of an entrée choice with a dessert Choice.
Permutation
3
Example2: How many ways are there to elect a class president, vice president, and
treasurer from a class of 30 students? We assume that each student is eligible for any
office and that no student may be elected to more than one office.
Exercise
1: Find , , , ,
2: In how many ways can we select three students from a group of five students to
stand in line for a picture? In how many ways can we arrange all five of these students
in a line for a picture?
3: Suppose that there are eight runners in a race. The winner receives a gold medal, the
second place finisher receives a silver medal, and the third-place finisher receives a
bronze medal. How many different ways are there to award these medals, if all possible
outcomes of the race can occur and there are no ties?
4
Permutation with repetitions
The number of permutations of a multiset, that is, a set of objects some of which
are alike. We will let
, ,...,
Denote the number of permutations of n objects of which are alike, are alike, . . .,
are alike. The general formula follows:
Example. Find the number m of seven-letter words that can be formed using the letters
of the word “BENZENE.”
Solution: the number of permutations of 7 objects of which 3 are alike (the three E’s ,
and 2 are alike (the two N’s . By Theorem
,
,
Combination
Let S be a set with n elements. A combination of these n elements taken r at a time is any
selection of r of the elements where order does not count. Such a selection is called an
r-combination; it is simply a subset of S with r elements. The number of such
combinations will be denoted by , .
Before we give the general formula for C(n, r), we consider a special case.
5
Solution: The farmer can choose the cows in , ways, the pigs in , ways, and
the hens in , ways.
Thus the number m of choices follows:
・ ・
Example2: How many different committees of three students can be formed from a
group of four students?
Solution: here the order does not mater then by our formula
,
Exercise:
1. How many ways are there to select five players from a 10-member tennis team to
make a trip to a match at another school?
2. How many committees of five people can be chosen from 20 men and 12 women?
(a) if exactly three men must be on each committee ?
(b) if at least four women must be on each committee ?
n B n n B n B
In other words, to find the number n(A B) of elements in the union of A and B, we add
n(A) and n(B) and then we subtract n(A B) that is, we “include” n(A) and n(B), and
we “exclude” n(A B). This follows from the fact that, when we add n(A) and n(B), we
have counted the elements of (A B) twice. The above principle holds for any number
of sets. We first state it for three sets.
Example1: Find the number of mathematics students at a college taking at least one of
the languages
French, German, and Russian, given the following data:
65 study French, 20 study French and German,
45 study German, 25 study French and Russian,
42 study Russian, 8 study all three languages.
15 study German and Russian,
We want to find n(F G R) where F, G, and R denote the sets of students studying
French, German, and Russian, respectively.
6
n(F G R)= n(F ) + n(G) + n(R) n(F G) n(F R) n(G R) + n(F G R)
= 65 + 45 + 42 20 25 15 + 8 = 100
Example2: How many students are there in a discrete math class if 15 students are
computer science majors, 7 are math majors, and 3 are double majors in math and
computer science?
Solution: Let A denote the subset of computer science majors in the class, and
B denote the math majors.
Then , . So by the principle of
Inclusion/exclusion there are 15 + 7 3 = 19 students in the class.
Solution: Let be the set of those integers divisible by 3 and be the set of
those integers divisible by 5.
a) Notice that the elements are 2 = 2(1), 4 = 2(2), . . . , 114 = 2(57). Thus card (A) =
57.
b) There are = 19 integers in A divisible by 3. They are {6,12,18, . . . ,114}.
Notice that 114 = 6(19). Thus .
c) There are = 11 integers in A divisible by 5. They are {10,20,30, . . . ,110}.
Notice that 110 = 10(11). Thus card ( ) = 11
d, e, f, g (left as an exercise)
Binomial theorem
The binomial theorem gives the coefficients of the expansion of powers of binomial expressions.
A binomial expression is simply the sum of two terms, such as x + y. (The terms can be products
of constants and variables)
7
Example1: What is the expansion of ?
= .
Solution: =
=
=
=
Exercise:
1. What is the expansion of a)
b)
8
COROLLARY 2 Let n be a positive integer. Then
Proof: When we use the binomial theorem with x = −1 and y = 1, we see that
Prove it.
The numbers are called binomial coefficients, since they appear as the coefficients in
the expansion of .
9
This triangle is known as Pascal’s triangle. Pascal’s identity shows that when two
adjacent binomial coefficients in this triangle are added, the binomial coefficient in the
next row between these two coefficients is produced.
10
Chapter two
Elementary probability theory
Sample space and events
The set S of all possible outcomes of a given experiment is called the sample space. A
particular outcome, i.e., an element in S, is called a sample point. An event A is a set of
outcomes or, in other words, a subset of the sample space S. In particular, the set {a}
consisting of a single sample point a ∈ S is called an elementary event.
Furthermore, the empty set and S itself are subsets of S and so and S are also events;
is sometimes called the impossible event or the null event. Since an event is a set, we
can combine events to form new events using the various set operations:
(i) A B is the event that occurs iff A occurs or B occurs (or both).
(ii) A B is the event that occurs iff A occurs and B occurs.
(iii) Ac, the complement of A is the event that occurs iff A does not occur.
Two events A and B are called mutually exclusive if they are disjoint, that is, if A B = .
In other words, A and B are mutually exclusive iff they cannot occur simultaneously.
Three or more events are mutually exclusive if every two of them are mutually
exclusive.
EXAMPLE
(a) Experiment: Toss a coin three times and observe the sequence of heads (H) and
tails (T ) that appears.
The sample space consists of the following eight elements:
(b) Experiment: Toss a (six-sided) die, and observe the number (of dots) that appear on
top.
The sample space S consists of the six possible numbers, that is, S = {1, 2, 3, 4, 5, 6}.
Let A be the event that an even number appears,
B that an odd number appears, and
C that a prime number appears.
That is, let
A = {2, 4, 6}, B= {1, 3, 5}, C= {2, 3, 5}
Then
A C = {2, 3, 4, 5, 6} is the event that an even or a prime number occurs.
B C = {3, 5} is the event that an odd prime number occurs.
= {1, 4, 6} is the event that a prime number does not occur.
Note that A and B are mutually exclusive: A B = . In other words, an even number
and an odd number cannot occur simultaneously.
11
Example2: Toss a pair of dice and record the two numbers on the top.
There are six possible numbers, 1, 2, . . . , 6, on each die. Thus S consists of the pairs of
numbers from 1 to 6, and hence n(S) = 36. Figure below shows these 36 pairs of
numbers arranged in an array where the rows are labelled by the first die and the
columns by the second die.
Let be the event that the sum of the two numbers is 6, and
Let B be the event that the largest of the two numbers is 4. That is,
, , , , , , , , , ,
, , , , , , , , , , , , ,
Then the event “A and B” consists of those pairs of integers whose sum is and whose
largest number is 4 or, in other words, the intersection of A and B. Thus
, , ,
Similarly, “A or B,” the sum is or the largest is , shaded in Fig(b). is the union .
Probability of an event
DEFINITION: Let S be a finite sample space. The outcomes in S are said to be equally
likely if , ∈ , . , ∈ ,
DEFINITION: If the outcomes in a finite sample space S are all equally likely, then the
probability of an event E is given by
Example1: If two fair coins are tossed, then what is the probability of getting exactly one
head?
Solution: the sample space of possible outcomes is given by the set of ordered pairs
S = {TT, TH, HT, HH}.
12
Since the coins are assumed to be fair, each of the outcomes in S is equally likely. The
event of getting exactly one head is given by
E = {TH, HT}.
Hence,
Theorem: The probability function P defined on the class of all events in a finite
probability space has the following properties:
For every event , ≤ ≤ .
.
If events A and B are mutually exclusive, then .
If p is the probability that an event E occurs, then s the probability that E does
not occur.
(That is, if we hit a target of the times, then we miss the target of the
times.)
Theorem (Addition Principle): For any events A and B,
EXAMPLE 1. Suppose a student is selected at random from 100 students where 30 are
taking mathematics, 20 are taking chemistry, and 10 are taking mathematics and
chemistry. Find the probability p that the student is taking mathematics or chemistry.
Let M = {students taking mathematics} and C = {students taking chemistry}. Since the
space is equiprobable,
13
Conditional probability
EXAMPLE: What is the conditional probability that a family with two children has two
boys, given they have at least one boy? Assume that each of the possibilities BB, BG, GB,
and GG is equally likely, where B represents a boy and G represents a girl. (Note that BG
represents a family with an older boy and a younger girl while GB represents a family
with an older girl and a younger boy.)
Solution: Let E be the event that a family with two children has two boys, and let F be
the event that a family with two children has at least one boy. It follows that
E = {BB},
F = {BB, BG, GB}, and
E F = {BB}. Because the four possibilities are equally likely, it follows that
.We conclude that
Example2; A pair of fair dice is tossed. The sample space S consists of the 36 ordered
pairs (a, b), where a and b can be any of the integers from 1 to 6.Thus the probability of
any point is 1 36. Find the probability that one of the dice is 2 if the sum is 6. That is,
find P(A\E) where:
, , , , , , , , , , , ,
A = {(2, 1), (2, 2), (2, 3), (2, 4), (2, 5), (2, 6), (1, 2), (3, 2), (4, 2), (5, 2), (6, 2)}
Since S consists of 36 elements,
P(A) = 11/36.
Exercises
1) A couple has two children; the sample space is S = {bb, bg, gb, gg} with probability ¼
for each point. Find the probability p that both children are boys if it is known that:
(i) at least one of the children is a boy; (ii) the older child is a boy.
14
2) At a company picnic, the children played a soccer game, after which one player’s
name was randomly drawn to win a prize. The winning team in the soccer game
consists of 7 girls and 4 boys, and the losing team consists of 5 girls and 6 boys. Given
that the prize winner is a boy, what is the probability that he also comes from the
winning soccer team?
Independent events
DEFINITION. Two events E and F in a sample space S are said to be independent if
If E and F are independent events and P(E | F ) is defined, then P(E | F ) = P(E), In this
case, knowing that event F has occurred does not affect the likelihood of event E
occurring.
Example; Assume, that each of the four ways a family can have two children is equally
likely. Are the events E, that a family with two children has two boys, and F, that a family
with two children has at least one boy, independent?
Solution: Because E = {BB}, we have p(E) = 1/4. And F={BB,BG,GB} we have p(F) = 3/4
and that p(E F) = 1/4.
But p(E)p(F) =
Therefore p(E F) p(E)p(F),
so the events E and F are not independent.
Exercise
1. Are the events E, that a family with three children has children of both sexes, and F,
that this family has at most one boy, independent? Assume that the eight ways a
family can have three children are equally likely.
2. Consider the experiment of tossing two dice in sequence. Let E be the event that the
first die shows a value of at most 3, let F be the event that the values on the two dice
are the same, and let G be the event that the sum of the values on the two dice is 5.
A) Are E and F independent?
B) Are E and G independent?
Definition 7.3: Let S be a finite probability space. By the space of n independent repeated
trials, we mean the probability space Sn consisting of ordered n-tuples of elements of S,
with the probability of an n-tuple defined to be the product of the probabilities of its
components:
, ,..., ...
15
P(a) = 1/2, P(b) = 1/3, and P(c) = 1/6. If the horses race twice, then the sample space
of the two repeated trials is
S2 = {aa, ab, ac, ba, bb, bc, ca, cb, cc}
For notational convenience, we have written ac for the ordered pair (a, c). The
probability of each point in S2 is
P aa P a P a , P ba , P ca
P ab P a P b , P bb , P cb
P ac P a P c , P bc , P cc
Thus the probability of c winning the first race and a winning the second race is
P(ca) = 1/12 .
Now consider an experiment with only two outcomes. Independent repeated trials of
such an experiment are called Bernoulli trials. The term independent trials mean that
the outcome of any trial does not depend on the previous outcomes (such as tossing a
coin). We will call one of the outcomes success and the other outcome failure.
Example. A fair coin is tossed 6 times; call heads a success. This is a binomial
experiment with n = 6 and p = q = 12
.
(a) The probability that exactly two heads occurs (i.e., k = 2) is
16
Random variables and expectation
Definition: A random variable X is a rule that assigns a numerical value to each outcome
in a sample space S.
We shall let RX denote the set of numbers assigned by a random variable X, and we shall
refer to RX as the range space.
EXAMPLE .A pair of fair dice is tossed. The sample space S consists of the 36 ordered
pairs (a, b) where a and b can be any of the integers from 1 to 6.
Let X assign to each point in S the sum of the numbers; then X is a random variable with
range space
RX = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}
Let Y assign to each point the maximum of the two numbers; then Y is a random
variable with range space
RY = {1, 2, 3, 4, 5, 6}
The set of ordered pairs (x1, f (x1)), (x2, f (x2)), . . . , (xt, f (xt )) is called the distribution of
the random variable X. This function f has the following two properties:
17
Expectation of a Random Variable
Let X be a random variable on a probability space S = {s1, s2, . . . , sm } Then the mean or
expectation of X is denoted and defined by:
EXAMPLE. Let X be the random variable which assigns the sum to the toss of a pair of
dice. Note n(S) = 36, and Rx = {2, 3, . . . , 12}. Using Theorem, we obtain the distribution
f of X as follows:
Exercise; suppose a fair coin is tossed six times. The number of heads which can occur
then find the distribution and expectation
18
Chapter three
Recurrence relations
We begin with some examples.
Example. Consider the following sequence which begins with the number 3 and for
which each of the following terms is found by multiplying the previous term by 2:
3, 6, 12, 24, 48, . . .
It can be defined recursively by:
, ≥ , ≥
th
Clearly, the formula gives us the n term of the sequence without calculating any
previous term.
(2) The equation a0 = 3, which gives a specific value to one of the terms, is called an
initial condition.
(3) The function an = 3(2n), which gives a formula for an as a function of n, not of
previous terms, is called a solution of the recurrence relation.
(4) There may be many sequences which satisfy a given recurrence relation. For
example, each of the following is a solution of the recurrence relation .
1, 2, 4, 8, 16, . . . and 7, 14, 28, 56, 112, . . .
All such solutions form the so-called general solution of the recurrence relation.
(5) On the other hand, there may be only a unique solution to a recurrence relation
which also satisfies given initial conditions. For example, the initial condition a0 = 3
uniquely yields the solution 3, 6, 12, 24, . . . of the recurrence relation
Where C1,C2, . . . , Ck are constants with Ck = 0, and f (n) is a function of n. The meanings
of the names linear and constant coefficients follow:
Linear: There are no powers or products of the aj ’s.
Constant coefficients: The C1C2, . . . ,Ck are constants (do not depend on n).
19
If f (n) = 0, then the relation is also said to be homogeneous.
(b) an = 2an 1 an 2 + n2
The product an 1an 2 means the recurrence relation is not linear. Given initial
conditions a1 = 1, a2 = 2, we can still find the next few elements of the sequence:
a3 = 2(2)(1) + 32 = 13, a4 = 2(13)(2) + 42 = 68
(c) an = nan 1 + 3an 2
This is a homogeneous linear second-order recurrence relation but it does not have
constant coefficients because the coefficient of an 1 is n, not a constant. Given initial
conditions a1 = 1, a2 = 2, the next few elements of the sequence follow:
a3 = 3(2) + 3(1) = 9, a4 = 4(9) + 3(2) = 42
(d) an = 2an 1 + 5an 2 – 6 an 3
This is a homogeneous linear third-order recurrence relation with constant coefficients.
Thus we need three, not two, initial conditions to yield a unique solution of the
recurrence relation. Suppose we are given the initial conditions a1 = 1, a2 = 2, a3 = 1.
Then, the next few elements of the sequence follow:
a4 = 2(1) + 5(2) 6(1) = 6, a5 = 2(2) + 5(1) 6(6) 37
a6 = 2(1) + 5(6) 6( 37) = 254
a = sa +ta or a sa ta =0
where s and t are constants with t _= 0.We associate the following quadratic polynomial
with the above recurrence relation:
x x sx t
20
We emphasize that the constants and may be uniquely computed using initial
conditions.
=2 +3
The general solution is obtained by first finding its characteristic polynomial and
its roots r1 and r2:
Since the roots are distinct, we can use Theorem to obtain the general solution:
Thus any values for c1 and c2 will give a solution to the recurrence relation.
Suppose we are also given the initial conditions a0 = 1, a1 = 2. Using the recurrence
relation we can compute the next few terms of the sequence:
The unique solution is obtained by finding c1 and c2 using the initial conditions.
Specifically:
Thus the following is the unique solution of the given recurrence relation with the given
initial conditions a0 = 1, a1 = 2:
Suppose the roots of the characteristic polynomial are not distinct. Then we have the
following result.
Theorem: Suppose the characteristic polynomial of the recurrence
relation
=s +t
21
has only one root r0. Then the general solution of the recurrence relation follows, where
c1 and c2 are arbitrary constants:
=6 9
Thus any values for c1and c2 will give a solution to the recurrence relation.
Suppose we are also given the initial conditions a1 = 3, a2 = 27. Using the recurrence
relation we can
compute the next few terms of the sequence:
The unique solution is obtained by finding c1 and c2 using the initial conditions.
Specifically:
Solving the system of the two equations in the unknown’s c1 and c2 yields:
c1 1 and c2 = 2
Thus the following is the unique solution of the recurrence relation with the given initial
conditions:
Consider now a general linear homogeneous kth - order recurrence relation with
constant coefficients which has the form
= c1 + c2 c3 +...+ck = ci (*)
22
Where C1, C2, . . . , Ck are constants with Ck 0. The characteristic polynomial _(x) of the
recurrence relation follows:
= C1 C2 C3 ・ ・ ・ Ck ci
The roots of are called the characteristic roots of the recurrence relation.
The following remarks are in order.
Remark 1: If p(n)and q(n) are solutions of (*), then any linear combination
of p(n) and q(n) is also a solution. (This is not true if the recurrence relation is non
homogeneous.)
c1rn + c2nrn + c3n2rn +・ ・ ・+cmnm 1rn = (c1 + c2n + c3n2 +・ ・ ・+cmnm 1)rn
is also a solution.
= 11 39 45
= 11 + 39x 45 = (x – 3)2(x – 5)
Thus any values for c1, c2, c3 will give a solution to the recurrence relation.
Suppose we are also given the initial conditions a0 = 5, a1 = 11, a3 = 25. Using the
recurrence relation we can compute the next few terms of the sequence:
The unique solution is obtained by finding c1, c2 & c3 using the initial conditions.
Specifically:
23
For n = 0 and a0 = 5, we get: c1 + c3 = 5
For n = 1 and a2 = 11, we get: 3 c1 + 3 c2 + 5 c3 = 11
For n = 2 and a3 = 25, we get: 9 c1 + 18 c2 + 25 c3 = 25
Solving the system of the three equations in the unknown’s c1, c2 & c3 yields:
c1= 4, c2 2, c3 = 1
Thus the following is the unique solution of the recurrence relation with the given initial
conditions:
= (4 2n)( )+
Then
a) Find the next three terms of the sequence.
b) Find the general solution.
c) Find the unique solution with the given initial conditions.
= c1 + c2 c3 +...+ck + F(n),
where c1, c2, . . . , ck are real numbers and F(n) is a function not identically zero
depending only on n. The recurrence relation
= c1 + c2 c3 +...+ck
24
THEOREM
If is a particular solution of the non homogeneous linear recurrence relation
with constant coefficients
= c1 + c2 c3 +...+ck + F(n),,
= c1 + c2 c3 +...+ck + F(n),
THEOREM. Suppose that {an} satisfies the linear non homogeneous recurrence relation
= c1 + c2 c3 +...+ck + F(n)
where b0, b1, . . . , bt and s are real numbers. When s is not a root of the characteristic
equation of the associated linear homogeneous recurrence relation, there is a particular
solution of the form
Note that in the case when s is a root of multiplicity m of the characteristic equation of
the associated linear homogeneous recurrence relation, the factor ensures that the
proposed particular solution will not already be a solution of the associated linear
homogeneous recurrence relation.
Step 1: Find the homogeneous solution to the homogeneous equation. This results when
you set the R.H.S. to zero. If it is already zero, skip the next two steps and go directly to
the step 4. Your answer will contain one or more undetermined coefficients whose
values cannot be determined until step 4.
Step 2: Find the particular solution by guessing a form similar to the R.H.S. This step
does not produce any additional undetermined coefficients, nor does it eliminate those
from step 1.
Step 3: Combine the homogeneous and particular solution.
25
Step 4: Use boundary or initial conditions to eliminate the undetermined constants from
the step 1.
We shall now discuss the way to find a particular solution : The form of a particular
solution has nothing to do with the order of the recurrence relation. It only depends on
the form of the R.H.S. of recurrence equation expressed in standard form. Guess a
solution of the same form but with undetermined coefficients, which have to be
calculated. We find their values by substituting the guessed particular solution into the
recurrence equation. You may find the following table useful for guessing a particular
solution:
= 6
Solution: This is a linear non homogeneous recurrence relation. The solutions of its
associated homogeneous recurrence relation
= 6
. where C is a constant.
Substituting the terms of this sequence into the recurrence relation implies that
C· = 5C · 6C · + .
26
Example2. Solve the recurrence equation
10 ...(1)
is 10 =0 ...(2)
⇒ (x – 2)(x – 5) = 0
⇒ x = 2 and x = 5
Since the two roots 2 and 5 of characteristic equation are distinct, the homogeneous
solution is given by
...(3)
n n 10 n
or, A[4n – 7(n – 1) 2 + 10(n– 2)] =
or, C[4n – 14(n – 1) + 10n – 20] = 4
or, C[4n – 14n + 14 + 10n – 20] = 4
or, – 6C = 4 ⇒ C =
Particular solution is = .
The complete, also called total, solution is obtained by combining the homogeneous and
particular solutions. This is given as
...(4)
The equation (4) contains two undetermined coefficients and , which are to be
determined.
To find this, we use the given initial conditions for n = 0 and n = 1
.
Since values of and are given.
27
And
Replacing and in equation (4) by its respective values, we get the closed form
formula for the given recurrence equation. Thus,
Exercise1) What is the general formula for the following recurrence relation
= 12
If
a)
b)
c)
28
Chapter four
Elements of Graph Theory
Definition
A graph G consists of two finite sets: a nonempty set V(G) of vertices and a set E(G) of
edges, where each edge is associated with a set consisting of either one or two vertices
called its endpoints. The correspondence from edges to endpoints is called the edge-
endpoint function.
An edge with just one endpoint is called a loop, and two or more distinct edges with the
same set of endpoints are said to be parallel. An edge is said to connect its endpoints;
two vertices that are connected by an edge are called adjacent; and a vertex that is an
endpoint of a loop is said to be adjacent to itself.
An edge is said to be incident on each of its endpoints, and two edges incident on the
same endpoint are called adjacent. A vertex on which no edges are incident is called
isolated.
A simple graph is a graph G = (V, E) that has no loops and no multiple edges.
Graphs have pictorial representations in which the vertices are represented by dots and
the edges by line segments.
Example; Consider the following graph:
a) Write the vertex set and the edge set, and give a table showing the edge-endpoint
function.
b) Find all edges that are incident on v1, all vertices that are adjacent to v1, all edges
that are adjacent to e1, all loops, all parallel edges, all vertices that are adjacent to
themselves, and all isolated vertices.
Solution
a) vertex set = {v1, v2, v3, v4, v5, v6}
edge set = {e1, e2, e3, e4, e5, e6, e7}
edge-end point function:
29
b) e1, e2, and e3 are incident on v1.
v2 and v3 are adjacent to v1.
e2, e3, and e4 are adjacent to e1.
e6 and e7 are loops.
e2 and e3 are parallel.
v5 and v6 are adjacent to themselves.
v4 is an isolated vertex.
Degree of a vertex
Solution
Deg(a)=4 Deg(b)=6 Deg(c)=1 Deg(d)=5 Deg(e)=6
(Note that this applies even if multiple edges and loops are present.)
Example1. How many edges are there in a graph with 10 vertices each of degree six?
Solution: Because the sum of the degrees of the vertices is 6 ・ 10 = 60, it follows that
2E = 60
where E is the number of edges. Therefore, E = 30.
30
Example2. Determine the number of edges in a graph with 6 vertices, 2 of degree 4 and
4 of degree 2. Draw two such graphs.
Solution. Suppose the graph with 6 vertices has e number of edges. Therefore by
Handshaking
theorem
deg
∈
Example3. How many vertices are needed to construct a graph with 6 edges in which
each vertex is of degree 2.
Solution. Suppose these are P vertices in the graph with 6 degree. Also given the degree
of each vertex is 2.
By handshaking theorem,
deg
Two types of matrices commonly used to represent graphs. One is based on the adjacency of vertices, and
the other is based on incidence of vertices and edges.
31
Adjacency Matrices
Suppose that G = (V ,E) is a simple graph where |V| = n. The adjacency matrix with A= [ ], is
then given by
, , .
,
Incidence Matrices
Another common way to represent graphs is to use incidence matrices. Let G = (V ,E) be an undirected
graph. Suppose that v1, v2, . . . , vn are the vertices and e1, e2, . . . , em are the edges of G. Then the incidence
matrix with respect to this ordering of V and E is the n × m matrix M = [ ], where
, when edge is incident with .
,
Exercise. Use an adjacency and incidence matrix to represent the graph shown below
a) b)
32
Isomorphism of Graphs
Let G1 = (v1, E1) and G2 = (v2, E2) be two graphs. A function is called a
graphs isomorphism if
In other words, two graphs G1 and G2 are said to be isomorphic to each other if there is
a oneto one correspondence between their vertices and between edges such that
incidence relationship is preserve. Written as ≅ .
Solution. Let f : G G′ be any function defined between two graphs degrees of the graph
G and G′ are as follows :
deg (G) deg (G′)
deg (a) = 3 deg (a′) = 3
deg (b) = 2 deg (b′) = 2
deg (c) = 3 deg (c′) = 3
deg (d) = 3 deg (d′) = 3
deg (e) = 1 deg (e′) = 1
33
Exr. Show that the following graphs are isomorphic
.
1)
2)
DEFINITION
(a) A walk in a graph G = (V, E) is an alternating list of vertices and edges
v0, e1, v1, e2, v2, e3, . . . , v n 1, en, vn with n ≥ 0 that starts at vertex v0, ends at vertex vn,
(b) A circuit is a walk of positive length that starts and ends at the same vertex.
(c) A trail is a walk with no repeated edges. In a graph with multiple edges, distinct
multiple edges may be included.
(d) A path is a walk with no repeated vertices.
(e) A cycle is a circuit in which the only vertex repetition is vn = v0.
(f) The distance between two vertices u and v in G, denoted distG(u, v), is the length of
the shortest walk in G between u and v. If there is no walk, then we assign distG(u, v)
∞. When G is clear in context, the subscripts may be dropped.
34
(a) 1, b, 2, e, 5, h, 5, e, 2, d, 4 is a walk of length 5 that starts at 1 and ends at 4.
(b) 1, b, 2, e, 5, h, 5, g, 4, d, 2, a, 1 is a circuit of length 6 that starts and ends at 1.
(c) 2, a, 1, b, 2, e, 5, h, 5 is a trail of length 4 that starts at 2 and ends at 5.
(d) 2, b, 1, c, 3, f, 4 is a path of length 3 that starts at 2 and ends at 4.
(e) 2, b, 1, c, 3, f, 4, d, 2 is a cycle of length 4 that starts and ends at 2.
(f) dist(2, 4) = 1, dist(3, 5) = 2, and dist(5, 5) = 0.
DEFINITION
(a) A graph G is connected if, for any two vertices, there is a path between them.
Otherwise, G is disconnected.
Example. The graph in (a) is connected and therefore have a single component. The
graph in (b) is disconnected and has two Components.
(a) (b)
One is induced by {1, 2, 4, 5, 6}, and the other is induced by {3, 7}.
Eulerian graphs
DEFINITION
Let G be a graph or a digraph. An Euler circuit (respectively, Euler trail) in G is a
circuit (respectively, trail) that covers every edge exactly once and covers every
vertex. Of course, unless G has isolated vertices, covering every edge will imply
that every vertex is covered. If G contains an Euler circuit, then G is said to be
Eulerian.
35
Example. Check the graph is eulerian or not
Since the pictured graph G is connected and every vertex has even degree,
Euler’s Theorem guarantees an Euler circuit for G. In fact, the Euler circuit can
be found as follows.
a, i, j, k, b, c, d, e, f, l, m, n, g, h
Exercise. Check whether the given graphs are eulerian or not if it is find the eulerian
circuit.
(a)
(c)
(b)
Hamiltonian graph
DEFINITION
Let G be a graph. A Hamiltonian cycle (respectively, Hamiltonian path) in G is a cycle
(respectively, path) that covers every vertex. By definition, each vertex must be covered
exactly once, with the exception that the starting and ending vertex of a Hamiltonian
cycle is covered twice. If G contains a Hamiltonian cycle, then G is said to be
Hamiltonian.
Although no useful necessary and sufficient conditions for the existence of Hamilton
circuits are known, quite a few sufficient conditions have been found.
Having seen ways to show that a Hamiltonian cycle does not exist, we ought to consider
conditions sufficient to guarantee that one does. There is a bound on the minimum
degree δ(G) of a graph G that implies Hamiltonicity.
36
THEOREM. If G is a simple graph with n vertices with n ≥ 3 such that the degree of every
vertex in G is at least n/2, then G has a Hamilton circuit.
THEOREM. If G is a simple graph with n vertices with n ≥ 3 such that deg(u) + deg(v) ≥
n for every pair of nonadjacent vertices u and v in G, then G has a Hamilton circuit.
Both theorems provide sufficient conditions for a connected simple graph to have a
Hamilton circuit. However, these theorems do not provide necessary conditions for the
existence of a Hamilton circuit. For example, the graph C5 has a Hamilton circuit but
does not satisfy the hypotheses of either of the theorems.
Example. It follows from above Theorem that the pictured graph G = (V, E) is
Hamiltonian, since δ(G) = 4 = .
A, B, C, D, H, G, E, F, A.
Exercise. Find and shade a Hamiltonian cycle for the following graphs
Complete Graphs
A graph G is said to be complete if every vertex in G is connected to every other vertex
in G. Thus a complete graph G must be connected. The complete graph with n vertices is
denoted by Figure below shows the graphs K1 through K6.
37
Regular Graphs
A graph G is regular of degree k or k-regular if every vertex has degree k. In other
words, a graph is regular if every vertex has the same degree.
Bipartite graphs
A graph G = (V, E) is bipartite if the vertex set V can be partitioned into two subsets
(disjoint) V1 and V2 such that every edge in E connects a vertex in V1 and a vertex V2
(so that no edge in G connects either two vertices in V1 or two vertices in V2). (V1, V2)
is called a bipartition of G. Obviously; a bipartite graph can have no loop.
38
Examples of bipartite graphs.
The complete bipartite graph on m and n vertices, denoted Km, n is the graph, whose
vertex set is partitioned into sets V1 with m vertices and V2 with n vertices in which
there is an edge between each pair of vertices V1 and V6. Where V1 is in V1 and V2 is in
V2. The complete bipartite graphs K2, 3, K3, 3, K3, 5 and K2, 6 are shown in Figure below.
Note that Kr, s has r + s vertices and rs edges.
39
Exercise1. Determine whether or not each of the graphs is bipartite. In each case, give
the bipartition sets or explain why the graph is not bipartite.
1. 2.
Planar graphs
Example
The closed electric circuit on the left-hand side of Figure (a) contains a battery and
some resistors . An intersection of wires not marked by a node • is a wire crossing,
which we would like to avoid. On the right-hand side of Figure (a) is a graph that
models this circuit, with edges representing wires. Since that graph can alternatively be
drawn with no edge crossings, as shown on the right-hand side of Figure (b), the circuit
can similarly be constructed without wire crossings, as shown on the left-hand side of
Figure (b).
40
Fig(b) an electric circuit without wire crossing
The planarity of graphs is also useful in the design of road networks. Suppose we want
to connect a group of cities by roads. We can model a road network connecting these
cities using a simple graph with vertices representing the cities and edges representing
the highways connecting them. We can build this road network without using
underpasses or overpasses if the resulting graph is planar.
Euler’s Formula
A planar representation of a graph splits the plane into regions, including an unbounded region.
THEOREM. EULER’S FORMUL Let G be a connected planar simple graph with e edges
and v vertices. Let r be the number of regions in a planar representation of G. Then
Example. Suppose that a connected planar simple graph has 20 vertices, each of degree
3. Into how many regions does a representation of this planar graph split the plane?
Solution: This graph has 20 vertices, each of degree 3, so v = 20. Because the sum of the
degrees of the vertices, 3v = 3 ・ 20 = 60, is equal to twice the number of edges, 2e, we
have 2e = 60, or e = . Conse uently, from Euler’s formula, the number of regions is
COROLLARY1. If G is a connected planar simple graph with e edges and v vertices, where
≥ , then
≤ .
COROLLARY 2 If a connected planar simple graph has e edges and v vertices with ≥
and no circuits of length three (i.e bipartite), then
≤ .
41
Example.
1. Show that K5 is non planar graph
Solution.The graph K5 has five vertices and 10 edges. However, the inequality e ≤ 3v 6
is not satisfied for this graph because e = 10 and 3v 6 = 9. Therefore, K5 is not planar.
Solution.The graph K2,3 has five vertices and 6 edges. However, the inequality e ≤ 2v 4
is satisfied for this graph
Hence e ≤ 2v – 4 gives 6 ≤ . Therefore, K2,3 is planar.
Draw graphs for K5 and K2,3
Graph coloring
Definition1. A coloring of a simple graph is the assignment of a color to each vertex of
the graph so that no two adjacent vertices are assigned the same color.
Definition2. The chromatic number of a graph is the least number of colors needed for a
coloring of this graph. The chromatic number of a graph G is denoted by χ G . (Here χ is
the Greek letter chi.)
Solution. The chromatic number of G is at least three, because the vertices a, b, and c must
be assigned different colors. Adjacent vertices cannot use the same color .
42
Example. (Accommodating Scheduling Conflicts). a graph G
was used to reflect scheduling conflicts among classes in Astronomy, Biology, Calculus,
Discrete Math, English Composition, and French, each needing to schedule a study
session. That is, in G an edge joins two vertices precisely when the two corresponding
class groups cannot meet simultaneously. We can now see how this graph can be used
to obtain a schedule that accommodates all of the study sessions in a minimum number
of time periods.
Solution. An allowable schedule corresponds to a coloring of the vertices of
G with time periods numbered 1, 2, . . . For example, the coloring
Graphs containing no simple circuits that are not necessarily connected, these graphs
are called forests and have the property that each of their connected components is a
tree.
43
Example.
Example of forest
THEOREM. An undirected graph is a tree if and only if there is a unique simple path
between any two of its vertices.
Rooted trees
DEFINITION. A rooted tree is a tree in which one vertex has been designated as the root and every edge
is directed away from the root.
The level of a vertex is the number of edges along the unique path between it and the
root.
The height of a rooted tree is the maximum level of any vertex of the tree.
Given the root or any internal vertex v of a rooted tree, the children of v are all those
vertices that are adjacent to v and are one level farther away from the root than v.
If w is a child of v, then v is called the parent of w, and two distinct vertices that are
both children of the same parent are called siblings. Given two distinct vertices v and w,
if v lies on the unique path between w and the root, then v is an ancestor of w and w is a
descendant of v.
44
Example. Rooted Trees
Consider the tree with root v0 shown below.
a. What is the level of v5? b. What is the level of v0?
c. What is the height of this rooted tree? d. What are the children of v3?
e. What is the parent of v2? f. What are the siblings of v8?
g. What are the descendants of v3?
Definition. A binary tree is a rooted tree in which every parent has at most two children.
Each child in a binary tree is designated either a left child or a right child (but not both).
Spanning trees
Definition. A spanning tree for a graph G is a subgraph of G that contains every vertex of
G and is a tree.
Proposition
1. Every connected graph has a spanning tree.
2. Any two spanning trees for a graph have the same number of edges.
Example. Find all spanning trees for the graph G pictured below.
Solution The graph G has one circuit v2v1v4v2, and removal of any edge of the circuit
gives a tree. Thus, as shown below, there are three spanning trees for G.
45
Algorithms for Minimum Spanning Trees
A wide variety of problems are solved by finding a spanning tree in a weighted graph
such that the sum of the weights of the edges in the tree is a minimum.
EXAMPLE. Use Prim’s and ruskal’s algorithm to find a minimum spanning tree in the graph shown
below.
Weighted graph
Solution: a) A minimum spanning tree constructed using Prim’s algorithm is
46
b. A minimum spanning tree constructed using kruskal’s algorithm is
Exercise. Use both algorisms then find the minimum spanning tree for the following graphs
47
Chapter five
Directed graphs
DEFINITION . A directed graph, or digraph, consists of a set V of vertices (or nodes)
together with a set E of ordered pairs of elements of V called edges (or arcs). The vertex
a is called the initial vertex of the edge (a, b), and the vertex b is called the terminal
vertex of this edge.
An edge of the form (a, a) is represented using an arc from the vertex a back to itself.
Such an edge is called a loop.
EXAMPLE 4 Find the in-degree and out-degree of each vertex in the graph G with
directed edges shown below
48
Exercise Find the in-degree and out-degree of each vertex in the graph G with directed
edges shown below
(1) (2)
Incidence matrix
The incidence matrix B = {bij} of digraph D with n vertices and m edges is the n × m
matrix in which
bij = 1 if arc j is directed away from a vertex vi
= – 1 if arc j directed towards vertex vi
= 0 otherwise.
Example1. Use adjacency matrix to represent the graphs shown in Figure below
Example2. Use incidence matrix to represent the graphs shown in Figure below
49
Exercise; Use adjacency and incidence matrix to represent the graphs shown in
Figure below
DEFINITION 1 A path from a to b in the directed graph G is a sequence of edges (x0, x1),
(x1, x2), (x2, x3), . . . , (xn 1, xn) in G, where n is a nonnegative integer, and x0 = a and xn =
b, that is, a sequence of edges where the terminal vertex of an edge is the same as the
initial vertex in the next edge in the path. This path is denoted by x0, x1, x2, . . . , xn 1, xn
and has length n. We view the empty set of edges as a path of length zero from a to a. A
path of length n ≥ 1 that begins and ends at the same vertex is called a circuit or cycle.
A path in a directed graph can pass through a vertex more than once. Moreover, an edge
in a directed graph can occur more than once in a path.
EXAMPLE . Which of the following are paths in the directed graph shown in Figure 1: a,
b, e, d; a, e, c, d, b; b, a, c, b, a, a, b; d, c; c, b, a; e, b, a, b, a, b, e? What are the lengths of
those that are paths? Which of the paths in this list are circuits?
50
Solution: Because each of (a, b), (b, e), and (e, d) is an edge, a, b, e, d is a path of length
three. Because (c, d) is not an edge, a, e, c, d, b is not a path. Also, b, a, c, b, a, a, b is a path
of length six because (b, a), (a, c), (c, b), (b, a), (a, a), and (a, b) are all edges. We see that
d, c is a path of length one, because (d, c) is an edge. Also c, b, a is a path of length two,
because (c, b) and (b, a) are edges. All of (e, b), (b, a), (a, b), (b, a), (a, b), and (b, e) are
edges, so e, b, a, b, a, b, e is a path of length six.
The two paths b, a, c, b, a, a, b and e, b, a, b, a, b, e are circuits because they begin and end
at the same vertex. The paths a, b, e, d; c, b, a; and d, c are not circuits.
Connectivity
There are three types of connectivity in a directed graph G:
(i) G is strongly connected or strong if, for any pair of vertices u and v in G, there is a
path from u to v and a path from v to u, that is, each is reachable from the other.
(ii) G is unilaterally connected or unilateral if, for any pair of vertices u and v in G, there
is a path from u to v or a path from v to u, that is, one of them is reachable from the
other.
(iii) G is weakly connected or weak if there is a semipath between any pair of vertices u
and v in G. Let G’ be the (nondirected) graph obtained from a directed graph G by
allowing all edges in G to be nondirected. Clearly, G is weakly connected if and only if
the graph G’ is connected.
Observe that strongly connected implies unilaterally connected which implies weakly
connected. We say that G is strictly unilateral if it is unilateral but not strong, and we say
that G is strictly weak if it is weak but not unilateral.
51
EXAMPLE . Consider the graph G in Fig. below. It is weakly connected since the
underlying nondirected graph is connected. There is no path from C to any other vertex,
that is, C is a sink, so G is not strongly connected.
However, P = (B,A,D,C) is a spanning path, so G is unilaterally connected.
52