0% found this document useful (0 votes)
9 views73 pages

MA320 - Discrete Mathematics

These lecture notes for MA320: Discrete Mathematics at The Copperbelt University aim to provide students with a foundational understanding of discrete mathematics, which is essential for various advanced mathematics courses. The notes cover topics such as set theory, logic, graph theory, and proof techniques, emphasizing the importance of logical arguments and axiomatic approaches. The document also includes a list of symbols and a detailed table of contents outlining the subjects covered in the course.

Uploaded by

lewissikanyika35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views73 pages

MA320 - Discrete Mathematics

These lecture notes for MA320: Discrete Mathematics at The Copperbelt University aim to provide students with a foundational understanding of discrete mathematics, which is essential for various advanced mathematics courses. The notes cover topics such as set theory, logic, graph theory, and proof techniques, emphasizing the importance of logical arguments and axiomatic approaches. The document also includes a list of symbols and a detailed table of contents outlining the subjects covered in the course.

Uploaded by

lewissikanyika35
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

The Copperbelt University

School of Mathematics And Natural Sciences

Department of Mathematics

MA320: Discrete Mathematics


December 20, 2021

Lecture Notes Lecturer: T.W. SINYANGWE.

Introduction and Motivation

Small print: The purpose of these lecture notes is to provide a clear comprehension of discrete
mathematics for students taking mathematics, data science or computer science as major courses.
The goal is to lay the mathematical foundation for mathematics courses such as linear and abstract
algebra, combinatorics, graph theory, probability, set theory, logic and number theory.

Discrete mathematics describes processes that consist of a sequence of individual steps. Discrete
mathematics is different from calculus, which describes processes that change continuously. Although
the ideas of calculus were fundamental to the science and technology of the industrial revolution,
the ideas of discrete mathematics underlie all of the science and technology of this era of computers.

Although discrete mathematics is often motivated by physical experimentation or by computer


simulations, it is made rigorous through the use of logical arguments. In studying discrete math-
ematics, we take what is called an axiomatic approach; that is, we take a collection of objects S
and assume some rules about their structure. These rules are called axioms. Using the axioms for
S, we wish to derive other information about S by using logical arguments. We require that our

1
axioms be consistent; that is, they should not contradict one another. We also demand that there
not be too many axioms. If a system of axioms is too restrictive, there will be few examples of the
mathematical structure.

A certain amount of mathematical maturity is necessary to find and study applications of dis-
crete mathematics. A basic knowledge of set theory, mathematical induction, equivalence relations,
and matrices is a must. Even more important is the ability to read and understand mathematical
proofs. In these notes we will outline the background needed for a course in discrete mathematics.

If that meant nothing to you then you should learn something from the course that you do not
already know. In both style and content, this is an abstract mathematics course. There are few
prerequisites so long as elegant, abstract ideas appeal to you and you are willing to work rigorously
with definitions even if you find it hard to visualise the concepts they define.

Good luck and hope we shall enjoy the course together ♥. 1

TIMOTHY SINYANGWE.

1
Notice: This material must NOT be used as a substitute for attending the lectures.

Page 2 of 73
List of Symbols
Subject Symbol Meaning
Logic ¬p not p
p∧q p and q
pL∨q p or q
p q or p XOR q p or q but not both p and q
p≡q p is logically equivalent to q
p −→ q if p then q
p ←→ q p if and only if q
∴ therefore
P (x) predicate in x
P (x) =⇒ Q(x) Every element in the truth set of P (x)
is in the truth set of Q(x)
P (x) ⇐⇒ Q(x) P (x) and Q(x) have identical truth sets
∀ for all
∃ there exists
Number Theory d|n d divides n
and Applications
d-n d does not divide n
n div d the integer quotient of n divided by d
n mod d the integer remainder of n divided by d
gcd(a, b) the greatest common divisor of a and b
x := e x is assigned the value e
Sequences ... and so forth
Xn
ak the summation from k equals m to n of ak
k=m
Yn
ak the product from k equals m to n of ak
k=m
n! n factorial
Set Theory a∈A a is an element of A
a∈ /A a is not an element of A
{a1 , a2 , . . . , an } the set with elements a1 , a2 , . . . , an
{x ∈ D | P (x)} the set of all x in D for which P (x) is true
R, R− , R+ the sets of all real numbers, negative real numbers,
positive real numbers, and nonnegative real numbers
Z, Z− , Z+ the sets of all integers, negative integers,
positive integers, and nonnegative integers
Q, Q− , Q+ the sets of all rational numbers, negative rational number
positive rational numbers, and nonnegative rational numb
N the set of natural numbers
A⊆B A is a subset of B
A*B A is not a subset of B

Page 3 of 73
B−A the difference of B minus A
A=B A equals B
A∪B A union B
A∩B A intersection B
A the compliment of A
(x, y) ordered pair
(x1 , x2 , . . . , xn ) ordered n-tuple
A×B the Cartesian product of A and B
A1 × A2 × · · · × An the Cartesian product of A1 , A2 , . . . , An
∅ the empty set
P(A) the power set of A

Page 4 of 73
Contents
1 Set Theory 7
1.1 Introduction to Set Theory . . . . . . . . . . . . . . . . . . . . . . . . 7
1.2 New Sets from Old Sets . . . . . . . . . . . . . . . . . . . . . . . . . 7

2 Relations 10
2.1 Functions and Relations . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.2 New Functions from Old Functions . . . . . . . . . . . . . . . . . . . 12

3 Counting Principles 14
3.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 The Inclusion-Exclusion Principle of Two Sets . . . . . . . . . . . . . 14
3.2.7 Permutations with Indistinguishable Objects . . . . . . . . . . 15
3.2.18 Useful Identities . . . . . . . . . . . . . . . . . . . . . . . . . . 18

4 The Fundamentals of Logic 19


4.1 Basic Connectives and Truth Tables . . . . . . . . . . . . . . . . . . . 19
4.1.1 Connectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.1.5 New Statements from Existing Ones In Two Ways . . . . . . . 19
4.1.16 The Truth Table . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2 Logical Equivalence: The Laws of Logic . . . . . . . . . . . . . . . . . 23
4.2.3 The Laws of Logic . . . . . . . . . . . . . . . . . . . . . . . . 25

5 Boolean Algebra 26
5.1 Switching Functions: Disjunction and Conjunction Normal Forms . . 26
5.1.6 Addition and Subtraction of Boolean Functions . . . . . . . . 27
5.1.7 Ten Important Laws In Boolean Algebra . . . . . . . . . . . . 28
5.1.10 Disjunction Normal Form (d.n.f) . . . . . . . . . . . . . . . . 29

6 Proof Techniques 32
6.1 Mathematical Induction . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.1.3 Steps Involved in Proving By Mathematical Induction . . . . . 32
6.1.4 How To Do It . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.2 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

7 Graphs Theory 39
7.1 Introduction to Graphs Theory . . . . . . . . . . . . . . . . . . . . . 39
7.2 Graphs as Networks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.3 Special Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
7.4 Operations in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.5 The Concept of Degree of a Graph . . . . . . . . . . . . . . . . . . . 47
7.5.8 Havel-Hakimi Algorithm . . . . . . . . . . . . . . . . . . . . . 49
7.6 Walks, Trails, Paths, and Circuits . . . . . . . . . . . . . . . . . . . . 51
7.7 Connectedness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

Page 5 of 73
7.8 Euler Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.9 Distance in Graphs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.10 Cut-vertices and Bridges . . . . . . . . . . . . . . . . . . . . . . . . . 59
7.11 The Shortest Path Algorithm . . . . . . . . . . . . . . . . . . . . . . 60
7.12 Distance in Weighted Graphs . . . . . . . . . . . . . . . . . . . . . . 61
7.13 Dijkstra’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
7.13.1 Dijkstra’s Algorithm . . . . . . . . . . . . . . . . . . . . . . . 62
7.14 Trees and Forests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
7.15 Properties of Trees . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
7.16 Constructing Mininum Spanning Tree . . . . . . . . . . . . . . . . . . 65
7.16.5 Kruskal’s Algorithim . . . . . . . . . . . . . . . . . . . . . . . 66
7.17 Hamiltonian Circuits . . . . . . . . . . . . . . . . . . . . . . . . . . . 68

Page 6 of 73
1 Set Theory
1.1 Introduction to Set Theory
Definition 1.1.1 (Set) A set is a collection of objects (elements).

Let a be an element and let A and B be sets. We write a ∈ B if a is one of the


elements in the collection B and we write a ∈/ B if it is not. We write A ⊆ B if every
element in the collection A is also in the collection B and we write A * B if this is
not the case. If A ⊆ B we say A is a subset of B.

Example 1.1.2 The following are some of the useful examples of sets in this course;
(1) N = {0, 1, 2, 3, ...} is the set of natural numbers.
(2) Z = {..., −3, −2, −1, 0, 1, 2, 3, ...} is the set of all integers.
(3) Q = { ab : a, b ∈ Z and b 6= 0} is the set of all rational numbers.
(4) R is the set of all real numbers.
(5) C = {z|z is a complex number}.
(6) ∅ or {} is the empty set. It has no elements.
And N ⊂ Z ⊂ Q ⊂ R ⊂ C.

1.2 New Sets from Old Sets


When talking about a specific set, we need some way to explain to people what set
we are talking about. If it only has a few elements, we could simply list them all
between curly brackets. So, for example, the set of all natural numbers less than 10
is {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}. For sets with infinitely many (or even just very many)
elements, this form of notation is no longer practical.

If there is a well-established pattern then we can use dots to save space.


Example 1.2.1 The set of all even natural numbers less than 99 is {0, 2, 4, 6, . . . , 96, 98}
and the set of all odd natural numbers is {1, 3, 5, 7, ...}.
Often the set we want to talk about is the set of all objects (elements) of a certain
form that satisfy a certain condition (or that possess a certain property). Then we
can use notation of the form {thing | property} where the bar stands for the words
”such that”.

Example 1.2.2 The set {n2 | n ∈ N} is the set of all numbers of the form n2 such
that n is a natural number. So it is the set of all square natural numbers.

Example 1.2.3 {a ∈ R | a > 0} which is the set of all real numbers a such that a is
bigger than zero. So it is the set of all positive real numbers.

Page 7 of 73
Using this notation we can now describe some standard ways of defining new sets in
terms of sets that we already know about.

Definition 1.2.4 (Intersection) Let A and B be sets. Then

A ∩ B = {a | a ∈ A and a ∈ B}

(which could also be written as {a ∈ A | a ∈ B} or as {a ∈ B | a ∈ A}).

Definition 1.2.5 (Union of Sets) Let A and B be sets. Then

A ∪ B = {a | a ∈ A or a ∈ B}.

Definition 1.2.6 (Relative Complement) Let A and B be sets. Then

A \ B = {a | a ∈ A and a ∈
/ B}

(which could also be written as {a ∈ A | a ∈


/ B}).

Sometimes we will work within one fixed set U , called the universal set. For any set
A ⊂ U , we define the complement of A, denoted by A0 , to be the set

A0 = {a|a ∈ U and a ∈
/ A}.

Example 1.2.7 Let R be the universal set and suppose that

A = {a ∈ R|0 < a ≤ 3} and B = {a ∈ R|2 ≤ a < 4}.

Then

A∩B = {a ∈ R|2 ≤ a ≤ 3}
A∪B = {a ∈ R|0 < a < 4}
A0 = {a ∈ R|a ≤ 0 or a > 3}
A\B = {a ∈ R|0 < a < 2}.

Theorem 1.2.8 Let A, B, and C be sets. Then

(i) A ∪ A = A, A ∩ A = A and A\A = ∅;

(ii) A ∪ ∅ = A and A ∩ ∅ = A;

(iii) A ∪ (B ∪ C) = (A ∪ B) ∪ C and A ∩ (B ∩ C) = (A ∩ B) ∩ C;

(iv) A ∪ B = B ∪ A and A ∩ B = B ∩ A;

(v) A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C);

(vi) A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C).

Page 8 of 73
Proof.
We will prove (i) and (iii) and leave the remaining results to be proven as an exercise.
(i) Observe that

A ∪ A = {a|a ∈ A or a ∈ A}
= {a|a ∈ A}
=A

and

A ∩ A = {a|a ∈ A and a ∈ A}
= {a|a ∈ A}
= A.

Also, A\A = A ∩ A0 = ∅.

(iii) For sets A, B, and C,

A ∪ (B ∪ C) = A ∪ {a|a ∈ B or a ∈ C}
= {a|a ∈ A or a ∈ B, or a ∈ C}
= {a|a ∈ A or a ∈ B} ∪ C
= (A ∪ B) ∪ C.

A similar argument proves that A ∩ (B ∩ C) = (A ∩ B) ∩ C.

Definition 1.2.9 (Equality of Sets) Two sets A and B are equal, written A = B,
if we can show that A ⊂ B and B ⊂ A.

Theorem 1.2.10 (De-Morgan’s Laws) Let A and B be sets. Then


(i) (A ∪ B)0 = A0 ∩ B 0

(ii) (A ∩ B)0 = A0 ∪ B 0 .
Proof

(i) We must show that (A ∪ B)0 ⊂ A0 ∩ B 0 and (A ∪ B)0 ⊃ A0 ∩ B 0 . Let a ∈ (A ∪ B)0 .


Then a ∈ / A0 ∪ B 0 . So a is neither in A nor in B, by definition of the union
of sets. By the definition of the complement, a ∈ A0 and a ∈ B 0 . Therefore,
a ∈ A0 ∩ B 0 and we have (A ∪ B)0 ⊂ A0 ∩ B 0 .

To show the reverse inclusion, suppose that a ∈ A0 ∩ B 0 . Then a ∈ A0 and


a ∈ B 0 , and so a ∈
/ A or a ∈ / A ∪ B and so a ∈ (A ∪ B)0 . Hence,
/ B. Thus, a ∈
(A ∪ B)0 ⊃ A0 ∩ B 0 and so (A ∪ B)0 = A0 ∩ B 0 .

(ii) The proof of (ii) is left as a learning opportunity for students.

Page 9 of 73
Example 1.2.11 Other relations between sets often hold true. For example,

(A\B) ∩ (B\A) = ∅.

To see that this is true, observe that

(A\B) ∩ (B\A) = (A ∩ B 0 ) ∩ (B ∩ A0 )
= A ∩ A0 ∩ B ∩ B 0
= ∅.

Definition 1.2.12 (Cartesian Product) Let A and B be sets. Then we can define
a new set A × B, called the Cartesian product of A and B, as a set of ordered pairs.
That is,
A × B = {(a, b) | a ∈ A and b ∈ B}.
Here (a, b) is the ordered pair whose first coordinate is a and whose second coordinate
is b.

Example 1.2.13 Let A = {a, b}, B = {1, 2, 3}, and C = ∅. Then A × B is the set

A × B = {(a, 1), (a, 2), (a, 3), (b, 1), (b, 2), (b, 3)}

and
B × A = {(1, a), (1, b), (2, a), (2, b), (3, a), (3, b)}
and
A × C = ∅.

We define the Cartesian product of n sets to be

A1 × · · · × An = {(a1 , . . . , an )|ai ∈ Ai for i = 1, . . . , n}.

And if A = A1 = A2 = · · · = An , we often write An for A × · · · × A (where A would be


written n times). For example, the set R3 consists of all of 3-tuples of real numbers.

2 Relations
2.1 Functions and Relations
Definition 2.1.1 (Relation) For sets A and B, a relation between A and B is any
subset of the Cartesian product A × B. In the case where A = B, we speak of R being
a relation in A.

Remark 2.1.2 Since A × B and B × A are not generally the same sets (i.e A × B 6=
B × A), a relation between A and B maybe quite a different mathematical object from
a relation between B and A.

Page 10 of 73
Definition 2.1.3 (Domain and range) Let R ⊆ A × B be a relation. The domain
of R (domR) is defined by

domR = {a ∈ A|(a, b) ∈ R for some b ∈ B}

and the range of R (rngR) is defined by

rngR = {b ∈ B|(a, b) ∈ R for some a ∈ A}

Remark 2.1.4 (a) domR ⊆ A, rngR ⊆ B and R ⊆ domR × rngR.

(b) it may happen that domR = A, then R is called a relation from A into B.

Definition 2.1.5 (Function or Map) A function or mapping f from a set A into


a set B is a relation f from A into B such that whenever, (a, b1 ) ∈ f and (a, b2 ) ∈ f ,
then b1 = b2 . In other words no two distinct ordered pairs of f have the same first
component.

(Recall also the Vertical Line Test (VLT) in first year ).


Example 2.1.6 The set of ordered pairs R = {(x, y)|x, y ∈ R|x2 + y 2 = 25} is a
relation in R, but not a function.

Why? Since x2 + y 2 = 25 is the equation of a circle with radius 5 centred at the


origin, by the Vertical Line Test, the line must intersect the graph of x2 + y 2 = 25 in
at most one point, which is not the case here.

Remark 2.1.7 (i) A function is a relation from A into B in which each a ∈ A is


related to exactly one b ∈ B.

(ii) b is called the functional value or image of a under f , denoted f (a).

(iii) f (a) is the unique second component of f having a as first component.

(iv) f = {(a, f (a))|a ∈ A}.

(v) To convey the information that f is a function from A into B, we write f :


A −→ B; in particular this signifies that domf = A.

(vi) For most functions f : A −→ B it is not the case that rngf = B. And this will
lead to the definition of Surjectivity (onto).

We shall be particularly interested in three properties that a function might have.

Let f : A −→ B be a function, then;


Definition 2.1.8 (Injective or One-to-one) A function f is called one-to-one (in-
jective) if and only if for all a1 , a2 ∈ A with a1 6= a2 , implies that f (a1 ) 6= f (a2 ), i.e.
distinct elements in the domain have distinct functional values. Similarly, for all
a1 , a2 ∈ A, if f (a1 ) = f (a2 ), then a1 = a2 .

Page 11 of 73
How do we check for one-to-oneness ?

ALGEBRAICALLY

(1) Suppose that x1 , x2 ∈ domf, x1 6= x2 , show that f (x1 ) 6= f (x2 ). Or

(2) suppose that f (x1 ) = f (x2 ), show that x1 = x2 for all x1 , x2 ∈ domf .
If f is a continuous function, then f is one-to-one iff it is strictly increasing,
which is equivalent to the derivative been always positive or always negative in
the case where f is differentiable.

GRAPHICALLY: (Recall the Horizontal Line Test (HLT).)


A function f is one-to-one if and only if (iff) every horizontal line intersects the graph
of f in at most one point.

Definition 2.1.9 (Surjective or Onto) A function f is said to be surjective (onto)


if the following condition is satisfied. For all b ∈ B there exists at least one a ∈ A
such that f (a) = b.

Definition 2.1.10 (Bijection) We say that f is a bijection (f is bijective) if f is


both injective and surjective.

(i) Two functions f and g are identical iff they are composed of the same ordered
pairs.

(ii) Equivalently, f = g iff domf = domg and f (a) = g(a) for each a in their
common domain.

2.2 New Functions from Old Functions


We shall also sometimes be concerned with composition of functions.

Suppose that f and g are functions whose ranges are a subset of a system in which
addition, multiplication and division are permissible, then we can define functions
f + g, f · g and fg as;

(f + g)(a) = f (a) + g(a)


(f · g)(a) = f (a) · g(a)
 
f f (a)
(a) = , Where, g(a) 6= 0 and, a ∈ domf ∩ domg.
g g(a)

f + g is called the pointwise sum and f · g is called the pointwise product of f and g.

Definition 2.2.1 (Composition of Functions) Let A, B and C be sets. Let g :


A −→ B and f : B −→ C. Then f ◦ g : A −→ C is called a composite function
defined as follows. For all a ∈ A, (f ◦ g)(a) = f (g(a)).

Page 12 of 73
In other words, the composition of two functions f and g denoted f ◦ g is defined by

f ◦ g = {(a, b)|for some c, (a, c) ∈ g and (c, b) ∈ f }

That is; (f ◦ g)(a) = f (g(a)) where, a ∈ domg and g(x) ∈ domf .


Note 2.2.2 that dom(f ◦ g) ⊆ dom(g) and rng(f ◦ g) ⊆ rng(f ).

(1) Suppose that f = {(x, 4 − x2 ), −2 ≤ x ≤ 2} and g = {(x, x2 )|x ∈ R\{0}},

i.e. f (x) = 4 − x2 for −2 ≤ x ≤ 2 and g(x) = x2 for x ∈ R\{0}. If x ∈
domf ∩ domg = [−2, 0) ∪ (0, 2].
Then,
√ 2
(f + g)(x) = f (x) + g(x) = 4 − x2 +
x √

 
2 2 4 − x2
(f · g)(x) = f (x) · g(x) = ( 4 − x2 ) =
x x

Homework; (Hint: Use definition of composite functions)



(2) Suppose√that f = {(x, x)|x ∈ R, x ≥ 0} and g = {(x, 2x + 3)|x ∈ R} that is
f (x) = x, for all x ≥ 0 and g(x) = 2x + 3 for all x ∈ R.
Then find;

(i) (f ◦ g)(x) where, dom(f ◦ g) = {x ∈ domg|g(x) ∈ domf }


(ii) (g ◦ f )(x) where, dom(g ◦ f ) = {x ∈ domf |f (x) ∈ domg}

Definition 2.2.3 (Inverse of a Function) The inverse of a one-to-one function f ,


written f −1 , is the set of ordered pairs

f −1 = {(b, a)|(a, b) ∈ f }

(i) domf −1 = rngf and rngf −1 = domf

(ii) Cancellation laws;

(f −1 ◦ f )(x) = x, for x ∈ domf


(f ◦ f −1 )(y) = y, y ∈ domf −1 = rngf

Theorem 2.2.4 Let A, B and C be sets. Let g : A −→ B and f : B −→ C


(i) If f and g are injective then f ◦ g is injective.

(ii) If f and g are surjective then f ◦ g is surjective.

(iii) If f and g are bijective then f ◦ g is bijective.


Proof (We shall discuss the proof during the lecture time.)

Page 13 of 73
3 Counting Principles
3.1 Introduction
Counting problems arise throughout mathematics and computer science. For ex-
ample, we must count the successful outcomes of experiments and all the possible
outcomes of these experiments to determine probabilities of discrete events.

In this chapter, we will introduce the basic techniques of counting. These methods
serve as the foundation for almost all counting techniques.

3.2 The Inclusion-Exclusion Principle of Two Sets


Suppose that A and B are sets. Then, there are n(A) ways to select an element from
A and n(B) ways to select an element from B.

The number of ways to select an element from A or from B, that is, the number
of ways to select an element from their union, is the sum of the number of ways to
select an element from A and the number of ways to select an element from B, minus
the number of ways to select an element that is in both A and B.

Because there are n(A ∪ B) ways to select an element either in A or in B, and


n(A ∩ B) ways to select an element common to both sets, we have

n(A ∪ B) = n(A) + n(B) − n(A ∩ B).

Definition 3.2.1 (The Multiplication Rule) Suppose that a procedure can be bro-
ken down into a sequence of two tasks. If there are n1 ways to do the first task and
for each of these ways of doing the first task, there are n2 ways to do the second task,
then there are n1 n2 ways to do the procedure.

Example 3.2.2 How many different bit strings of length seven are there?

Solution
Each of the seven bits can be chosen in two ways, because each bit is either 0 or 1.
Therefore, the multiplication rule shows there are a total of 27 = 128 different bit
strings of length seven.

Example 3.2.3 The chairs of the MPF exam room at CBU are to be labelled with
an uppercase English letter followed by a positive integer not exceeding 100. What is
the largest number of chairs that can be labelled differently?

Solution
The procedure of labelling a chair consists of two tasks, namely, assigning to the seat
one of the 26 uppercase English letters, and then assigning to it one of the 100 pos-
sible integers. The multiplication rule shows that there are 26 · 100 = 2600 different

Page 14 of 73
ways that a chair can be labelled. Therefore, the largest number of chairs that can be
labelled differently is 2600.
Theorem 3.2.4 (Permutation) If n, r ∈ Z such that 0 ≤ r ≤ n, then
n n!
Pr =
(n − r)!
By Theorem 3.2.4 we know that if n ∈ Z+ , then n Pn = n!. We will illustrate this
result with some examples.
Example 3.2.5 How many ways are there to select a first-prize winner, a second-
prize winner, and a third-prize winner from 100 different people who have entered a
contest?

Solution
Because it matters which person wins which prize, the number of ways to pick the
three prize winners is the number of ordered selections of three elements from a set of
100 elements, that is, the number of 3-permutations of a set of 100 elements. Conse-
quently, the answer is
100 100!
P3 =
(100 − 3)!
= 970200
Example 3.2.6 Suppose that a saleswoman has to visit eight different cities. She
must begin her trip in a specified city, but she can visit the other seven cities in any
order she wishes. How many possible orders can the saleswoman use when visiting
these cities?

Solution
The number of possible paths between the cities is the number of permutations of seven
elements, because the first city is determined, but the remaining seven can be ordered
arbitrarily. Consequently, there are 7! = 7 · 6 · 5 · 4 · 3 · 2 · 1 = 5040 ways for the
saleswoman to choose her tour. If, for instance, the saleswoman wishes to find the
path between the cities with minimum distance, and she computes the total distance
for each possible path, she must consider a total of 5040 paths!

3.2.7 Permutations with Indistinguishable Objects


Some elements may be indistinguishable in counting problems. When this is the case,
care must be taken to avoid counting things more than once.
Theorem 3.2.8 (Permutations with Indistinguishable Objects) The number
of different permutations of n objects, where there are n1 indistinguishable objects of
type 1, n2 indistinguishable objects of type 2, . . . , and nk indistinguishable objects of
type k, is
n!
n1 ! × n2 ! × · · · × nk !

Page 15 of 73
Example 3.2.9 How many different strings can be made by reordering the letters of
the word M AT HEM AT ICS?

Solution
We first note that the letter M is repeated twice so n1 = 2. Also, the letter A is
repeated twice so n2 = 2, and also the letter T is repeated twice so n3 = 2.

The word M AT HEM AT ICS consists of 11 letters so the number of different strings
that can be made by reordering the letters of this word is
11!
= 4989600
2! × 2! × 2!
Theorem 3.2.10 (Combination) If n, r ∈ Z such that 0 ≤ r ≤ n, then

n n!
Cr =
r!(n − r)!

Example 3.2.11 (i) How many poker hands of five cards can be dealt from a stan-
dard deck of 52 cards?

(ii) How many ways are there to select 47 cards from a standard deck of 52 cards?
Solution

(i) Because the order in which the five cards are dealt from a deck of 52 cards does
not matter, there are

52 52!
C5 = = 2, 598, 960
5!(52 − 5)!

different hands of five cards that can be dealt.

(ii) There are

52 52!
C47 = = 2, 598, 960
47!(52 − 47)!

different ways to select 47 cards from a standard deck of 52 cards.


52 52
We can observe that C5 = C47 .

Corollary 3.2.12 Let n, r ∈ Z such that 0 ≤ r ≤ n. Then n Cr = n


Cn−r .

Proof
From Theorem 3.2.10, we have

n n!
Cr = .
r!(n − r)!

Page 16 of 73
Now,
n n!
Cn−r =
(n − r)![n − (n − r)]!
n!
=
(n − r)!(n − n + r)!
n!
=
(n − r)!r!
= n Cr
and this completes our proof.
Theorem 3.2.13 (The Binomial Theorem) Let x and y be variables, and let n
be a nonnegative integer. Then
n  
n
X n n−k k
(x + y) = x y .
k=0
k

Example 3.2.14 What is the expansion of (x + y)2 ?

Solution

2  
2
X 2
(x + y) = x2−k y k
k=0
k
     
2 2 0 2 1 1 2 0 2
= xy + xy + xy
0 1 2
= x2 + 2xy + y 2 .
Example 3.2.15 What is the expansion of (x + y)4 ?

Solution

4  
4
X 4 4−k k
(x + y) = x y
k=0
k
         
4 4 0 4 3 1 4 2 2 4 1 3 4 0 4
= xy + xy + xy + xy + xy
0 1 2 3 4
= x4 + 4x3 y + 6x2 y 2 + 4xy 3 + y 4 .
Example 3.2.16 What is the coefficient of x12 y 13 in the expansion of (x + y)25 ?

Solution
From the binomial theorem it follows that this coefficient is
 
25 25!
= = 5200300.
13 13!(25 − 13)!

Page 17 of 73
Example 3.2.17 What is the coefficient of x12 y 13 in the expansion of (2x − 3y)25 ?

Solution
First, note that this expression equals (2x + (−3y))25 . By the binomial theorem, we
have
25  
25
X 25
(2x + (−3y)) = (2x)25−k (−3y)k
k=0
k

Consequently, the coefficient of x12 y 13 in the expansion is obtained when k = 13,


namely,
 
25 12 25!
2 (−3)13 = −212 313
13 13!(25 − 13)!

3.2.18 Useful Identities


We can prove some useful identities using the binomial theorem.

Corollary 3.2.19 Let n ∈ Z+ . Then


n  
X n
= 2n .
k=0
k

Proof
Using the binomial theorem with x = y = 1, we have
n   n  
n
X
n n n−k k X n
2 = (1 + 1) = 1 1 =
k=0
k k=0
k

which is the desired result.

Corollary 3.2.20 Let n ∈ Z+ . Then


n  
X n
k
(−1) = 0.
k=0
k

Proof
Using the binomial theorem with x = 1 and y = −1, we have
n   n  
n
X n n−k k
X
k n
0 = (1 + (−1)) = 1 (−1) = (−1)
k=0
k k=0
k

which is the desired result.

Page 18 of 73
4 The Fundamentals of Logic
We now look at what constitutes a valid argument and a more conventional proof.
When a mathematician wishes to provide a proof for a given situation, he or she
must us a system of logic. This is also true when a computer scientist develops the
algorithm needed for a program or system of programs. The logic of mathematics is
applied to decide whether one statement follows from, or is a logical consequence of
one or more other statements.

4.1 Basic Connectives and Truth Tables


4.1.1 Connectives
When developing any mathematical theory, assertions are made in the form of sen-
tences and such written assertions are called statements (or propositions).
Definition 4.1.2 (Statement) A statement(or proposition) is a sentence that is
true or false but not both.
We use the lowercase letters of the alphabet (such as p, q and r) to represent state-
ments as;
Example 4.1.3 We can define logic statements as shown in the following Example
4.1.3 below;
p : Discrete mathematics is a required course for computer scientists.
q : James wrote I love descrete mathematics.
r : 2 + 3 = 5.

Definition 4.1.4 (Primitive Statements) The preceding statements represented


by the letters p, q and r are considered to be primitive statements, since we can not
break them down into anything simplier.

4.1.5 New Statements from Existing Ones In Two Ways


Let p, q defined above be the component statements, then we define;
Definition 4.1.6 (Negation) If p is a statement, the negation of p is ”not p,” de-
noted ¬p. It has opposite truth value from p. That is, if p is true, ¬p is false; if p is
false, ¬p is true.

Example 4.1.7 (Negation) Transforming the statement p in Example 4.1.3 above,


into the statement ¬p (which denotes the negation) and reads as ”Not p”, we have for
the statement p above, ¬p is the statement ”Discrete mathematics is not a required
course for computer scientists.”

Some times two or more statements can be combined to form a compound statement.
To do so, we use the following logical connectives as; Conjunction, Disjunction, Im-
plication and Biconditional.

Page 19 of 73
Definition 4.1.8 (Conjunction) If p and q are statements, then the conjunction
of p and q is ”p and q,” denoted by p ∧ q. It is true when both p and q are true. If
either p or q is false, or if both are false, p ∧ q is false.

Example 4.1.9 (Conjunction) Consider Example 4.1.3, the compound statement


p ∧ q is read ”Discrete mathematics is a required course for computer scientists, and
James wrote I love discrete mathematics.”

Definition 4.1.10 (Disjunction) If p and q are statements, then the disjunction of


p, q read ”p or q,” and denoted by p ∨ q is true when either p is true, or q is true, or
both p and q are true; it is false only when both p and q are false.

Example 4.1.11 (Disjunction) Considering Example 4.1.3, the compound state-


ment p ∨ q read ”Discrete mathematics is a required course for computer scientists or
James wrote I love discrete mathematics.”

We use the word ”or” in the inclusive sense. The exclusive ”or” is denoted by p Y q.
And so the compound statement p Y q is true if one or the other of p, q is true but
not both of the statements p, q are true. One way to express p Y q for Example 4.1.3
here is ”Discrete mathematics is a required course for computer scientists, or James
wrote I love discrete mathematics, but not both.”
Definition 4.1.12 (Implication) If p, q are statements, then the implication of p
and q denoted by p → q and reads ”p implies q designates the statement which is the
implication of q by p.
The alternative of Definition 4.1.12, we say that;
(i) ”if p, then q” (ii) p is sufficient for q” (iii) ”p is a sufficient condition for q.”

(iv) ”q is necessary for p” (iv) ”p only if q.”

Example 4.1.13 (Implication) Considering Example 4.1.3, a verbal translation of


p → q is ”If discrete mathematics a required course for computer scientists, then
James wrote I love discrete mathematics.” Here the statement p is called the hy-
pothesis of the implication; q is called the conclusion.

Definition 4.1.14 (Bi-conditional) If p, q are statements, then the bi-conditional


of p, q, denoted by p ↔ q, reads ”p if and only if q” or ”p is necessary and sufficient
for q.”

Example 4.1.15 (Bi-conditioning) Consider Example 4.1.3, the bi-condition of


two statements p, q, that is p ↔ q reads ”Discrete mathematics is a required course
for computer scientists if and only if James wrote I love discrete mathematics.”

Sometimes p ↔ q is abbreviated as ”p iff q” to mean ”p if and only if q.”

Throughout our discussion on logic, we must realise that a sentence such as;

Page 20 of 73
”The number x is an integer”

is not a statement because its truth value (true or false) can not be determined until
a numerical value is assigned for x. That is if x is assigned the value say x =
√7, then
the result would be true. Otherwise, assigning x to be such that x = 1/2, π, 2, then
the resulting statement would be false.

4.1.16 The Truth Table


In the foregoing section, we have mentioned the circumstances under which the com-
pound statements p ∨ q, p Y q are considered true, on the basis of the truth of their
components p, q.

Let use now define ”0” to represent ”false”, and ”1” to represent ”true”, then we
can construct the truth table for the component statements p, q to investigate the
idea of the truth or falsity of compound statements which are dependent only on the
truth values of its components. That is;

p ¬p
0 1
1 0

Table 1: Truth table for ¬p

From Table 1, we construct the following truth table of compound statements as;

p q p∧q p∨q pYq p→q p↔q


0 0 0 0 0 1 1
0 1 0 1 1 1 0
1 0 0 1 1 0 0
1 1 1 1 0 1 1

Table 2: Truth Table for compound statements.

Observation 4.1.17 From Table 2, we notice that the statement p ∧ q is true only
when both statements p, q are true, whereas, p ∨ q is false only when both component
statements p, q are false. Similarly, as we noted before, p Y q is true when exactly
on of the statements p, q is true. For the implication p → q, the result is true in all
cases, except where p is true and q is false, because we do not want a true statement
to lead us into believing something that is false.
Finally, the bi-condition p ↔ q is true when the statements p, q have the same truth
values and is false otherwise.

We now investigate a little further some of these initial concepts or ideas about
connectives.

Page 21 of 73
Example 4.1.18 Let s, t and u denote the following primitive statements;
s : Timothy goes out for a walk.
t : The moon is out.
u : It is raining.
The following English statements provide possible translations for the given (symbolic)
compound statements.
(i) (t ∧ ¬u) → s: If the moon is out and it in not raining, the Timothy goes out
for a walk.
(ii) t → (¬u → s): If the moon is out, then if it is not raining, Timothy goes out
for a walk.
(iii) ¬(s ↔ (u ∨ t)): It is not the case that Timothy goes out for a walk if and only
if it is raining or the moon is out.
We now work in reverse order to examine the logical (or symbolic) notation for the
three given English sentences;
(iv) ”Timothy will go out for a walk if and only if the moon is out.” Here the words
”if and only if” indicate that we are dealing with a bi-conditional. In symbolic
form, this becomes s ↔ t.
(v) ”If it is raining and the moon is not out, then Timothy will not go out for a
walk.” This compound statement is an implication where the hypothesis is also
a compound statement. Thus, we express this statement in symbolic form as
(u ∧ ¬t) → ¬s.
(vi) ”It is raining and Timothy will still go out for a walk.” This sentence is repre-
sented symbolically as u ∧ s.
In computer science the if-then and if-then-else decision structures arise (in various
formats) in high-level programming languages such as Python, Java, and C + +. The
hypothesis p is often a relational expression such as x > 2. This expression then
becomes a (logical) statement that has the truth value 0 or 1, depending on the
value of the variable x at that point in the program. The conclusion q is usually an
executable statement.” (So q is not one of the logical statements that we have been
discussing.) When dealing with ”if p then q,” in this context, the computer executes
q only on the condition that p is true. For p false, the computer goes to the next
instructionin the program sequence. For the decision structure ”if p then q else r,”
here q is executed when p is true and r is executed when p is false.
Example 4.1.19 Let p, q, r be primitive statements statements defined by
p : student’s grade is greater than or equal to 60
q : student has passed
r : student has failed
A pseudo-code for the if-then maybe written as follows;

Page 22 of 73
if p >= 60 then
print q
else
print r

Definition 4.1.20 (Tautology) A compound statement is said to be a tautology if


it is true for all truth value assignments for its component statements. If a compound
statement is false for all such assignments, then it is called a contradiction.

Through out this section, we will denote a tautological compound statement by T0 and
any contradiction compound statement by F0 . In the later sections, we will use the
ideas of tautology and implication to describe a valid argument. This will be of greater
interest and importance to develop needed skills for proving mathematical theorems.
In general, an argument starts with a list of given statements called premises and a
statement called the conclusion of the argument. We examine these premises, say
p1 , p2 , . . . , pn , and try to show that the conclusion q follows logically from these given
statements-that is, we try to show that if each of p1 , p2 , . . . , pn is a true statement,
then the statement q is also true. To do so one way is to examine the implication

(p1 ∧ p2 ∧ · · · ∧ pn ) −→ q

where the hypothesis is the conjunction of the n premises. If any one of p1 , p2 , . . . , pn


is false, then no matter what truth value q has, the implication

(p1 ∧ p2 ∧ · · · ∧ pn ) −→ q

is true. Consequently, if we start with the premises p1 , p2 , . . . , pn each with truth value
1, and find that under these circumstances q has the value 1, then the implication

(p1 ∧ p2 ∧ · · · ∧ pn ) −→ q

is a tautology and so we have a valid argument.


2

4.2 Logical Equivalence: The Laws of Logic


Our interest is to know when the entities we are studying are equal or essentially the
same. For example, we know that two real numbers are equal when they have the
same magnitude and algebraic sign, say if x, y ∈ R, then we have x = y if |x| = |y|
and xy > 0, and conversely that is if x = y, then |x| = |y| and xy > 0.

Now the study of logic is referred to as the algebra of propositions (as opposed to
the algebra of real numbers). In logic we use the truth tables of the statements, or
propositions, to develop an idea of when two such entities are essentially the same.

2
At this point we have dealt only with the conjunction of two statements, so we must point out
that conjunction p1 ∧ p2 ∧ · · · ∧ pn of n statements is true if and only if each pi , 1 ≤ i ≤ n, is true.

Page 23 of 73
Consider the following example;

Example 4.2.1 For premitive statements p and q. The following table below provides
the truth tables for the compound statements ¬p ∨ q and p → q. Here we see that the
corresponding truth tables for the two statements ¬p ∨ q and p → q are exactly the
same
p q ¬p ¬p ∨ q p → q
0 0 1 1 1
0 1 1 1 1
1 0 0 0 0
1 1 0 1 1

This situation leads us to the following idea

Definition 4.2.2 (Logically Equivalent) Two statements s1 , s2 are said to be log-


ically equivalent, and we write s1 ≡ s2 , when the statement s1 is true (respectively,
false) if and only if the statement s2 is true (respectively, false).
3
Thus, it follows from Definition 4.2.2 that we can express the connective for the
implication of primitive statements in terms of negation and disjunction as

(p → q) ≡ ¬p ∨ q

And in the same manner, from the Table in Example 4.2.1 we have

(p ↔ q) ≡ (p → q) ∧ (q → p)

And this can be verified from Example 4.2.1 as follows

p q p→q q→p (p → q) ∧ (q → p) p↔q


0 0 1 1 1 1
0 1 1 0 0 0
1 0 0 1 0 0
1 1 1 1 1 1

Therefore, we can deduce that when s1 and s2 are logically equivalent statements
(i.e. s1 ≡ s2 ), then the compound statement s1 ↔ s2 is a tautology. Under these
circumstances it is also true that ¬s1 ≡ ¬s2 and so ¬s1 ↔ ¬s2 is also a tautology.

If s1 , s2 and s3 are statements where s1 ≡ s2 and s2 ≡ s3 , then s1 ≡ s3 (this is


called the transitive property). When two statements s1 , s2 are not logically equiva-
lent, we may write s1 6≡ s2 to designate this situation.

3
When s1 ≡ s2 the statements s1 and s2 provide the same truth tables since s1 , s2 have the same
truth values for all choices of truth values for their primitive components

Page 24 of 73
4.2.3 The Laws of Logic
Using the concepts of logical equivalence, tautology, and contradiction, we state the
following list of laws for the algebra of proposition.

Theorem 4.2.4 (Laws of Logic) For any primitive statements p, q, r and any tau-
tology T0 and any contradiction F0 ;

1. Commutative laws: p∧q ≡q∧p p∨q ≡q∨p


2. Associative laws: (p ∧ q) ∧ r ≡ p ∧ (q ∧ r) (p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
3. Distributive laws: p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r) p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
4. Identity laws: p ∧ T0 ≡ p p ∨ F0 ≡ p
5. Inverse laws: p ∨ ¬p ≡ T0 p ∧ ¬p ≡ F0
6. Double negative law: ¬(¬p) ≡ p
7. Idempotent laws: p∧p≡p p∨p≡p
8. Domination laws: p ∨ T0 ≡ T0 p ∧ F0 ≡ F0
9. De Morgan’s laws: ¬(p ∧ q) ≡ ¬p ∨ ¬q ¬(p ∨ q) ≡ ¬p ∧ ¬q
10. Absorption laws: p ∨ (p ∧ q) ≡ p p ∧ (p ∨ q) ≡ p
11. Negation of T0 and F0 : ¬T0 ≡ F0 ¬F0 ≡ T0
4

Example 4.2.5 (Simplifying Statement Forms) Use Theorem 4.2.4 to verify the
logical equivalence ¬(¬p ∧ q) ∧ (p ∨ q) ≡ p.

Solution:

¬(¬p ∧ q) ∧ (p ∨ q) ≡ (¬(¬p) ∨ ¬q) ∧ (p ∨ q) by De Morgan’s laws


≡ (p ∨ ¬q) ∧ (p ∨ q) by the double negative law
≡ p ∨ (¬q ∧ q) by the distributive law
≡ p ∨ (q ∧ ¬q) by the commutative law for ∧
≡ p ∨ F0 by the negation law
≡p by the identity law

Example 4.2.6 Simplify the compound statement ¬[¬[(p ∨ q) ∧ r] ∨ ¬q] ≡ q ∧ r where


p, q, r are primitive statements.

Solution
This statement contains four occurences of pprimitive statements, three negation sym-
bols, and three connectives. From the laws of logic, it follows that

¬[¬[(p ∨ q) ∧ r] ∨ ¬q] ≡ ¬¬[(p ∨ q) ∧ r] ∧ ¬¬q De Morgan’s laws


≡ [(p ∨ q) ∧ r] ∧ q Laws of double negation
4
We note that because of the Associative Laws, there is no ambiguity in statements of the form
p ∨ q ∨ r or p ∧ q ∧ q ∧ r.

Page 25 of 73
[(p ∨ q) ∧ r] ∧ q ≡ (p ∨ q) ∧ (r ∧ q) Associative law of ∧
≡ (p ∨ q) ∧ (q ∧ r) Commutative law of ∧
≡ [(p ∨ q) ∧ q] ∧ r Associative law of ∧
≡q∧r Absorption law and commutative laws for ∧ and ∨

5 Boolean Algebra
We now encounter an algebraic system in which the structure depends primarily on
two closed binary operations. In dealing with Boolean algebras, we shall applications
more than the abstract nature of the system.

5.1 Switching Functions: Disjunction and Conjunction Nor-


mal Forms
Let us consider an electric switch. An electric switch can be turned on (allowing
the flow of current) or off (preventing the flow of current). Similarly, in a transistor,
current is either passing (conducting) or not passing (non-conducting). These are two
examples of two state devices.

In order to investigate such two state devices, we abstract these notions of ”true”
and ”false”, ”on” and ”off” as follows;

Let B = {0, 1}. We define addition, multiplication, and complements for these ele-
ments of B by;

(i) Addition:

0 + 0 = 0; 0+1=1+0=0+1=1+1=1

(ii) Multiplication:

0 · 0 = 0 = 1 · 0 = 0 · 1; 1·1=1

(iii) Complement:

0̄ = 1; 1̄ = 0.

Definition 5.1.1 (Boolean Variable) A variable x is called a Boolean variable if x


takes on only values in B = {0, 1}. Consequently, x + x = x, and x2 = x · x = xx = x
for all x ∈ B.

Suppose that x, y are Boolean variables, then the following hold true;

(i) x + y = 0 if and only if x = y = 0.

Page 26 of 73
(ii) xy = 1 if and only if x = y = 1.
Definition 5.1.2 (Boolean or Switching Function) A function f : B n −→ B is
called a Boolean or switching function of n Boolean variables, where n ∈ Z+ and
B n = {(b1 , b2 , . . . , bn )|bi ∈ {0, 1}, 1 ≤ i ≤ n}.
Example 5.1.3 Let f : B 3 −→ B, where f (x, y, z) = xy + z. This Boolean function
is determined by evaluating f for each of the eight possible assignments to the Boolean
variables x, y, z as tables demonstrates below;
x y z xy f (x, y, z) = xy + z
0 0 0 0 0
0 0 1 0 1
0 1 0 0 0
0 1 1 0 1
1 0 0 0 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 1
Definition 5.1.4 (Equality of Boolean Functions) Let f : B n −→ B and g :
B n −→ B for n ∈ Z+ , n ≥ 2 be two Boolean functions of the n Boolean variables
x1 , x2 , . . . , xn . We say that f and g are equal and write f = g if the columns for f, g
[in their respective (function) tables] are exactly the same. That is the table shows
that
f (b1 , b2 , . . . , bn ) = g(b1 , b2 , . . . , bn )
for each of the 2n possible assignments of either 0 or 1 to each of the n Boolean
variables x1 , x2 , . . . , xn .
Definition 5.1.5 (Complement of a Boolean Function) Suppose that
f : B n −→ B is a Boolean function, then the complement of f , denoted by f¯, is the
Boolean function defined on B n by
f¯(b1 , b2 , . . . , bn ) = f (b1 , b2 , . . . , bn ).

5.1.6 Addition and Subtraction of Boolean Functions


Suppose that f : B n −→ B and g : B n −→ B are Boolean functions, then we define;
(i) Addition of f and g as;
(f + g)(b1 , b2 , . . . , bn ) = f (b1 , b2 , . . . , bn ) + g(b1 , b2 , . . . , bn )
and
(ii) Multiplication of f and g as;
(f · g)(b1 , b2 , . . . , bn ) = f (b1 , b2 , . . . , bn ) · g(b1 , b2 , . . . , bn )
5

5
When dealing with Boolean variables multiplication is performed before addition. Hence, xy + z
represents (xy) + z, not x(y + z).

Page 27 of 73
5.1.7 Ten Important Laws In Boolean Algebra
(1) Law of Double Complement;

f¯ = f ; x̄¯ = x

(2) De Morgan’s Laws;

f + g = f¯ · ḡ; x + y = x̄ · ȳ
f · g = f¯ + ḡ x · y = x̄ + ȳ

(3) Commutative Laws;

f + g = g + f; x+y =y+x
f g = gf ; xy = yx

(4) Associative Laws;

f + (g + h) = (f + g) + h; x + (y + z) = (x + y) + z
(f g)h = f (gh); (xy)z = x(yz)

(5) Distributive Laws;

f + gh = (f + g)(f + h); x + yz = (x + y)(x + z)


f (g + h) = f g + f h; x(y + z) = xy + xz

(6) Idempotent Laws;

f + f = f; x+x=x
f · f = f; x·x=x

(7) Identity Laws;

f + 0 = f; x+0=x
f · 1 = f; x·1=x

(8) Dominance Laws;

f + 1 = 1; x+1=1
f · 0 = 0; x·0=0

(9) Inverse Laws;

f + f¯ = 1; x + x̄ = 1
f · f¯ = 0; x · x̄ = 0

Page 28 of 73
(10) Absorption Laws;

f + fg = f; x + xy = x
f (f + g) = f ; x(x + y) = x

Example 5.1.8 To establish the first absorption property for Boolean variables, we
argue as follows;

x + xy = x · 1 + xy Reasons
= x · 1 + xy Identity law
= x(1 + y) Distributive law
=x·1 Dominance law (and commutative law of +)
=x Identity law.

Example 5.1.9 Simplify the following expression

wx + x̄z + (y + z̄)

where w, x, y, z are Boolean variables.

Solution

Reasons
wx + x̄z + (y + z̄) = wx + (x̄¯ + z̄) + (y + z̄) De Morgans law
= wx + (x + z̄) + (y + z̄) Law of double complement
= [(wx + x) + z̄] + (y + z̄) Associative law of +
= (x + z̄) + (y + z̄) Absorption law and the commutative law of + and ·
= x + (z̄ + z̄) + y Commutative associative laws of +
= x + z̄ + y Idempotent law of +

5.1.10 Disjunction Normal Form (d.n.f )


Up to this point, we have seen that, when given a Boolean function (in algebraic
terms), we can construct its table of values. Now we consider the reverse process:
Given a table of values, we shall find a Boolean function (described in algebraic terms)
for which it is the correct table.

Definition 5.1.11 For all n ∈ Z+ , if f is a Boolean function on the n variables


x1 , x2 , . . . , xn , we call

(i) each term xi or its complement x̄i , for 1 ≤ i ≤ n, a literal;

(ii) a term of the form y1 y2 · · · yn , where each yi = xi or x̄i , for 1 ≤ i ≤ n a


fundamental conjunction; and

Page 29 of 73
(iii) a representation of f as a sum of fundamental conjunctions a disjunctive normal
form(d.n.f ) of f .

Example 5.1.12 Given three Boolean variables x, y, z, find formulas for functions
f, g, h : B 3 −→ B for the columns specified in the table below;

x y z f g h
0 0 0 0 0 0
0 0 1 1 0 1
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 0 0 0
1 1 1 0 0 0

Solution
For the column under f , we want a result that has the value 1 only in the case where
x = y = 0 and z = 1. And so the function

f (x, y, x) = x̄ȳz

is one such function. In the same way,

g(x, y, z) = xȳz̄

yields the value 1 for x = 1, y = z = 0, and is 0 in all other cases. Now since each of
f and g has the value 1 in only one case and these cases are distinct from each other,
their sum f + g has the value 1 in exactly these two cases. So

h(x, y, z) = f (x, y, z) + g(x, y, z) = x̄ȳz + xȳz̄

has the column of values given under h.

Example 5.1.13 Find the disjunctive normal form (d.n.f ) for f : B 3 −→ B, where
f (x, y, z) = xy + x̄z. Given the table of values as;

x y z xy x̄z f
0 0 0 0 0 0
0 0 1 0 1 1
0 1 0 0 0 0
0 1 1 0 1 1
1 0 0 0 0 0
1 0 1 0 0 0
1 1 0 1 0 1
1 1 1 1 0 1

Page 30 of 73
Solution
From the table, we see that the column for f contains four 1’s. They indicate the four
fundamental conjunctions needed in the d.n.f. of f , so

f (x, y, z) = x̄ȳz + x̄yz + xyz̄ + xyz

Another way to solve this problem is to take each product term appearing in f -namely,
xy and x̄z-and somehow involve whichever variables are missing. Using the properties
of these variables, we have xy+x̄z = xy(z+z̄)+x̄(y+ȳ)z (why)= xyz+xyz̄+x̄yz+x̄ȳy.

Example 5.1.14 Find the disjunctive normal form (d.n.f ) for

g(w, x, y, z) = wxȳ + wyz̄ + xy

Solution
We examine each term, as follows;

(i) wxȳ = wxȳ(z + z̄) = wxȳz + wxȳz̄

(ii) wyz̄ = w(x + x̄)yz̄ = wxyz̄ + wx̄yz̄

(iii) xy = (w + w̄)xy(z + z̄) = wxyz + wxyz̄ + w̄xyz + w̄xyz̄

It follows from the idempotent property of + that the d.n.f. of g is

g(w, x, y, z) = wxȳz + wxȳz̄ + wxyz̄ + wx̄yz̄ + wxyz + w̄xyz + w̄xyz̄.

Page 31 of 73
6 Proof Techniques
6.1 Mathematical Induction
6.1.1 Introduction
Consider a sequence of dominoes in the figure below;

Figure 1: The Game of Dominoes

Mathematical induction is one of the mathematical proof technique. It is essentially


used to prove that a statement P (n) holds for every natural number n ≥ 1 that is
overall statement is a sequence of infinitely many cases p(1), p(2), . . .
Definition 6.1.2 (Mathematical Induction) Mathematical induction is a math-
ematical technique which is used to prove a statement, a formula or a theorem is true
for every natural number.

6.1.3 Steps Involved in Proving By Mathematical Induction


The technique involves two steps to prove a statement, as stated below;

Type 1: Base Step


It proves that a statement is true for the initial value, say n = 1.

Type : Inductive Step


It proves that if the statement is true for the nth iteration (or number n = k) where k
is any positive integer, then it is also true for (n+1)th iteration (or number n = k +1,
for all k ∈ Z).

6.1.4 How To Do It
(i) Consider an initial value for which the statement is true, that is for n = 1.
(ii) Assume the statement is true for any value of n = k, k ∈ Z+ . Then prove the
statement is true for n = k + 1, where k is any positive integer. We actually
break n = k + 1 into two parts, one part is n = k (which is already proved) and
try to prove the other part.

Page 32 of 73
Transitive Property
The transitive property states that, if for all a, b, c ∈ R, suppose a < b and b < c,
then a < c.

For example: Suppose that


2 < 3, and 3 < 4
⇒2<3<4
⇒2<4

6.2 Examples
Example 6.2.1 Prove by mathematical induction that for all natural numbers n ∈ N
n(n + 1)
1 + 2 + 3 + ··· + n =
2
Proof:
We use mathematical induction to prove that
n(n + 1)
1 + 2 + 3 + ··· + n =
2
for all n ≥ 1.
Step 1: For n = 1: We have
1(1 + 1)
1 + 2 + 3 + ··· + 1 = =1
2
which is a true statement.

Step 2: Assume that the statement is true for n = k, where k ∈ Z. That is


k(k + 1)
1 + 2 + 3 + ··· + k = (1)
2
and prove that it is also true for n = k + 1, k ∈ Z. That is
(k + 1)(k + 2)
1 + 2 + 3 + · · · + k + (k + 1) = (2)
2
Deducing Equation (2) from Equation (1) we have;

(k)(k + 1)
1 + 2 + 3 + · · · + k + (k + 1) = +k+1
2
k(k + 1) + 2(k + 1)
=
2
(k + 1)(k + 2)
=
2

Page 33 of 73
which is exactly equal to Equation (2). Hence, deduced. Therefore, since the statement
is true for n = 1, n = k and n = k + 1 for k ∈ Z, then by Mathematical Induction
n(n + 1)
1 + 2 + 3 + ··· + n =
2
for all natural numbers n.
Example 6.2.2 Prove by mathematical induction that
n(n + 1)(2n + 1)
12 + 22 + 32 + · · · + n2 =
6
Proof:
To prove that
n(n + 1)(2n + 1)
12 + 22 + 32 + · · · + n2 =
6
Step 1: We first prove that this is true for all n = 1 that is
1(1 + 1)(2 × 1 + 1) 6
12 + 22 + 32 + · · · + 12 = = =1
6 6
which is a true statement.

Step 2: Assume that it is also true for n = k, where k ∈ Z. That is


k(k + 1)(2k + 1)
12 + 22 + 32 + · · · + k 2 = (3)
6
Now we need to show that it is also true for n = k + 1, k ∈ Z. That is
(k + 1)(k + 2)(2k + 3)
12 + 22 + 32 + · · · + (k + 1)2 = (4)
6
we do this by obtaining (deducing) Equation (4) from Equation (3) since from Equa-
tion (4) we know that,
12 + 22 + 32 + · · · + k 2 + (k + 1)2 (5)
k(k + 1)(2k + 1)
But k 2 = from Equation (3). Thus, it follows that
6

k(k + 1)(2k + 1) k(k + 1)(2k + 1) + 6(k + 1)2


12 + 22 + 32 + · · · + + (k + 1)2 =
6 6
(k + 1)[k(2k + 1) + 6(k + 1)2 ]
=
6
(k + 1)(2k 2 + k + 6k + 6)
=
6
2
(k + 1)(2k + 7k + 6)
=
6
(k + 1)(k + 2)(2k + 3)
=
6

Page 34 of 73
which is exactly equal to the required result in Equation (4). Since the statement is
true for n = 1, n = k and n = k + 1 k ∈ Z, then by mathematical induction:

n(n + 1)(2n + 1)
12 + 22 + 32 + · · · + n2 =
6
for all natural numbers.

Recall the transitive property that if a, b and b are natural numbers, then

(i) if a < b and b < c, then a < c

(ii) if a > b and b > c, then a > c

We prove the following results using mathematical induction.

Example 6.2.3 Prove that 2n > n for all positive integers n.

Solution
We use the principle of mathematical induction to prove that

2n > n

for all positive integers n.

Step 1: If n = 1, then we have


21 > 1
which is a true statement.

Step 2: We now assume that the statement is true for n = k, that is

2k > k for all k ∈ Z (6)

And then prove that the statement is true for all n = k + 1, k ∈ Z, that is

2k+1 > k + 1 for all n ∈ Z (7)

From Inequality (6) we have:

2k > k for all k ∈ Z

Deducing Inequality (7) from Inequality (6) we multiplying through Inequality (6) by
2 we get;
2 · 2k > 2k
⇒ 2k+1 > 2k
Since
2k+1 > 2k > k + 1

Page 35 of 73
then by the transitive property
2k+1 > k + 1
Hence deduced. Since the statement is true for n = 1, n = k and n = k + 1, then by
mathematical induction
2n > n for all n ≥ 1
for all integers.

Example 6.2.4 Prove by mathematical induction that

3n ≥ 2n + 1

Proof:
Step 1: If n = 1, we have
31 ≥ 2(1) + 1 = 3
which is a true statement.

Step 2: We assume that the statement is true for n = k, where k ∈ Z, that is

3k ≥ 2k + 1 (8)

and prove that the statement is also true for n = k + 1, where k ∈ Z. That is

3k+1 ≥ 2(k + 1) + 1 (9)

We start with the hypothesis to deduce Inequality (9) from Inequality (8). From;

3k ≥ 2k + 1

we multiply through by 3 to get

3(3k ) ≥ 3(2k + 1) ⇒ 3k+1 ≥ 6k + 3

Now since
3k+1 ≥ 6k + 3 ≥ 2k + 1
then by the transitive property we have

3k+1 ≥ 2k + 1

as required. Hence deduced. Now since the statement is true for n = 1, n = k and
for n = k + 1, then the statement is true for all positive integers.

Example 6.2.5 Use mathematical induction to prove thatn

2n ≥ n + 1.

Proof:
Step 1: If n = 1, then

2n ≥ n + 1 ⇒ 21 ≥ 1 + 1 = 2

Page 36 of 73
which is a true statement.

Step 2: We assume that the statement is true for n = k, that is

2k ≥ k + 1 for all k ∈ Z (10)

and prove that the statement is true for n = k + 1 for all k ∈ Z, that is

2k+1 ≥ k + 2 (11)

Using the assumption to deduce Inequality (11) we have: Since

2k ≥ k + 1

then we multiply by 2 through out then inequality we get

2(2k ) ≥ 2(k + 1) ⇒ 2k+1 ≥ 2k + 2

. Now
2k1 ≥ 2k + 2 ≥ k + 2
then by the transitive property we have

2k+1 ≥ k + 2.

Since the statement is true for n = 1, n = 1 and n = k + 1, then we can conclude


that
2n ≥ n + 1 for all n ∈ Z+

Example 6.2.6 Use mathematical induction to show that 4n − 1 is divisible by 3.

Solution
To show that 4n − 1 is divisible by 3;
Step 1: We first show that for n = 1, 4n − 1 is divisible by 3. Since if n = 1, we
have;
4n − 1 = 41 = 3
which is divisible by 3.

Step 2: Assume that the statement is true for n = k, that is

4k − 1, ∀ k ∈ Z (12)

is divisible by 3, and prove that the statement is true for n = k + 1, k ∈ Z, that is

4k+1 − 1 (13)

is divisible by 3. Starting with the assumption (12) to deduce the following statement
(13). Let x be any positive integer such that

4k − 1 = 3x.

Page 37 of 73
Then multiplying through by 4 we get;

4(4k − 1) = 4(3x)
⇒ 4k+1 − 4 = 12x
⇒ 4k+1 − 1 − 3 = 12x
⇒ 4k+1 − 1 = 12x + 3
⇒ 4k+1 − 1 = 3(4x + 1) (14)

Since the right hand side of (14) is divisible by 3, then 4k+1 − 1 is also divisible by
3. Therefore, since the statement is true for n = 1, n = k and n = k + 1, then we
conclude that 4k − 1 is divisible by 3 for all positive integers.

Example 6.2.7 Use mathematical induction to show that 6n − 1 is divisible by 5.

Solution
Step 1: If n = 1, then
6n − 1 = 61 − 1 = 5
which is divisible by 5. Hence true statement.

Step 2: Assume that the statement is true for n = k, k ∈ Z that is 6k − 1 is


divisible by 5, and prove that the statement is true for n = k + 1, k ∈ Z, that is

6k+1 − 1

is divisible by 5. Let m ∈ Z such that

6k − 1 = 5m

Then multiply through by 6 on both sides we get

6(6k − 1) = 6(5m)
⇒ 6k+1 − 6 = 30m
⇒ 6k+1 − 1 − 6 = 30m
⇒ 6k+1 − 1 = 30m + 5
⇒ 6k+1 − 1 = 5(6m + 1) (15)

Since the right hand side of equation 15 is divisible by 5, then 6k − 1 is also divisible
by 5. Now since the statement is true for n = 1, n = k and n = k + 1 then we
conclude that 6n − 1 is divisible by 5 for all positive integers n.

Page 38 of 73
7 Graphs Theory
7.1 Introduction to Graphs Theory
Imagine an organization that wants to set up teams of three to work on some projects.
In order to maximize the number of people on each team who had previous experience
working together successfully, the director asked the members to provide names of
their past partners. This information is displayed on Table 3:

Name Past Partners


Ana Dan, Flo
Bev Cai, Flo, Hal
Cai Bev, Flo
Dan Ana, Ed
Ed Dan, Hal
Flo Cai, Bev, Ana
Gia Hal
Hal Gia, Ed, Bev, Ira
Ira Hal

Table 3:

The information on Table 3 can also be represented by means of a diagram. See


Figure 2:

Figure 2:

As we can see from the drawing in Figure 2, it is possible for two edges to cross at a
point that is not a vertex. Note also that the type of graph described here is quite
different from the ”graph of an equation” or the ”graph of a function.” The edges

Page 39 of 73
may be straight or curved and should either connect one vertex to another or a vertex
to itself, as shown in Figure 3:

Figure 3:

In Figure 3, the vertices have been labelled with v ’s and the edges with e’s. When
an edge connects a vertex to itself (as e5 does), it is called a loop. When two edges
connect the same pair of vertices (as e2 and e3 do), they are said to be parallel. It is
quite possible for a vertex to be unconnected by an edge to any other vertex in the
graph (as v5 does), and in that case the vertex is said to be isolated.

Definition 7.1.1 (Graph) A graph G consists of two finite sets; a non-empty


V (G) of vertices and a possibly empty set E(G) of edges, where each edge is as-
sociated with 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.

Page 40 of 73
Example 7.1.2 Consider the following graph (see Figure 4):

Figure 4:

(i) Write the vertex set and the edge set, and give a table showing the edge-endpoint
function.

(ii) 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:

(i) vertex set = {v1 , v2 , v3 , v4 , v5 , v6 }


edge set = {e1 , e2 , e3 , e4 , e5 , e6 , e7 }
edge-endpoint function:

Edge Endpoints
e1 {v1 , v2 }
e2 {v1 , v3 }
e3 {v1 , v3 }
e4 {v2 , v3 }
e5 {v5 , v6 }
e6 {v5 }
e7 {v6 }

(ii) 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.

Page 41 of 73
Definition 7.1.3 (Directed Graph) A directed graph, or digraph, consists of
two finite sets; a nonempty set V (G) of vertices and a set E(G) of directed edges,
where each is associated with an ordered pair of vertices called endpoints. If edge e
is associated with the pair (u, v) of vertices, then e is said to be the directed edge
from u to v.

7.2 Graphs as Networks


Graphs are a powerful problem-solving tool because they enable us to represent a
complex situation with a single image that can be analysed both visually and with a
computer.

Telephone, electric power, gas pipeline, social network, and air transport systems
can all be represented by graphs, as can computer networks–from small local area
networks to the global internet system that connects millions of computers worldwide.

Questions that arise in the design of such systems involve choosing connecting edges
to minimize cost, optimize a certain type of service, and so forth.

A typical network, called a hub and smoke model, is shown below (see Figure 5):

Figure 5:

7.3 Special Graphs


Definition 7.3.1 (Simple Graph) A simple graph is a graph that does not have
any loops or parallel edges. In a simple graph, an edge with endpoints u and v is
denoted {u, v}.

Page 42 of 73
Example 7.3.2 (Some Examples of Simple Graphs) See Figure 6:

Figure 6:

Example 7.3.3 (A Simple Graph) Draw all simple graphs with four vertices {u, v, w, x}
and two edges, one of which is {u, v}.

Solution:
Each possible edge of a simple graph correspond to a subset of two vertices. Given
4

four vertices, there are 2 = 6 such subsets in all:
{u, v}, {u, w}, {u, x}, {v, w}, {v, x}, and {w, x}.

Figure 7:

Definition 7.3.4 (Complete Graph) Let n be a positive integer. A complete


graph on n vertices, denoted Kn , is a simple graph with n vertices and exactly one
edge connecting each pair of distinct vertices.

Example 7.3.5 (Some Examples of Complete Graphs) See Figure 8:

Figure 8:

Page 43 of 73
Definition 7.3.6 (Complete Bipartite Graph) Let m and n be positive integers.
A complete bipartite graph on (m, n) vertices, denoted Km,n , is a simple graph
with distinct vertices u1 , u2 , . . . , um and v1 , v2 , . . . , vn that satisfies the following prop-
erties: For all i, k = 1, 2, . . . , m and for all j, l = 1, 2, . . . , n,

(i) There is an edge from each vertex ui to each vertex vj .

(ii) There is no edge from any vertex ui to another vertex uk .

(iii) There is no edge from any vertex vj to another vertex vl .

Example 7.3.7 (Some Examples of Complete Bipartite Graphs) See Figure


9:

Figure 9:

Definition 7.3.8 (Subgraph) A graph H is said to be a subgraph of a graph G if,


and only if, every vertex in H is also a vertex in G, every edge in H is also an edge
in G, and every edge in H has the same endpoints as it has in G.

Example 7.3.9 (Subgraphs) List all subgraphs of the graph G with vertex set {v1 , v2 }
and edge set {e1 , e2 , e3 }, where the endpoints of e1 are v1 and v2 , the endpoints of e2
are v1 and v2 , and e3 is a loop at v1 .

Page 44 of 73
Solution:
G can be drawn as shown below (see Figure 10):

Figure 10:

There are 11 subgraphs of G, which can be grouped according to those that do not have
any edges, those that have one edge, those that have two edges, and those that have
three edges. The 11 subgraphs are shown in Figure 10:

7.4 Operations in Graphs


There are several operations we can perform om graphs in order to form new ones.
The simplest of these is to form their union. In the following definitions, we assume
G1 and G2 are two graphs with disjoint vertex sets.
Definition 7.4.1 (Union) The union G = G1 ∪ G2 has V (G) = V (G1 ) ∪ V (G2 )
and E(G) = E(G1 ) ∪ E(G2 ). If a graph G consists of k (≥ 2) disjoint copies of a
graph H, then we write G = kH.
The graph 2K1 ∪ 3K2 ∪ K1,3 is shown in Figure 11:

Figure 11: The union of graphs

Definition 7.4.2 (Join) The joint G = G1 + G2 has V (G) = V (G1 ) ∪ V (G2 ) and
E(G) = E(G1 ) ∪ E(G2 ) ∪ {vw | v ∈ V (G1 ) and w ∈ V (G2 )}.
The graph G = G1 + G2 = K2 + K3 is shown in Figure 12:

Page 45 of 73
Figure 12: The join of two graphs

Definition 7.4.3 (Cartesian Product) The Cartesian product G = G1 × G2 has


V (G) = V (G1 ) × V (G2 ) and two vertices (v1 , v2 ) and (w1 , w2 ) are adjacent if, and
only if, either

v1 = w1 and v2 w2 ∈ E(G2 )

or

v2 = w2 and v1 w1 ∈ E(G1 ).

The Cartesian product of G1 × G2 can be constructed by placing a copy of G2 at each


vertex of G2 and adding the appropriate edges. For example, K2 × K3 is shown in
Figure 13:

Figure 13:

Definition 7.4.4 (Complement) If G is a graph, we form its complement G by


taking the vertex set of G and joining two vertices by an edge whenever they are not
joined in G.

For example, the compliment of Kn is Kn . Figure 14 shows a graph G and its


compliment G. Note that if we take the complement of G, then we get back the
original graph G.

Page 46 of 73
Figure 14: A graph and its complement

7.5 The Concept of Degree of a Graph


Definition 7.5.1 (Degree of a Vertex) Let G be a graph and v a vertex of G. The
degree of v, denoted deg v, equals the number of edges that are incident on v, with
an edge that is a loop counted twice. The total degree of G is the sum of the degrees
of all the vertices of G.

An example is given in Figure 15:

Figure 15:

Example 7.5.2 (Degree of a Vertex and Total Degree of a Graph) Find the
degree of each vertex of the graph G shown below (in Figure 16). Then find the total
degree of G.

Page 47 of 73
Figure 16:

Solution:
deg v1 = 0 since no edge is incident on v1 .
deg v2 = 2 since both e1 and e2 are incident on v2 .
deg v3 = 4.
total degree of G = deg v1 + deg v2 + deg v3 = 0 + 2 + 4 = 6.

Note that the total degree of a graph G equals twice the number of edges of G.
Roughly speaking, this is true because each edge has two end segments, and each end
segment is counted once towards the degree of some vertex. In fact, for any graph
without loops, the general result can be explained as follows: Imagine a group of
people at a party. Depending on how social they are, each person shakes hands with
various other people.

1 edge ≡ 1 handshake by two different people


1 vertex ≡ 1 person.

Theorem 7.5.3 (The Handshake Theorem) If G is any graph, then the sum of
the degrees of all vertices of G equals twice the number of edges of G. Specifically, if
the vertices of G are v1 , v2 , . . . , vn , where n is a nonnegative integer, then

the total degree of G = deg v1 + deg v2 + · · · + deg vn


= 2 · (the number of edges of G).

Corollary 7.5.4 (Deduction) The total degree of a graph is even.

Proposition 7.5.5 (Deduction) In any graph, there are an even number of vertices
of odd degree.

Page 48 of 73
It is often convenient to list the degrees of vertices of a graph; this is usually done
by writing them in nonincreasing order (that is, in decreasing order but allowing
’repeats’ where necessary). The resulting list is called the degree sequence of a graph.
Given a graph G, the degree sequence of G can be easily determined (we simply find
the degree of each of its vertices). For example, the graph in Figure 17 has degree
sequence 5, 4, 3, 3, 2, 2, 1, 1, 1, 0. Now we may be wondering if we can be able to draw
a graph G, given the degree sequence s. Now this leads us to the following definition:

Figure 17: A graph with the degrees of its vertices

Definition 7.5.6 (Graphical) A sequence of integers is said to be graphical if it


is the degree sequence of some graph. A graph G with degree sequence s is called a
realization of s.

Theorem 7.5.7 (Havel-Hakimi) A nonincreasing sequence of nonnegative inte-


gers s : d1 , d2 , . . . , dn is graphical if and only if the sequence s1 : d2 − 1, d3 −
1, . . . , dd1 +1 − 1, dd1 +2 , . . . , dn (n ≥ 2) is graphical.

With the aid of Theorem 7.5.7, we may now present a procedure, or algorithm, that
allows us to determine whether a finite sequence of nonnegative integers is graphical
or not.

7.5.8 Havel-Hakimi Algorithm


Given a sequence of n(≥ 1) non-negative integers:

(i) If some integer in the sequence exceeds n − 1, the the sequence is not graphical.

(ii) If all the integers in the sequence are 0, then the sequence is graphical.

(iii) If the sequence contains a negative integer, then the sequence is not graphical.

(v) Reorder the sequence (if necessary) so that it is nonincreasing.

(iv) Delete the first number, say t, from the sequence and subtract 1 from the next
t numbers in the sequence to form a new sequence. Return to step 2.

Page 49 of 73
To illustrate Algorithm 7.5.8, consider the sequence:

s : 4, 4, 4, 3, 3, 2.

Step 1 is satisfied, and we begin the loop of Step 2 to 5. The tests in Step 2 and 3
do not immediately halt us. Proceeding to Step 5, we get

s01 = 3, 3, 2, 2, 2
s1 = 3, 3, 2, 2, 2. re-orderring

Continuing to apply Algorithm 9.5.7, we have

s02 = 2, 1, 1, 2
s2 = 2, 2, 1, 1. re-orderring

s03 = 1, 0, 1
s3 = 1, 1, 0. re-orderring

s04 = 0, 0
s4 = 0, 0. re-orderring

Algorithm 7.5.8 shows that s is graphical, since 0, 0 is the degree sequence of the
empty graph K2 on two vertices.

To construct a graph with degree sequence s1 , we proceed in reverse from s02 to


s1 , observing that a vertex should be added to G2 so that it is adjacent to one vertex
of degree 2 and two vertices of degree 1 in G2 . We therefore obtain a graph G1 with
degree sequence s1 . Proceeding from s01 to s, we again add a new vertex joining it
to two vertices of degree 3 and two vertices of degree 2 in G1 . This gives a graph G
with degree sequence s.

Figure 18: Construction of a a graph G with a given degree sequence.

It should be pointed out that the graph G in Figure 18 is not the only graph with
degree sequence s. The graphs G and H in Figure 19 both have the same degree
sequence, namely 2, 2, 2, 2, 2, 2. So degree sequences do not always provide enough
information to uniquely describe a graph.

Page 50 of 73
Figure 19: Two graphs with the same degree sequence 2, 2, 2, 2, 2, 2.

7.6 Walks, Trails, Paths, and Circuits


Probably the oldest and best known of all problems in graph theory is the problem
of the seven Königsberg bridges. In the eighteenth century, the medieval city of
Königsberg in Eastern Prussia contained a central island called Kneiphof, around
which the river of Pregel flowed before dividing into two. The four parts of the city
were interconnected by seven bridges, as shown in Figure 20. The legend says that
the citizens of Königsberg amused themselves by trying to find a route crossing each
bridge exactly once, and returning to the starting point. Can this be done?

Figure 20: The seven bridges of Königsberg

Thus for the purpose of solving the puzzle, the map of Königsberg can be identified
with the graph shown in Figure 21 where the vertices A, B, C, and D represent the
land masses and the seven edges represent the seven bridges.

Figure 21: Graph Version of Königsberg Map

Page 51 of 73
In terms of this graph, the question becomes the following: It is possible find a
route through the graph that starts and ends at some vertex, one of A, B, C, or D,
and traverses each edge exactly once? Equivalently: Is it possible to trace this graph,
starting and ending at the same point, without ever lifting our pencil from the paper?

If we start at vertex A, for example, each time we pass through vertex B, C, or D, we


use up to two edges because we arrive on one edge and depart on a different one. So,
if it is possible to find a route that uses all the edges of the graph and starts and ends
at A, then the total number of arrivals and departures from each vertex B, C, and D
must be a multiple of 2. That is, the degree of the vertices B, C, and D must be even.

However, they are not all even: deg B = 5, deg C = 3, and deg D = 3. Hence
there is no route that solves the puzzle by starting and ending at A. Similarly when
starting at B, C, or D.

Definition 7.6.1 (Walk, Trails, Paths, and Circuits) Let G be a graph and let
v and w be vertices in G.

A walk from v and w is a finite alternating sequence of adjacent vertices and


edges of G. Thus a walk has the form

v0 e1 v1 e2 · · · vn−1 en vn .

where the v’s represent vertices,the e’s represent edges, v0 = v, vn = w, and for all
i = 1, 2, . . . , n, vi−1 and vi are endpoints of ei . The trivial walk from v to w consists
of the single vertex v.

A trail from v to w is a walk from v to w that does not contain a repeated edge.

A path from v to w is a trail from v to w that does not contain a repeated vertex.

A closed walk is a walk that starts and ends at the same vertex.

A circuit is a closed walk is a closed walk that contains at least one edge and does
not contain a repeated edge.

A simple circuit is a circuit that does not have any repeated vertex except the first
and last.

Page 52 of 73
For ease of reference, these definitions are summarized in Table 4:

Repeated Repeated Starts and Ends Must Contain at


Edge? Vertex? at Same Point? Least One Edge?
Walk allowed allowed allowed no
Trail no allowed allowed no
Path no no no no
Closed walk allowed allowed yes no
Circuit no allowed yes yes
Simple circuit no first and last only yes yes

Table 4:

Often a walk can be specified unambiguously by giving either a sequence of edges or


a sequence of vertices.
Example 7.6.2 (Walks, Trails, Paths, and Circuits) In the graph below, deter-
mine which of the following walks are trails, paths, circuits, or simple circuits.

Figure 22:

(i)
v1 e1 v2 e3 v3 e4 v3 e5 v4

(ii)
e1 e3 e5 e5 e6

(iii)
v2 v3 v4 v5 v3 v6 v2

(iv)
v2 v3 v4 v5 v6 v2

(v)
v1 e1 v2 e1 v1

Page 53 of 73
(vi)
v1

Solution:
(i) This is a trail from v1 to v4 .
(ii) This is just a walk from v1 to v5 .
(iii) This is a circuit.
(iv) This is a simple circuit (also known as a cycle).
(v) This is a closed walk.
(vi) This is a closed walk from v1 to v1 .

7.7 Connectedness
A graph is connected if it is possible to travel from any vertex to any other vertex
along a sequence of adjacent edges of the graph.
Definition 7.7.1 (Connectedness) Let G be a graph. Two vertices v and w of
G are connected if, and only if, there is a walk from v to w. The graph G is
connected if, and only if, given any two vertices v and w in G, there is a walk from
v to w. Symbolically,

G is connected if and only if for all vertices v, w ∈ V (G), ∃ a walk from v to w.

If we take the negation of this definition, we will see that a graph G is not connected
if, and only if, there are two vertices of G that are not connected by any walk.
Example 7.7.2 (Connected and Disconnected Graphs) Which of the follow-
ing graphs are connected?

Figure 23:

Solution:
The graph of (a) is connected, whereas those of (b) and (c) are disconnected. To
understand why (c) is not connected, recall that in a drawing of a graph, two edges
may cross at a point that is not a vertex. Thus the graph in (c) can be redrawn as
follows (see Figure 24):

Page 54 of 73
Figure 24:

Some useful facts relating circuits and connectedness are collected in the following
lemma.

Lemma 7.7.3 (Circuits and Connectedness) Let G be a graph.

(i) If G is connected, then any two distinct vertices of G can be connected by a


path.

(ii) If vertices v and w are part of a circuit in G and one edge is removed from the
circuit, then there still exists a trail from v to w in G.

(iii) If G is connected and G contains a circuit, then an edge of the circuit can be
removed without disconnecting G.

The graphs in (b) and (c) are both made up of three pieces, each of which is itself
a connected graph. A connected component of a graph is a connected subgraph of
largest possible size.

Definition 7.7.4 (Connected Component) A graph H is a connected component


of a graph G if, and only if,

(i) H is a subgraph of G.

(ii) H is connected; and

(iii) no connected subgraph of G has H as a subgraph and contains vertices or edges


that are not in H.

The fact is that any graph is a kind of union of its connected components.

Page 55 of 73
Example 7.7.5 (Connected Components) Find all connected components of the
following graph G (see Figure 25):

Figure 25:

Solution:
G has three connected components: H1 , H2 , and H3 with vertex sets V1 , V2 , and V3
and edge sets E1 , E2 , and E3 , where

V1 = {v1 , v2 , v3 } E1 = {e1 , e2 }
V2 = {v4 } E2 = ∅
V3 = {v5 , v6 , v7 , v8 } E3 = {e3 , e4 , e5 }

7.8 Euler Circuits


Now we return to consider the general problems similar to the puzzle of the Königsberg
bridges. The following definition is made in honor of Leonhard Euler:

Definition 7.8.1 (Euler Circuit) Let G be a graph. An Euler circuit for G is a


circuit that contains every vertex and every edge of G. That is, an Euler circuit for
G is a sequence of adjacent vertices and edges in G that has at least one edge, starts
and ends at the same vertex, uses every vertex of G at least once, and uses every edge
of G exactly once.

Page 56 of 73
Consider the graph shown in Figure 26:

Figure 26:

The Euler circuit is shown in the graph above (see Figure 26) is:

v0 , v1 , v2 , v3 , v4 , v2 , v5 , v0 .

The analysis used earlier to solve the puzzle of the Königsberg bridges generalizes to
prove the following theorem:

Theorem 7.8.2 (Euler Circuit) If a graph has an Euler circuit, then every vertex
of the graph has positive even degree.

Contrapositive of Theorem 7.8.2 is logically equivalent to the following statement:

Contrapositive Version of Theorem 7.8.2

If some vertex of a graph has odd degree, then the graph does not have an Euler
circuit.

The contrapositive version of Theorem 7.8.2 is useful for showing that a given graph
does not have an Euler circuit.

Page 57 of 73
Example 7.8.3 (Showing That a Graph Does Not Have an Euler Circuit)
Consider the graph in Figure 27. Show that the graph does not have an Euler circuit.

Figure 27:

Solution:
Vertices v1 and v3 both have degree 3, which is odd. Hence by (the contrapositive form
of ) Theorem 7.8.2, this graph does not have an Euler circuit.

Now consider the converse of Theorem 7.8.2: If every vertex of a graph has even
degree, then the graph has an Euler circuit. Is this converse true?

The answer is no. Use counter-example to show: There is a graph G such that every
vertex of G has even degree but G does not have an Euler circuit. The illustration in
Figure 28 is such a counter-example.

Figure 28:

Note that the graph in the preceding drawing is not connected. It turns out that
although the converse of Theorem 7.8.2 is false, a modified converse is true:

Page 58 of 73
If every vertex of a graph has positive even degree and the graph is connected, then
the graph has an Euler circuit.

7.9 Distance in Graphs


The distance between two vertices in a graph is defined as follows:
Definition 7.9.1 (Distance in Graphs) For a connected graph G, we define the
distance d(u, v) between two vertices u and v as the minimum of the lengths of the
u−v paths of G. If G is a disconnected graph, then the distance between two vertices of
the same component of G is defined as above. However, if u and v belong to different
components of G, then d(u, v) is undefined (or we could define d(u, v) = ∞).
For the graph G of Figure 29, d(x, u) = 2, d(x, w) = 3 while d(x, v) = 5.

Figure 29:

The distance function d(u, v) on pairs of vertices is a metric, that is, it satisfies the
following fundamental properties:
Theorem 7.9.2 (The Distance Function) Let G be a graph and let u, v, w ∈ V (G).
Then
(i) d(u, v) ≥ 0 and d(u, v) = 0 if and only if u = v;
(ii) d(u, v) = d(v, u) (symmetric property);
(iii) d(u, v) ≤ d(u, w) + d(w, v) (triangle inequality).

7.10 Cut-vertices and Bridges


Some graphs are connected so slightly that they can be disconnected by deleting a
single vertex or a single edge. Such vertices and edges play a special role in graph
theory. and we discuss these next.
Definition 7.10.1 (Slightly Connected Graphs) If e is an edge of a graph G,
then G − e is the subgraph of G possessing the same vertex set as G and having all
the edges except e. If v is a vertex of a graph G containing at least two vertices, then
G − v is the subgraph of G whose vertex set consists of all vertices of G except v
and whose edge set consists of all edges of G except those incident with v. Figure 30
illustrates these concepts.

Page 59 of 73
Figure 30:

Definition 7.10.2 (Cut-vertices and Bridges) A vertex v in a graph G is called


a cut-vertex of G if k(G − v) > k(G). So, if G is a connected graph, then v is cut-
vertex if G − v is disconnected. Analogous to the cut-vertex is the concept of a bridge.
An edge e is a bridge if k(G − e) > k(G). Therefore, if G is a connected graph, then
e is a bridge if G − e is disconnected.
The vertex v3 of the graph G in Figure 30 is cut-vertex; however, no other vertex of
the graph is a cut-vertex. The edge e4 of the graph of the graph G in Figure 30 is a
bridge, but no other edge of that graph is a bridge. If v is a cut-vertex of a connected
graph G, then G − v contains two or more components. However, if e is a bridge of
a connected graph G, then G − e contains exactly two components.
Theorem 7.10.3 (Cut-vertex) A vertex v of a connected graph G is a cut-vertex
of G if and only if there exists vertices u and w (u 6= w) such that v is on every u − w
path.
Theorem 7.10.4 (Bridge) An edge e of a connected graph G is a bridge of G if
6 w) such that e is on every u − w path.
and only if there exists vertices u and w (u =
For bridges, there is another useful characterization.
Theorem 7.10.5 (Useful characterization for bridges) Let G be a connected graph.
An edge e of G is a bridge if and only if e does not lie on any cycle of G.

7.11 The Shortest Path Algorithm


Consider the following problem: A traveller wishes to drive from Kitwe to Lusaka.
Given that the traveller has a map of Zambia that shows the distance between par-
ticular pairs of cities or towns, how does the traveller determine the shortest possible
route?

In this particular example, it may not be too difficult to find the solution by intelligent
guesswork, but such an approach is less likely to succeed as the road network becomes
more and more complicated. In the section we describe an efficient algorithm which
can be used to find the shortest path between any two vertices in a graph.

Page 60 of 73
7.12 Distance in Weighted Graphs
Before introducing the shortest path algorithm, we will need to generalise the concept
of distance in a graph.

Definition 7.12.1 (Weighted Graph) A weighted graph is graph in which each


edge e is assigned a positive real number, called the weight of e, and denoted by
w(e). The length of a path P in a weighted graph G is the sum of the weights of the
edges of G. For connected vertices u and v of the weighted graph G, the distance
d(u, v) between u and v is the minimum of the lengths of the u − v paths of G. A
u − v path of minimum weight in G is called a shortest u − v path for G (so that a
path containing three edges, each of weight one, is ”shorter” than a path containing
two edges, each of weight two).

Consider the weighted graph G of Figure 31. The path P : v2 , v1 , v3 , v4 is a shortest


v2 − v4 path (of length 4). Notice that the path Q : v2 , v3 , v5 (of length 5) is not a
shortest v2 − v4 path for G, even though Q has fewer edges than P .

For example, an airline service can be represented by a weighted graph with the
vertices representing the cities serviced, edges representing the direct flying routes,
and with the weight of an edge being the cost of a direct fight. Finding the distance
between two vertices in this weighted graph corresponds to finding the minimum cost
of flying from one city to another, while a shortest path is a flying route between two
cities with the lowest cost.

Definition 7.12.2 (The Weight Matrix) Let G be a weighted graph with vertex
set V (G) = {v1 , v2 , . . . , vp }. It is convenient to represent G by means of a weight
matrix W (G) defined as follows: W (G) = (wi,j ) is p × p matrix, where
(
w(vi vj ) if vi vj ∈ E(G)
wi,j =
∞ if vi vj ∈
/ E(G).

(By 0 ∞0 we shall mean a number larger than any weight actually occurring in our
calculations.) For example, a graph and its weight matrix are shown in Figure 31,
where the weights of edges are indicated in the diagram.

Figure 31:

Page 61 of 73
7.13 Dijkstra’s Algorithm
We now introduce an algorithm, due to Dijkstra (1959), which determines, for a fixed
vertex x in a connected weighted graph G, the distance d(x, v) from x to each vertex
v of G, as well as a shortest x − v path in G. We shall write w(e) = ∞ if e ∈
/ E(G),
i.e, w(uv) = ∞ if u and v are non-adjacent vertices of G.

The idea of Dijkstra?s algorithm is to modify labels l(v) attached to the vertices,
where l(v) represents the length of the shortest x − v path presently known. As we
proceed, we reduce these labels as shorter paths are found from x to v.

7.13.1 Dijkstra’s Algorithm


Given a connected weighted graph G of order n and a vertex x of G:

(i) Set l(x) = 0 and for all v 6= x, set l(v) = ∞ and set S = V (G).

(ii) If |S| = 1, then stop; otherwise, continue.

(iii) Among all the vertices in S, let u be the one of minimum label l(u).

(iv) For each v ∈ S, if uv ∈ E(G) and l(u) + w(uv) < l(v), then

• replace l(v) by l(u) + w(uv), and


• assign to parent(v) the label u.

(v) Remove u from S, and return to Step 2.

As an example, we apply Dijkstra’s algorithm to the graph G of Figure 31 to determine


the distance from the vertex x = v1 to every other vertex of G and to find a shortest
x − vi ) path for i = 1, 2, 3, 4. Table 5 has three columns corresponding to the vertices
v2 , v3 , v4 . The ordered pairs in the columns corresponding to the vertex vi indicate
(l(vi ), parent(vi )) for i = 2, 3, 4 at a given point in the algorithm.

l(v) v2 v3 v4 removed from S S


0 (∞, −) (∞, −) (∞, −) − {x, v2 , v3 , v4 }
(1, x) (2, x) (5, x) x {v2 , v3 , v4 }
(2, x) (5, x) v2 {v3 , v4 }
(3, v3 ) v3 {v4 }

Table 5:

Our results may be summarized as shown in Table 6. Using Table 5 we obtain, for
each i = 2, 3, 4, the distance from x = v1 to vi and a shortest x − vi path Pi .

Page 62 of 73
v d(x, v) Pi
v2 l(v2 ) = 1 x, v2
v3 l(v3 ) = 2 x, v3
v4 l(v4 ) = 3 x, v3 , v4

Table 6:

7.14 Trees and Forests


Suppose we have a collection of n cities, and we wish to construct a railway sys-
tem connecting them. Hence a passenger must be able to ride from any station in
the system to any other station. Assume that we know the cost of building tracks
between every two cities. How can we build the railway system as cheaply as possible?

The desired railway system can be represented by a graph whose vertices correspond
to cities involved and which two vertices are adjacent if a track runs between the two
corresponding cities. The edges are labelled (weighted) with their proposed costs.
To solve this problem, we must find a connected graph (so that all stations can be
reached from all other stations) with the minimum sum of the edge weights. This is
called the Minimum Connector Problem.

Note that to construct a graph with minimum edge weight sum, we must avoid
cycles, since otherwise we could remove the most expensive edge (largest weight) on
the cycle, obtaining a new connected graph with smaller weight sum. Hence, it would
be possible to leave out a set of tracks between two cities and still have all cities con-
nected, implying that the original railway system is not the cheapest. Thus, what we
desire is a connected acyclic graph with minimum possible edge weight sum. Be-
fore solving the Minimum Connector Problem, we need to investigate in more detail
the type of graph we have just encountered.

Figure 32:

Definition 7.14.1 (Tree, Forest) A tree is a connected graph which contains no


cycles. A forest is a graph that has no cycles (so each component of a forest is a
tree).

Figure 32 shows three trees. Trees are the simplest connected graphs. These graphs
are perhaps the most useful of all special classes of graphs. Recently, there has been

Page 63 of 73
considerable interest in tree structures arising in computer sciences and artificial intel-
ligence. We often meet such structures when organising data in a computer memory
store or when organising the flow of information through a system. Trees also have
applications in chemistry (for example, in counting alkanes Cn H2n+2 ), sociology, and
many other studies. In computer programming and switching theory, we frequently
deal with decision trees with only two alternatives at each intermediate vertex. We
will discuss mainly the application of trees in this section.

7.15 Properties of Trees


Since a tree contains no cycles, it follows from Theorem 7.10.4 that every edge of a
tree is a bridge. Trees have several pleasing properties - for example, any two vertices
of a tree are connected by exactly one path.

Theorem 7.15.1 (Path Uniqueness)


A graph T is a tree if and only if every two distinct vertices are joined by a unique
path.

Theorem 7.15.2 (Size of a tree) A tree T of order n has size m = n − 1.

Proof We prove by induction on n. If n = 1, then T ∼ = K1 and T has size m = 0,


as required. Let k ≥ 2 be an integer, and suppose the result is true for all trees of
order n < k. Let T be a tree of order n = k and size m, let e = uv be an edge of
T . Since every edge of a tree is a bridge, the graph T − e is disconnected. In fact,
T − e is a forest with exactly two components, namely a tree T1 containing u and
a tree T2 containing v. Let Ti (i = 1, 2) be a tree of order ni and size mi . Then
ni < k (i = 1, 2). Hence, by inductive hypothesis, we know that mi = ni − 1 for
i = 1, 2. Since n = n1 + n2 and m = m1 + m2 + 1 (the + 1 is for the removed edge e),

m = (n1 − 1) + (n2 − 1) + 1
= n1 + n2 − 1
=n−1

Thus, by induction, the size of a tree is one less than its order.

Theorem 7.15.3 (Equivalent statements) Let T be a graph of order n. Then the


following statements are equivalent:

(i) T is a tree;

(ii) T is connected and has size n − 1;

(iii) T has no cycles and has size n − 1.

Theorem 7.15.4 (Tree, End-vertices) Every nontrivial tree contains at least two
end-vertices.

Page 64 of 73
7.16 Constructing Mininum Spanning Tree
In this subsection, we return to the Minimum Connector Problem. First we shall
need the concept of a spanning tree of a connected graph.
Definition 7.16.1 (Spanning tree, Spanning forest)
A spanning tree of a connected graph G is a tree that is a subgraph of G that contains
all the vertices of G. A spanning forest of a graph G is a forest that is a subgraph of
G that contains all the vertices of G.
A connected graph may actually have several nonisomorphic spanning trees. Figure
33 shows a graph G and three of its spanning trees T1 , T2 and T3 .

Figure 33:

Every connected graph G contains a spanning tree. We can find such a spanning tree
as follows: If G has no cycles, then the graph G itself is a spanning tree. If there are
cycles in G, then choose any cycle in G and remove one of its edges. By removing
one cycle edge in G, we still remain with a connected graph. We now repeat this
procedure, removing cycle edges one at a time, until finally only bridges remain; this
gives our spanning tree. So it is easy to find a spanning tree in a connected graph.
However, a much stronger statement can be made.
Definition 7.16.2 (Distance preserving) A spanning tree T of a connected graph
G is said to be distance preserving from a vertex v in G if dT (u, v) = dG (u, v) for
every vertex u.

Theorem 7.16.3 (Distance preserving) For every vertex v of a connected graph


G, there exists a spanning tree that is distance preserving from v.

Figure 34:

There are a number of applications involving spanning trees in connected graphs.

Page 65 of 73
Definition 7.16.4 (Minimum spanning tree)
The weight w(H) of a subgraph H of a weighted graph is the sum of the weights of the
edges of H. A minimum spanning tree of a connected weighted graph is a spanning
tree of minimum weight in the graph.

We now restate the Minimum Connector Problem in graphical terms.

The Minimum Connector Problem: Given a connected weighted graph, find


a minimum spanning tree in it.

The Minimum Connector Problem is perhaps one of the best known problems in
combinatorial optimisation. Many practical problems involve connected weighted
graphs in which it is necessary to find a minimum spanning tree. Consider, for exam-
ple, a graph where each vertex represents a village, and an edge between two vertices
represents a road between the corresponding villages. The length of such a road is
indicated in the graph by assigning a weight to the corresponding edge. Telephone
line must be built along some existing roads that connect the villages with each other.
We wish to erect these telephone line in such a way that every pair of villages can
communicate by telephone. Moreover, the total number of kilometers of telephone
lines is to be minimised. The problem with which we are faced is to determine along
which roads these telephone lines should be erected to produce the desired system.
This amounts to finding the a minimum spanning tree in the connected weighted
graph.

A number of algorithmic solutions to the Minimum Connector Problem have been


given. Perhaps the most famous of these algorithms is one due to Kruskal in 1956.
The strategy of the algorithm is very simple. We begin by choosing an edge of mini-
mum weight that does not form a cycle with any of the edges we have already chosen.
We continue in this fashion until a spanning tree is formed.

7.16.5 Kruskal’s Algorithim


To construct a minimum spanning tree in a connected weighted graph G, successfully
choose edges of G of minimum weight in such a way that no cycles are created.

Kruskal’s algorithm is an example of a type of algorithm known as a greedy algo-


rithm. This name arises from the fact that at each stage we make the greediest choice
available (that is, the edge involving the smallest weight) with no concern for what
is happening else where in the graph. Algorithms of this kind can sometimes work
very well as we will show in the case of Kruskal’s algorithm. However, in practice,
the greedy approach does not always succeed.

Page 66 of 73
To illustrate Kruskal’s algorithm, we find a minimum spanning tree in the connected
weighted graph G shown in Figure 35.

Figure 35:

First Choice: We choose an edge of minimum weight; this is de with weight 1.

Second Choice: We choose an edge of next smallest weight; this is either bc or


cg with weight 2. Let us choose bc.

Third Choice: We choose an edge of next smallest weight; this is cg of weight


2.

Fourth Choice: We cannot now choose bg, since it would create a cycle, namely
b, c, g, b. So we choose an edge of next smallest weight different from bg; this is either
cd or eg with weight 3. Let us choose cd.

Fifth Choice: We cannot now include eg in the tree, since it would create a
cycle (c, d, e, g, c). The edge of next smallest weight is dg with weight 4. Since this
edge would create a cycle (c, d, g, c), we choose instead one of the edges ab, ag, or af
with weight 6. Let us choose ag.

Sixth Choice: The edges of next smallest weight are ab and af with weight 6.
Since ab would create a cycle (a, b, c, g, a), we choose af .

This completes the spanning tree T , since the addition of any further edge would
create a cycle. The tree T (shown in Figure 36) is a minimum spanning tree of weight

w(T ) = w(de) + w(bc) + w(cg) + w(cd) + w(ag) + w(af )


=1+2+2+3+6+6
= 20.

Page 67 of 73
Figure 36:

It is clear that Kruskal’s algorithm will produce a minimum spanning tree of any
connected weighted graph to which it is applied. It is not obvious, though, that it
produces a minimum spanning tree.

Theorem 7.16.6 (Spanning tree, Kruskal’s algorithm) Kruskal’s algorithm pro-


duces a minimum spanning tree in a nontrivial connected weighted graph.

7.17 Hamiltonian Circuits


Theorem 7.17.1 completely answers the following question:

Given a graph G, is it possible to find a circuit for G in which all the edges of G
appear exactly once?

Theorem 7.17.1 (Euler Circuit) A graph G has an Euler circuit if, and only if,
G is connected and every vertex of G has positive even degree.

A related question to this:

Given a graph G, is it possible to find a circuit for G in which all the vertices of
G (except the first and the last) appear exactly once?

Page 68 of 73
In 1859, the Irish mathematician Sir William Rowan Hamilton introduced a puzzle
in the shape of a dodecahedron (DOH-dek-a-HEE-dron). A dodecahedron is a solid
figure with 12 identical pentagonal faces. See Figure 37:

Figure 37:

Hamilton labelled each vertex with the name of a city–eg Lusaka, Kitwe, Kabwe,
Luanshya, and so on. The problem Hamilton posed was:

Is it possible to start at one city and tour the country by visiting each other city
exactly once and return to the starting city?

Page 69 of 73
One way to solve the puzzle is to imagine the surface of the dodecahedron stretched
out and laid flat in a plane as in Figure 38:

Figure 38:

The circuit denoted in black lines is one solution. Note that although every city is
visited, many edges are not included in the circuit hence this is not an Euler circuit.
The following definition is made in honor of William Rowan Hamilton:
Definition 7.17.2 (Hamiltonian Circuit) Given a graph G, a Hamiltonian cir-
cuit for G is a simple circuit that includes every vertex of G. That is, a Hamiltonian
circuit for G is a sequence of adjacent vertices and distinct edges in which every vertex
of G appears exactly once, except for the first and the last, which are the same.
Note that an Euler circuit for a graph G:
(i) Must include every vertex and every edge of G.

(ii) May visit some vertices more than once.


On the other hand, a Hamiltonian circuit for G:
(i) May not include all the edges of G.

(ii) Must visit every vertex exactly once except the start and end vertex.
Hence a Hamilton circuit may not be an Euler circuit.

To check whether G has an Euler circuit, we use Theorem 7.17.1. For checking a
Hamiltonian circuit, where G has at least two vertices, there is following:
Proposition 7.17.3 (Hamiltonian Circuit) If a graph G has a Hamiltonian cir-
cuit, then G has a subgraph H with the following properties:
(i) H contains every vertex of G.

Page 70 of 73
(ii) H is connected.

(iii) H has the same number of edges as vertices.

(iv) Every vertex of H has degree 2.

An example of a subgraph H with properties (i)-(iv) is shown in Figure 39:

Figure 39:

Note that H has the same number of edges as it has vertices since all its 8 edges are
distinct and so are its 8 vertices v1 , v2 , . . . , v8 and back to v1 . Also, by definition of
Hamiltonian circuit, every vertex of G is a vertex of H, and H is connected since any
two of its vertices lie on a circuit. In addition, every vertex of H has degree 2.

Contrapositive of Proposition 7.17.3 is logically equivalent to the following statement:

Contrapositive Version of Proposition 7.17.3

If a graph G does not have a subgraph H with properties (1)-(4), then G does not
have a Hamiltonian circuit.

The contrapositive is very useful to show that a graph does not have a Hamiltonian
circuit.

Page 71 of 73
Example 7.17.4 (A Travelling Salesman Problem) This example illustrates a
type of problem known as a travelling salesman problem. It is a variation of the
problem of finding a Hamiltonian circuit for a graph. Consider a map showing four
cities A, B, C, and D and the distances in kilometres between them (see Figure 40).

Figure 40:

Suppose that a salesman must travel to each city exactly once, starting and ending in
city A. Which route from city to city will minimize the total distance that must be
travelled?

Solution:
The problem can be solved by writing all possible Hamiltonian circuits starting and
ending at A and calculating the total distance travelled for each.
Route Total Distance (In Kilometres)
ABCDA 30 + 30 + 25 + 40 = 125
ABDCA 30 + 35 + 25 + 50 = 140
ACBDA 50 + 30 + 35 + 40 = 155
ACDBA 140 : [This is ABDCA backwards]
ADBCA 155 : [This is ACBDA backwards]
ADCBA 125 : [This is ABCDA backwards]
Thus either route ABCDA or ADCBA gives a minimum total distance of 125 kilo-
metres.

J END I
6

6
For further reading, see; [1], [3] and [2], or any other Discrete mathematics books.

Page 72 of 73
References
[1] Susanna S Epp. Discrete mathematics with applications. Cengage learning, 2010.

[2] Linda Gilbert. Elements of modern algebra. Nelson Education, 2014.

[3] Kenneth H Rosen. Handbook of discrete and combinatorial mathematics. CRC


press, 1999.

Page 73 of 73

You might also like