12_matdis_eng.pdf
TRANSCRIPT
Matematika Diskrit
POLITEKNIK TELKOM
BANDUNG
2009
Penyusun dan Editor Adi Wijaya M.Si
Dilarang menerbitkan kembali, menyebarluaskan atau menyimpan baik
sebagian maupun seluruh isi buku dalam bentuk dan dengan cara apapun tanpa izin tertulis dari Politeknik Telkom.
Hak cipta dilindungi undang-undang @ Politeknik Telkom 2009
No part of this document may be copied, reproduced, printed, distributed, modified,
removed and amended in any form by any means without prior written authorization of Telkom Polytechnic.
Politeknik Telkom Matematika Diskrit
Matematika Diskrit iii PAGE 10
Kata Pengantar
Assalamu’alaikum Wr. Wb
Segala puji bagi Allah SWT karena dengan karunia-Nya courseware ini
dapat diselesaikan.
Atas nama Politeknik Telkom, kami sangat menghargai dan ingin
menyampaikan terima kasih kepada penulis, penerjemah dan
penyunting yang telah memberikan tenaga, pikiran, dan waktu sehingga
courseware ini dapat tersusun.
Tak ada gading yang tak retak, di dunia ini tidak ada yang sempurna,
oleh karena itu kami harapkan para pengguna buku ini dapat
memberikan masukan perbaikan demi pengembangan selanjutnya.
Semoga courseware ini dapat memberikan manfaat dan membantu
seluruh Sivitas Akademika Politeknik Telkom dalam memahami dan
mengikuti materi perkuliahan di Politeknik Telkom.
Amin.
Wassalamu’alaikum Wr. Wb.
Bandung, Maret 2009
Christanto Triwibisono
Wakil Direktur I
Bidang Akademik & Pengembangan
Telkom Polytechnic Discrete Mathematics
iv PBO PAGE 10
Daftar Isi
Kata Pengantar.................................................................................... iii Daftar Isi ............................................................................................... iv Daftar Gambar ..........................................Error! Bookmark not defined. Daftar Tabel ...............................................Error! Bookmark not defined. 1 HIMPUNAN ....................................Error! Bookmark not defined. 1.1 Definisi dan Keanggotaan Suatu HimpunanError! Bookmark not
defined. 1.2 Operasi Himpunan .............................. Error! Bookmark not defined. 1.3 Prinsip Dualitas ..................................... Error! Bookmark not defined. 1.4 Multi Set ................................................ Error! Bookmark not defined. 2 RELASI DAN FUNGSI ...................Error! Bookmark not defined. 2.1 Definisi Relasi dan Cara Penyajian ... Error! Bookmark not defined. 2.2 Beberapa Sifat Relasi........................... Error! Bookmark not defined. 2.3 Operasi pada Relasi ............................. Error! Bookmark not defined. 2.4 Relasi Ekivalen dan Relasi Terurut..... Error! Bookmark not defined. 2.5 Fungsi ..................................................... Error! Bookmark not defined. 3 KOMBINATORIK ...........................Error! Bookmark not defined. Prinsip Dasar Menghitung ............................... Error! Bookmark not defined. Permutasi dan Kombinasi ................................ Error! Bookmark not defined. 4 TEORI GRAF ...................................Error! Bookmark not defined. 4.1 Definisi Graf .......................................... Error! Bookmark not defined. 4.2 Terminologi Graf .................................. Error! Bookmark not defined. 4.3 Keterhubungan dan Sub Graf ............ Error! Bookmark not defined. 4.4 Matriks Ketetanggaan (adjacency matrix) dan Matriks Bersisian
(incidency matrix) dari Suatu Graf .. Error! Bookmark not defined. 4.5 Eulerian dan Hamiltonian ................... Error! Bookmark not defined. 4.5.2 Sirkuit Hamilton .................................... Error! Bookmark not defined. 4.6 Graf Isomorfik....................................... Error! Bookmark not defined. 4.7 Beberapa Aplikasi Graf ....................... Error! Bookmark not defined. 5 POHON DAN PEWARNAAN GRAFError! Bookmark not
defined. 5.1 Pohon Merentang Minimum (Minimun Spanning Tree) ................ Error!
Bookmark not defined. 5.2 Pohon Berakar ...................................... Error! Bookmark not defined. 5.3 Penelusuran Pohon Biner..................... Error! Bookmark not defined. 5.4 Pewarnaan Graf ................................... Error! Bookmark not defined. Pewarnaan Peta (Map Coloring) .................. Error! Bookmark not defined. Daftar Pustaka ..................................................................................... vi
Politeknik Telkom Matematika Diskrit
Matematika Diskrit v PAGE 10
Politeknik Telkom Matematika Diskrit
Himpunan 1 PAGE 10
1 SETS
Overview
In reality, there are many problems related to objects that are grouped together based on certain criteria. This group of objects is a representation
of a condition, either statistically or economically. Such group of objects is defined as set. This chapert will discuss the definition of sets, the elements, and set operation of several types of sets.
Objective
1. Students understand the basic concept of set. 2. Students understand varios type of set operations and property.
3. Students are able to solve problems and phenomena related to set theory.
Telkom Polytechnic Discrete Mathematics
2 Himpunan PAGE 10
1.1 Definition and Mempership of Sets
A set is a group of different objects that can be clearly defined. The
objects in a set are called elements, or members, of the set. Membership in a
set is described using notation ’’. Example 1 :
A = {x, y, z}
x A : x is the element of set A.
w A : w is not the element of set A.
There are several ways to describe the set, i.e.:
a. By enumerating the elements
In this method, the set is described by listing all its members between braces.
Example 2 :
- The set A of the first four odd numbers can be written as A = {1, 3, 5, 7}.
- The set B of the first five prime numbers can be expressed by
B = {2, 3, 5, 7, 11}. - The set C of natural numbers less than 50 can be written as
C = {1, 2, ..., 50}
- The set of integers can be denoted by {…, -2, -1, 0, 1, 2, …}.
b. By using standard symbol
A set can be expressed using standard symbol that is usually used by academicians.
Example 3 :
N = the set of natural numbers = { 1, 2, ... } Z = the set of integers = { ..., -2, -1, 0, 1, 2, ... } Q = the set of rational numbers
R = the set of real numbers C = the set of complex numbers
Universal set is denoted by U.
Example 4 :
Suppose that U = {1, 2, 3, 4, 5} and A = {1, 3, 5} is the subset of
U.
Politeknik Telkom Matematika Diskrit
Himpunan 3 PAGE 10
3. By characterizing all elements in the set
A set can be described by characterizing all elements the elemetnts in the set. The set can be denotated as:
{ x property or properties that x must have }
Example 5 :
(i) Set A of natural numbers less than10 can be expressed by
A = { x | x 10 and x N } or
A = { x N | x 10 } That is equivalent with :
A = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} (ii) M = { x | x is student taking discrete mathematics
subject }
or
M = { x is student | he takes discrete mathematics
subject } 4. By using Venn Diagram
A set can a;so represented by listing all its members in a diagram that is
called Venn diagram.
Example 6 :
Suppose that U = {1, 2, …, 7, 8}, A = {1, 2, 3, 5} and B = {2, 5, 6, 8}.
The Venn Diagram is:
U
1 2
53 6
8
4
7A B
Telkom Polytechnic Discrete Mathematics
4 Himpunan PAGE 10
In terms of membership of sets, a set can be described as member of other
set. Example 7 :
a. Suppose that M = { students of Politechnic Telkom }
M1 = { students of Computer for Accountancy study progam } M2 = { students of Information System study progam } Thus, M = { M1, M2 }
b. Let P1 = {x, y}, P2 = { {x, y} } or P2={P1},
Meanwhile, P3 = {{{x, y}}}, then x P1 and y P2,
that P1 P2 , while P1 P3, but P2 P3
The number of elements in a set is called the cardinality of the set. For example, cardinality of set A can be denoted by:
n(A) or A
Example 8 :
(i) B = { x | x is prime numbers less than 10 },
or B = {2, 3, 5, 7 } then B = 4
(ii) A = {a, {a}, {{a}} }, then A = 3
If a set does not have any elements, in other words the cardinality of the ser
is zero, the set is called null set. The notation of null set is or {}
Example 9 :
(i) P = {STT Telkom’s Informatic Engineering students who have been to Mars},
then n(P) = 0
Thus, P =
(ii) A = {x | the suare root of x2 + 1 = 0 and x R}, then n(A) = 0
Thus A = {}
(iii) B = {{ }} can also be written as B = {}.
Thus, B is nut null set because it has one element, that is the nul set.
Politeknik Telkom Matematika Diskrit
Himpunan 5 PAGE 10
Set A is considered the subset of set B if and only if all elements of set A are
the elements of set B. In this case, B is considered the superset of A.
Subset can be denoted as: A B or A B
Using Venn diagram, the subset can be described as:
U
AB
Example 10 :
(i) N Z R C
(ii) {2, 3, 5} {2, 3, 5}
For every set of set A these conditions apply:
(a) A is the subset of A (yaitu, A A).
(b) The null set is the subset of A ( A).
(c) If A B and B C, then A C
A and A A, then and A is called the improper subsetof set A.
Statement AB is different with statement AB :
A B means that A is the subset of B, but A B. Thus, A is the proper subset ofi B.
Example 11 :
Suppose that A = {1, 2, 3}.
{1} and {2, 3} is the proper subset of A. The power set of set A is a set which elements are the subset of A, including
the null set and set A itself. Poser set is denoted by P(A). The cadinal of a power set depens on the cardinal of the original set (himpunan asal). For
example, the cardinality of set A is m, then P(A) = 2m.
Example 12 :
Telkom Polytechnic Discrete Mathematics
6 Himpunan PAGE 10
Suppose that A = { x, y }, then P(A) = { , { x }, { y }, { x, y }}
Example 13 :
The power set of null iset is P() = {}, while the poer of set of set
{} is P({}) = {, {}}.
Statement A B is used to described that A is the subset of B the makes A = B.
Two sets are equal if they satisfy these conditions:
A = B if and only if every element of A is the element of B and the other
way around, every element of B is the element of A.
To decide that A = B, it is necessary to prove that A is the subset of B and B
is the subset of A. If the condition is not like that, then A B. or
A = B A B and B A
Example 14 :
(i) Suppose that A = { 0, 1 } and B = { x | x (x – 1) = 0 }, then A = B
(ii) Suppose that A A = { 3, 5, 8, 5 } and B = {5, 3, 8 }, then A = B (iii) Suppose that A A = { 3, 5, 8, 5 } and B = {3, 8},
then A B For three subsets of A, B, and C, this axiom applies:
(a) A = A, B = B, and C = C (b) If A = B, then B = A (c) If A = B and B = C, then A = C
Two subsets are equivalent if ech set has the same cardinality. For example, set A is equivalent with set B. This means that the cardinality of
set A and set B are the same. This can be denoted by A~B
Example 15 :
Politeknik Telkom Matematika Diskrit
Himpunan 7 PAGE 10
Suppose that A = { 2, 3, 5, 7 } and B = { a, b, c, d },
then A ~ B because A = B = 4
Two sets of A and B are called disjoint if both sets do not have similar elements. The notation used is A // B . This can be described using Venn
diagram as follows:
U
A B
Example 16 :
Suppose that A = { x | x N, x < 10 } and B = { 11, 12, 13, 14, 15 }, then A // B.
1.2 Set Operations
Some set operations discussed are intersection, union, complement,
difference, and symmetric difference. a. Intersection
The intersection of two sets is denotated by ‘ ‘. Suppose that A and B are not disjoint sets, then
A B = { x x A and x B }
Using Venn diagram, it can be described as:
Telkom Polytechnic Discrete Mathematics
8 Himpunan PAGE 10
Example 17 :
1. Suppose that A = {2, 3, 5, 7, 11} and B = {3, 6, 9, 12},
then A B = {3}
2. Suppose that A is a set of Industrial Engineering students of STT Telkom and B is a set of old women (50 years above)
then A B = .
It means that A and B are disjoint or A // B.
b. Union
The union of two sets is denoted by ‘‘. Let A and B are sets, then
A B = { x x A or x B }
Using Venn diagram, it can represented as:
Example 18 :
(i) If A = { 2, 3, 5, 7} and B = { 1, 2, 3, 4, 5 }, then A B = {1,2,3, 4,
5, 7}
(ii) A = A
c. Complement
The complement of a set is the elements of all elements of universal set, minus the elements of the set. Suppose that A is a set within universal set U, the complement of set A is denoted by:
A= Ac = { x x U and x A }
Politeknik Telkom Matematika Diskrit
Himpunan 9 PAGE 10
It can be represented using Venn diagram as:
Example 19 :
Suppose that U = { 1, 2, 3, ..., 9 },
if A = {1, 3, 7, 9}, then A = {2, 4, 5, 6, 8}
if A = { x U | x is divisible by two}, then A= { 1, 3, 5, 7, 9 }
Example 20 : A = set of students of PolitechnicTelkom
B = set of students living in dormitory C = set of students majoring in Information System D = set of students taking Discrete Mathematics subject
E = set of students riding motorbikes to campus a. The statement
“All students of Politechnic Telkom, majoring in
Information System, and riding motorbikes to campus” can be expressed using the notation of set operation as:
(A C) E
b. The statement
“All students of Politechnic Telkom who live in dormitory and who do not take Discrete Mathematics subject”
can be expressed using the notation of set operation as:
DBA c. The statement
“All students who major in Information System, who do not live in dormitory or who do not ride motorbikes to
campus” can be expressed using the notation of set operation as:
EBC
Telkom Polytechnic Discrete Mathematics
10 Himpunan PAGE 10
d. Difference
The difference of two sets is denoted by ‘– ‘. Let A and B be sets, the difference between A and B is denoted by
A – B = { x x A and x B } = BA
Example 21 :
Suppose A = { 1, 2, 3, ..., 10 } and B = { 2, 3, 5, 7}, then A – B = { 1,
4, 6, 8, 9 } and B – A = e. Symmetric Difference
The symmetric difference of two sets is denoted by ‘ ‘. Let A and B be sets, the symmetric difference between A and B
dinotasikan oleh :
A B = (A B) – (A B)
= (A – B) (B – A) This can be represented using Venn diagram as:
Politeknik Telkom Matematika Diskrit
Himpunan 11 PAGE 10
Example 22 :
Suppose A = { 2, 3, 5, 7} and B = { 1, 2, 3, 4, 5 }, then
A B = { 1, 4, 7 }
Symmetric difference should meet the following requirements:
(a) A B = B A (Commutative laws)
(b) (A B ) C = A (B C ) (Asscociative laws)
f. Cartesian product
The Cartesian product of two sets is denoted by ‘ ‘.
Let A and B be sets, the Cartesian product of A and B is denoted by:
A B = {(a, b) a A and b B }
Example 23 :
(i) Suppose that C = {1, 2, 3}, and D = { a, b }, then
C D = { (1, a), (1, b), (2, a), (2, b), (3, a), (3, b) } (ii) Suppose that A = B = set of all real numbers, then
A B = set of all dots in a planar shape
Supposet that two sets have finite cardinality, the cardinality of the set as the Cartesian product of the two sets is the cardinality of each set. Thus, if A and B are finite sets, then:
A B = A . B.
An ordered pair (a, b) is different with (b, a), in other words (a, b) (b, a). Referring to this argument, the Cartesian product is not commutative, that is
A B B A In which A or B is not null set.
If A = or B = , then
A B = B A =
Telkom Polytechnic Discrete Mathematics
12 Himpunan PAGE 10
Laws apply to set operations are:
1. Identity laws:
A = A
A U = A
2. Null/domination laws:
A =
A U = U 3. Complementation laws:
A A = U
A A =
4. Idempotent laws:
A A = A
A A = A
5. Involution laws:
)(A = A
6. Absorption laws:
A (A B) = A
A (A B) = A
7. Commutative laws:
A B = B A
A B = B A
8. Associatitive laws:
A (B C) = (A B) C
A (B C) = (A B) C
9. Distributive laws:
A (B C) = (A B) (A C)
A (B C) = (A B) (A C)
10. De Morgan’s laws:
BA = BA
BA = BA 11. Universal Complementation laws
U
U =
Politeknik Telkom Matematika Diskrit
Himpunan 13 PAGE 10
Let A and B be finite sets, then
n(AB) = n(A) + n(B) – n(AB) This is called the principle of inclusion-exclusion. This principle is useful in solving sets and combinatorial.
The principles also apply to three or more finite sets. Let A, B, and C be finite sets. Based on the principle of inclusion-exclusion, the relationship between the cardinalities of the sets’ partitions can be expressed by:
|ABC| = |A| + |B| + |C| – |AB| – |BC| – |AC| + |ABC| The principle of inclusion-exclusion will be explained in chapter on Combinatorics.
1.3 Duality Principle
Duality principle explains that two different concepts can be exchanged. The
exchange provides true answers. Example 24 :
USA steering wheel is placed in front-left Indonesia steering wheel is placed in front-right
Rules: (a) in United State of America,
cars must take the right side of the road,
in the highways, overtaking is done from the left side, when the red light is on, cars are not allowed to directly turn right
(b) in Indonesia,
cars must take the left side of the road, in the highways, overtaking is done from the right side, when the red light is on, cars are allowen to directly turn left
Duality priciples applied to the above case is: The left-right principles can be exchanged. Rules applied in America is used in Indonesia and vice versa.
Duality Principle of Set. Suppose that S is an identity involving set and
operations like , , and complement. If S* is identity that is the dual of S, by
changing , , U, U , while the complement is not changed, when the operations are applied to the identity S*, they provide
correct results. Table 1.1 Duality of Algebraic Set Laws
Telkom Polytechnic Discrete Mathematics
14 Himpunan PAGE 10
1. Identity law:
A = A
The dual is:
A U = A
2. Null/domination law:
A =
The dual is:
A U = U
3. Complementation law:
A A = U
The dual is:
A A =
4. Idempotent law:
A A = A
The dual is:
A A = A
5. Absorption law:
A (A B) = A
The dual is:
A (A B) = A
6. Commutatitive law:
A B = B A
The dual is:
A B = B A
7. Associative law:
A (B C) = (A B) C
The dual is:
A (B C) = (A B) C
8. Distributive law:
A (B C)=(A B) (A C)
The dual is:
A (B C) = (A B) (A C)
9. De Morgan’s law:
BABA
The dual is:
BABA
10. 0/1 law:
U
The dual is:
U =
Example 25 :
Suppose that A U in which A = BABA
in its dual, suppose that it is U*, applies:
A = BABA
Politeknik Telkom Matematika Diskrit
Himpunan 15 PAGE 10
There are several ways in proving the truthfullness of a statement or in
representing a statement using other statement by using sets. They are: a. By using Venn diagram Example 26 :
Let A, B, and C be sets.
Show that A (B C) = (A B) (A C) by using Venn diagram.
Answer :
This way is not for formal proof. By drawing the sets and gradually
shading every operation, the end sets will be obtained.
A (B C) (A B) (A C)
These two Venn diagram provide the same shaded areas.
Statement stating that A (B C) = (A B) (A C) is proven.
b. Some examples in proving statements using algebraic set operation.
Example 27 : Let A and B be sets. Show that:
A (B – A) = A B Anser :
A (B – A) = A (B A) (Definition of difference)
= (A B) (A A ) (Distributive law)
= (A B) U (Complementation law)
= A B (Identity law)
Telkom Polytechnic Discrete Mathematics
16 Himpunan PAGE 10
Example 28 :
Show that for every sets A and B, these operation can be applied:
(i) BAA = A B and
(ii) A ( A B) = A B
Answer :
(i) BAA = BAAA (Distributive law)
= U (A B) (Complementation law)
= A B (Identity law)
(ii) is the dual of (i)
BAA = BAAA (Distributive law)
= (A B) (Complementation law)
= A B (Identity law)
1.4 Multiset
A set which elements are allowed to be repeated (do not have to be different) is called multi set.
Example 29 :
A = {1, 1, 1, 2, 2, 3},
B = {2, 2, 2}, C = {2, 3, 4}, D = { }.
The multiplicity of an element in a multiset is the number of the appearance of the element in the multiset. Example 30 :
M = { 1, 1, 1, 2, 2, 2, 3, 3, 1 }, the multiplicity of 1 is 4 and the multiplicity of 2 is 3, while the multiplicity of 3 is 2.
Set is a special example of multiset. In this case, the multiplicity of its element is 0 is 1. A set which multiplicity of ite elemement is 0 is null set. Let P and Q be multisets, the operations applied to those multisets are:
a. P Q is a multiset which multiplicity of elements is the same with maximum multiplicityof the elements is sets P and Q.
Politeknik Telkom Matematika Diskrit
Himpunan 17 PAGE 10
Example 31 :
P = { a, a, a, c, d, d } dan Q ={ a, a, b, c, c }, then
P Q = { a, a, a, b, c, c, d, d }
b . P Q is a multiset which multiplicity of the elements is the same as the minimum multiplicity of the elements in sets P and Q.
Example 32 :
P = { a, a, a, c, d, d } and Q = { a, a, b, c, c } then
P Q = { a, a, c }
c. P – Q is a multiset which multiplicity of the elements is the same as the multiplicity of the elements in P substracted by the multiplicity in Q. This is applicable if the difference of the multiplicities is positive. If the
difference is zero or negative, the multiplicity of the elements is zero. Example 33 :
P = { a, a, a, b, b, c, d, d, e } and
Q = { a, a, b, b, b, c, c, d, d, f } then P – Q = { a, e }
d. P + Q, which is defined as the sum of two multisets, is a multiset which
multiplicity of the elements is the same with the sum of the multiplicity of the elements in P and Q.
Example 34 :
P = { a, a, b, c, c } dan Q = { a, b, b, d }, then P + Q = { a, a, a, b, b, b, c, c, d }
Telkom Polytechnic Discrete Mathematics
18 Himpunan PAGE 10
Summary
1. Set is a group of different objects that can be clearly defined. 2. Set can be described by enumerating all its members, using symbol,
characterizing all elements in the set, or using Venn diagram. 3. The number of elements in set A is called the cardinality of set A and is
denoted by n(A) or A
4. If a set does not have any element, in other words the cardinality of the
set is zero, the set is called null set and is denoted by or { }.
5. Some necessary set operations are: intersection, union, complement, difference, and symetric difference.
6. Let A and B be finite sets, the principle of inklusion-exclusion for thos
two sets id described as:
n(AB) = n(A) + n(B) – n(AB) 7. A set which elements are allowed to be repeated boleh berulang (do not
have to be different) is called multiset. 8. The multiplicity of an element in a multiset is the number of its
appearance in the multiset.
Politeknik Telkom Matematika Diskrit
Himpunan 19 PAGE 10
True or False Quiz
(For questions No. 1 – 5) Suppose that A = {2, 3, 5, 7}, B = {2, 4, 6, 8,
10}, and C = {1, 3, 5, 7}
1. CABA
2. BA
3. BB is set of natural numbers
4. CBAA
5. CBACBA 6. Nul set is a set which only has one element. The element is zero.
7. If (A – B) = {1, 2, 3} and (B – A) = {4, 5} then AB = {1, 2, 3, 4, 5}
8. If P Q = R then (R – Q) = P
9. The complement of a set of natural numbers is negative numbers.
10. If a A and b B then A B =
Telkom Polytechnic Discrete Mathematics
20 Himpunan PAGE 10
Multiple Choices
1. A set which elements may be repeated is called
A. Double set D. Fuzzy set
B. Multiset E. Data set
C. Frequency set
2. If C = { x x A or x B } then C = .....
A. A B D. A B
B. A – B E. A (B A)
C. A B
3. Set operation of A B, is the same as ....
A. A – B D. (A B) – (A B)
B. (A – B) B E. (A – B) (B – A)
C. (A – B) (B – A)
4. D’Morgan’s law is a set is described as:
A. A B = B A D. A U = U
B. A (B C) = (A B) C E. (A B)
C. BABA
5. The frequency of the appearance of an element in a multiset is called ….
A. cardinality D. Multiplicity
B. Multiplication E. Additivity
C. Frequency
6 P = { x x A dan x B } then P = .....
A. A B D. A B
B. A – B E. A (B A)
C. A B
Politeknik Telkom Matematika Diskrit
Himpunan 21 PAGE 10
7 Set operation of (A – B) (A B) (B –A) results in
A Set A D Set B – A
B Set B E Set A B
C Set A – B
8 Suppose that U is universal set of A and B, then (A U) = ....
A (B – A)c D (A B)c
B (A – B)c E Bc
C (A B)c
9 There are 10 students who take discrete mathematics subjects, 15
students who take management subject, and 6 students who take the two subjects. If the total number of the studenst is 30, the number of students who do not take the two subjects is...
A 9 D 12
B 10 E 13
C 11
10 Suppose that P = {1, 2, 3, 4, 5} and Q = {a, b, c} then n (A X B) = ....
A 5 D 15
B 3 E 8
C 2
Telkom Polytechnic Discrete Mathematics
22 Himpunan PAGE 10
Exercises
(For questions no. 1 – 5) Suppose that A = {1,2, 3, 4, 5, 6, 7},
B = {1, 2, 3, 5, 6, 12}, and C = {2, 4, 8, 12, 20}
Find the result of set operations for:
1. (A B) – C
2. (A B) (B C)
3. (A – B) (B – C)
4. (A C) (B C)
5. (A B) – C (A C) – B 6. Find the number of numbers in set A, which is indivisible by by 3 or 5 !
7. Find the number of numbers in set A, which is divisible by 3, but not by 5 !
8. Find the number of numbers in set A, which is divisible by 3, but not by
5 or 7 ! 9. Suppose that the number of students in a class is 60. Twenty of them
like calculus, 30 of them like discrete mathematics, and 10 of them like
linear algebra. Seven of them like 7 calculus and discrete mathematics, 5 of them like discrete mathematics and linear algebra, and 10 of them do not like all the three subjects. a. Find the number of students who like all the three subjects!
b. Find the number of students who like only one subject! (For questions no. 10 – 15)
A survey done to 60 students results in the following data: 25 like to read Kompas 26 like to read Republika
27 like to read Pikiran Rakyat 9 like to read Kompas and Republika 11 like to read Kompas and Pikiran Rakyat
8 like to read Republika and Pikiran Rakyat 3 like to read all the three newspapers
10. Draw the Venn diagram for the data!
Politeknik Telkom Matematika Diskrit
Himpunan 23 PAGE 10
11. Find the number of students who never read any of the newspaper!
12. Find the number of students who only read Pikiran Rayat! 13. Find the number of students who exactly read only one kind of
newspaper!
Telkom Polytechnic Discrete Mathematics
24 Relasi dan Fungsi PAGE 10
2 RELATIONS AND FUNCTIONS
Overview
The relationships between elements/members in a set occur in many
context. The relationships are represented using a structure called a relation.
Relations can be used to solve various problems such as optimization on
communication network, schedulling, and solving database problems.
Objective
1. Students understand the concept of relations and functions.
2. Students understand various operations and properties of relations.
3. Students are able to solve problems and phenomena related to relations and functions.
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 25 PAGE 10
2.1 The Definition and Representation of Relations
The previous chapter has discussed the Cartesian product, which is
ordered pairs describing the relationship of two sets. All ordered pairs are the elements of a subset as a result of Cartesian product of two sets. Some of the elements of the subset have specific relationship between two
elements of the ordered pair. The relationship occurs according to certain rules. Rules relating two sets are called binary relations. Relation between set A and set B is a set that contains ordered pairs following certain rules. Thus, binary relation R between set A and B is a subset of Cartesian product
A B or R (A B).
The notation used for a ninary relation is a R b or (a, b) R. This
means that a is related to b by R. An element in a Cartesian product is not
the relation of the element is a R b atau (a, b) R, which means that a is not
related to b by relation R. Set A is called the domain of R, and set B is called the range of R.
Example 2.1 : Let A = {2, 3, 4} and B = {2, 4, 8, 9, 15}. If a relation R from A to B is defined by:
(a, b) R if a is the prime factor of b Find the elements of R!
Answer :
As it is previusly explained, the Cartesian product of A B is:
A B = {(2, 2), (2, 4), (2, 8), (2, 9), (2, 15), (3, 2), (3, 4), (3, 8),
(3, 9), (3, 15), (4, 2), (4, 4), (4, 8), (4, 9), (4, 15)} Using the above definition, the relation R from A to B following the rule
is: R = {(2, 2), (2, 4), (2, 8), (3, 9), (3, 15) }
Relation may also happen to only one set, that is the realtion on A. Relation
on set A is the subset of Cartesian product A A.
Telkom Polytechnic Discrete Mathematics
26 Relasi dan Fungsi PAGE 10
Example 2.2 :
Let R be the relation on A = {2, 3, 4, 8, 9} that is defined by (x, y)
R if and only if x is divisible by y. Answer :
A relation R on A that follow the rule is:
R = {(2, 2), (4, 4), (4, 2), (8, 8), (8, 2), (8, 4), (3, 3), (9, 9), (9, 3)} Relations can be represented in various ways such as using arrows, table,
matrix, or even using directed graph. In this section, each way of representing relations is discussed. Representing a relation:
a. Representing Relation using Arrows Let A = {2, 3, 4} and B = {2, 4, 8, 9, 15}. If it is defined that reltion R from A to B follows this rule:
(a, b) R if a is the prime factor of b the relation can be represented as the following:
b. Representing Relation usind Ordered Pairs
The example of relation on (a) can be expressed in ordered pairs as: R = {(2, 2), (2, 4), (2, 8), (3, 9), (3, 15)}
c. Representing Relation using Table
The first column of the table represents the domain, while the second column represents the relations. The relation explained in part (a) can be represented using table as the following:
2
3
4
2
4
8
9
15
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 27 PAGE 10
Table 2.1 Relation of ‘the prime factof of’
A B
2 2
2 4
2 8
3 9
3 15
d. Representing Relation using Matrix
Let R be the relation that relate set A = {a1, a2, …, am} and set B = {b1, b2, …, bn}. The relation can be represented using matrix as follows:
b1 b2 bn
M =
mnmm
n
n
m mmm
mmm
mmm
a
a
a
21
22221
11211
2
1
The elements mij on the matrix have the value of one or zero, depending on whether element ai on set A has relation with element bj on set B. The statement can be represented in the follwing form:
Rba
Rbam
ji
ji
ij),(,0
),(,1
Example 2.3 :
Let A = {2, 3, 4} and B = {2, 4, 8, 9, 15}. If a relation R from A to B is defined as:
(a, b) R if a is the prime factor of b
then the relation can be represented in the for of matrix as follows:
0
1
0
0000
1000
0111
M
e. Representing Relation using Directed Graph The relation on a set can graphically represented using directed
graph or digraph. Directed Graph is only defined to represent a relation
Telkom Polytechnic Discrete Mathematics
28 Relasi dan Fungsi PAGE 10
on a set (not between two sets). Every element of the set is represented
by a dot (it is also called vertex), and every ordered pairs is represented
by an edge (arc). If (a, b) R, an edge is drawn from vertex a to vertex b. Vertex a is called initial vertex and vertex b is called terminal vertex.
An ordered pair (a, a) is represented by an edge from vertex a to vertex a itself. Such edge is called loop.
Example 2.4 : Let R = {(a, b), (b, c), (b, d), (c, c) (c, a), (c, d), (d, b)} be the relation on set {a, b, c, d}.
Relation R can be represented using directed graph as follows:
2.2 Some Properties of Relation
A relation on a set has several properties. They are:
1. Reflexive
A relation R on a set A is called reflexive if (a, a) R for every element
a A. In other words, a relation R on a set A is not reflexisive if there
is a A such that (a, a) R.
Example 2.5 :
Suppose that A = {1, 2, 3, 4}, and relation R is a relation ‘’ which is defined on set A, then
R = {(1, 1), (1, 2), (1, 3),(1, 4), (2, 2), (2, 3), (2,4), (3, 3), (3, 4), (4, 4)} It is seen that (1, 1), (2, 2), (3, 3), (4, 4) are the elements of R. Therefore, R is reflexive.
a b
c d
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 29 PAGE 10
Example 2.6 :
Suppose that A = {2, 3, 4, 8, 9, 15}. If relation R on set A is defined according to:
(a, b) R if a is the prime factor of b
Notice that (4, 4) R . Thus, it is clear that R is not reflexive.
Reflexive property causes several characteristics in the representation of a relation. They are:
Reflexive relation has matrix which main diagonal elements is 1, or
mii = 1, for i = 1, 2, …, n,
1
1
1
1
When a reflexive relation is represented using directed graph, there
will always be loop in every vertex. 2. Transitive
A relation R on set A is called transitive if (a, b)R and (b, c) R,
then (a, c) R, for a, b, c A.
Example 2.7 :
Suppose that A = { 2, 3, 4, 5, 6, 7, 8, 9}, and relation R is defined by:
a R b if and only if b is divisible by a, in which a, b A, Answer :
By referring to the definition for relation R on set A, then: R = {(2, 2), (2, 4), (2, 6), (2, 8), (3, 3), (3, 6), (3, 9), (4, 4), (4, 8)}
When (2, 4) R and (4, 8) R, it is seen that (2, 8) R.
Therefore, R is transitive.
Example 2.8 :
R is a relation on a set of natural number N. R is defined by:
Telkom Polytechnic Discrete Mathematics
30 Relasi dan Fungsi PAGE 10
R : a + b = 5, a, b A,
Is R transitive? Answer :
By referring to the definition of relation R on set A, then:
R = {(1, 4), (4, 1), (2, 3), (3, 2) }
Notice that (1, 4) R and (4, 1) R , but (1, 1) R. Therefore, R is not transitive.
Transitive property gives some characteristics in the representation of a relation. They are:
Transitive property on directed graph is described by a condition: if there is an edge from b to c, there will be directed edge from a to c.
When represented in the form of matrix, a transitive relation does not have particular characteristics on its matrix representation.
3. Symmetric and Antisymmetric
A relation R on a set A is called symmetric if (a, b)R, for every
a, b A, then (b, a) R. A relation R on a set A is not simmetric if (a,
b) R, while (b, a) R. A relation R on a set A is called
antisymmetric if for every a, b A, (a, b) R and (b, a) R and it
applies only if a = b. Notice that the term symmetric is not the antonym for the term antisymmetric. This is due to the fact that a relation may have both characteristics at the same time. However, it is impossible
for a relation to have the two characteristics at the same time if it has
ordered pair of (a, b) in which a b.
Example 2.9 :
Let R be the relation on a set of real number. R is defined by :
a R b if and only if a – b Z. Show that the relation R is symmetric!
Answer :
Suppose that a R b, then (a – b) Z, while it is clear that (b – a)
Z. Therefore, R is symmetric.
Example 2.10 :
Show that relation ‘’ on set Z is antisymmetric.
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 31 PAGE 10
Answer :
It is clear that if a b and b a, then a = b.
Thus, relation ‘’ is antisymmetric.
Example 2.11 :
The relation “dividiblr” on a set of positive interger N is an example of not symmetric relation because yang if b is divisible by a,
a is not divisible byb, except if a = b. Meanwhile, relation “divisible” is an antisymmetric relation because if b is divisible by a and a is divisibyle by b, then a = b.
Example 2.12 :
Suppose that relation R = {(1, 1), (2, 2), (3, 3) }, then relation R is an
symmetric and antisymmetric relation .
The symmetri and antisymmetric property provides several
charcteristics in the representation of the relations either in the form of matrix or graph, i.e.:
Symmetric relation has matrix which elements under the main
diagonal are the reflection of the elements above the main diagonal, or mij = mji = 1, for i = 1, 2, …, n and j = 1, 2, …, n is:
0
1
0
1
A symmetric relation, when represented in the form of directed graph, has a characteristics of: if there is an adge from a to be, there will be an edge from b to a.
Antysymmetric relation has matrix which elements’ characteristic is:
if mij = 1 with i j, then mji = 0. In other words, the matrix of the
antisymmetric relation meets the condition of: is one of mij = 0 or
mji = 0 if i j :
Telkom Polytechnic Discrete Mathematics
32 Relasi dan Fungsi PAGE 10
0
1
00
0
1
Meanwhile, the characteristic of a directed graph of an antysemmetric relation is that there will never be two edges with different directions between two different vertices.
Let R be the relation from the set A to the set B. The inverse of relation R, denoted by R–1, is the relation of set B to set A, which is defined by:
R–1 = {(b, a) | (a, b) R }
Example 2.13 : Let P = {2, 3, 4} and Q = {2, 4, 8, 9, 15}. If the relation R of P to Q is defined as:
(p, q) R if and only if q is divisible by p
it will be obtained that: R = {(2, 2), (2, 4), (4, 4), (2, 8), (4, 8), (3, 9), (3, 15)
R–1 is the inverse of relation R, that is a relation from Q to P in the form of:
(q, p) R–1 if q is multiple of p
Thus, it is obtained that: R–1 = {(2, 2), (4, 2), (4, 4), (8, 2), (8, 4), (9, 3), (15, 3) }
If M is a matriix representing a relation R,
M =
00110
11000
00111
then the matrix representing relation R–1, let’s say N, is obtained by finding the transpose of matrix M,
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 33 PAGE 10
N = MT =
010
010
101
101
001
2.3 Operations of Relations
Relations are sets of oredered pairs. Thus, some algebraic operations that apply to sets also apply to relations. Set operations like intersection,
union, difference, and symmetric difference are also applicable for two
relations. Let R1 and R2 be relations form the set A to set B, R1 R2, R1
R2, R1 – R2, and R1 R2 are also the therelations from A to B. Example 2.14 :
Let A = {a, b, c} and B = {a, b, c, d}. Relation R1 = {(a, a), (b, b), (c, c)} Relation R2 = {(a, a), (a, b), (a, c), (a, d)}
Then :
R1 R2 = {(a, a)}
R1 R2 = {(a, a), (b, b), (c, c), (a, b), (a, c), (a, d)}
R1 R2 = {(b, b), (c, c)}
R2 R1 = {(a, b), (a, c), (a, d)}
R1 R2 = {(b, b), (c, c), (a, b), (a, c), (a, d)}
Suppose that relation R1 and R2 are represented by matrix MR1 and MR2. The Matrices representing the union and intersection of the two relations are:
MR1 R2 = MR1 MR2 and MR1 R2 = MR1 MR2
Example 2.15 :
Suppose that the relations R1 and R2 on set A are represented by the following matrices:
Telkom Polytechnic Discrete Mathematics
34 Relasi dan Fungsi PAGE 10
R1 =
011
101
000
and R2 =
001
110
010
then
MR1 R2 = MR1 MR2 =
011
111
010
MR1 R2 = MR1 MR2 =
001
100
000
Let R be the relation from set A to set B, and let T be the relation
from set B to set C. The composition of R and S is denoted by T R. It is the relation from A to C, which is defined by:
T R = {(a, c) a A, c C, for a b B
that (a, b) R and (b, c) S }
Example 2.16:
Let A = {a, b, c}, B = {2, 4, 6, 8} and C = {s, t, u}
Meanwhile, the relation from A ke B is defined as: R = {(a, 2), (a, 6), (b, 4), (c, 4), (c, 6), (c, 8)} while the relation from set B to set C is defined as:
T = {(2, u), (4, s), (4, t), (6, t), (8, u)} Thus, the composition of relation R and T are:
T R = {(a, u), (a, t), (b, s), (b, t), (c, s), (c, t), (c, u) }
The composition of R and T can be graphically represented using arrows as:
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 35 PAGE 10
1
2
3
2
4
6
8
s
t
u
If relation R1 and R2 are represented by matrices MR1 and MR2, matrix
representing the composition of the two relations are:
MR2 R1 = MR1 MR2
in which MR1 MR2 is the product of the two matrices. It is done by changing
the dot symbol with “” (and), and by changing the addition symbol with “” (or).
Example 2.17 :
Suppose that relations R1 and R2 on set A are represented by the
following matrices:
MR1 =
100
011
101
and MR2 =
101
100
010
the matrix representing R2 R1 is
MR2 R1 = MR1 . MR2
=
)11()10()00()01()00()10()11()00()00(
)10()11()01()00()01()11()10()01()01(
)11()10()01()01()00()11()11()00()01(
=
101
110
111
a
b
c
Telkom Polytechnic Discrete Mathematics
36 Relasi dan Fungsi PAGE 10
2.4 Equivalence Relations and Partial Orderings
A relation on a set A is called an equivalence relation if it is
reflexive, symmetric, and transitive. Two elements that are relted by an equivalence relation are called equivalent. Example 2.18 :
Suppose that R is the relation on Z, which is defined by: a R b if and only if a = b atau a = – b .
Is R an equivalence relation? Answer :
It is clear that a = a, in other words, if a R a for every a Z . Thus, R is reflexive.
If a = b and b = c, then a = c. Inother words, if a R b then b R c then a R c. Therefore, R is transitive.
If a = b or a = – b then b = a or b = – a. In other words, if a R b then b R a. Therefore, R is symmetric.
Thus, R is equivalence relation. Example 2.19 :
Let R be the relation on a set of Real numbers, which is definend by:
a R b if and only if a – b Z. Is R an equivalence relation?
Answer :
For every a Real, then a – a = 0 integers. Therefore, R is reflexive.
Suppose that a R b then (a – b) Z, it is obvious that (b – a) Z. Therefore R is symmetric.
If a R b and b R c, it means that (a – b), (b – c) Z then (a – c) = (a – b) + (b – c) are also integers. Therefore a R c. Thus, R is transitive.
In conclusion, R is an equivalence relation.
Example 2.20 :
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 37 PAGE 10
(Congruence Modulo)
Suppose that m is integers > 1.
Show that R = {(a,b) | a b (mod m)} is an equivalence relation on the set of integers.
Answer :
Notice that a b (mod m) if and only if a – b is divisible by m.
a – a = 0 is divisible by m, that is 0 = 0 m,
Therefore, a a (mod m) that R is reflexive.
a – b is divisible by m that a – b = km, for a k Z. This results in b – a = –km. Thus, the relation is symmetric
If a b (mod m) and b c (mod m),
that a – b and b – c is divisible by m, or
a – b = km and b – c = lm for a k, l Z
By summing them up:
a – c = (a – b) + (b – c) = (k + l) m, then a c (mod m).
This shows that the relation is transitive. Therefore, R is an equivalence relation.
Suppose that R is an equivalence relation on set A. The set of all elements that are related to an element of a of A is called the equivalence class of a. The equivalence class of a with respect to R is denoted by [a]R. When only one relation is under consideration, the notation is [a].
Example 2.21 :
What are the equivalence classes of 0, 1, –2, and –3 for congruence
modulo 4! Answer :
[0] = { . . . , – 12, – 8, – 4, 0, 4, 8, 12, . . . }
[1] = { . . . , – 11, – 7, – 3, 1, 5, 9, . . . } [–2] = { . . . , – 10, – 6, – 2, 2, 6, 10, . . . } [–3] = { . . . , – 11, – 7, – 3, 1, 5, 9, . . . }
A relation R on a set S is called partial ordering or partial order if
it is reflexive, antisymmetric and transitive. A set S together with a partial ordering R is called partially ordered set or poset and is denoted by (S, R).
Example 2.22 :
Telkom Polytechnic Discrete Mathematics
38 Relasi dan Fungsi PAGE 10
Show that the relation ‘’ is ordering relation on Z.
Answer :
Since a a for every a Z, the relation ‘’ is reflexive.
If a b and b a, then a = a. Thus, the relation ‘’ is antisymmetric.
If a b and b c, it means that a c. Thus, the relation ‘’ is
transitive.
Therefore, relation ‘’ is an ordering relation on Z.
Eah element in poset (S, ) is called comparable if either a b or b a for
every a, b S. Further, if (S, ) is a poset and every two elements on S are
comparable, S is called totally ordered set (toset) or chain, while is called a total ordering.
Example 2.23 :
1. ( N, ) is a toset. Sebelumnya blm dijelaskan apa itu toset
2. ( N, | ) is not a toset because it is not comparable.
If (S, ) is a toset and each subset, which is not empty subset, of S et
least has one element, (S, ) is called a well-ordered set.
Every partial ordering can be represented using Hasse diagram. The steps in constructing the Hasse diagram of a poset ar:
Present the ordering using directed graph.
Delete all loops (because the ordering is reflexive)
Delete all transitive edges
Example 2.24 :
Draw the Hasse diagram representing a poset ({1,2,3,4}, = {(a, b) |
a < b}}
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 39 PAGE 10
Answer :
2.5 Function
Let A and B be sets. A function f from A to B is a rule that assign each element of set B to particular element of set A. It is denoted by f(a) =
b, if b is an element of B that is assigned by f to a particular a of A. This means that if f(a) = b and f(a) = c, then b = c. Suppose that f is thefunction from set A to set be B, the statement can be
denoted by:
f : A B It means that f assigns set A to set B.
A is called the domain of f and B is the codomain of f. Another term for function is mapping or transformation.
Suppose that f(a) = b, b is called the image of a and a is the pre-image
of b. A set that contains all values of the mapping f is called the range of f. Notice that the range of f is the subset (perhaps the proper subset) of B.
4
3
2
1
4
3
2
1
Telkom Polytechnic Discrete Mathematics
40 Relasi dan Fungsi PAGE 10
Example 2.25 :
Suppose that f : R R is defined by f(x) = x2.
The domain and codomain of f is a set of Real numbers, while the range of f is a set of non-negative Real numbers.
Example 2.26 :
Below is an example of a relation, but it is not a function:
Below are some examples of representing function: 1. Set of Ordered pair
Suppose that f is a square function of {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, the funtion can be denoted by f = {(2, 4), (3, 9)}
2. Assignment
Example 2.27 : f(x) = x2 + 10, f(x) = 5x,
a b
A B
f
b = f(a) a
a 1
A B
2
3
b
c
cd 4
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 41 PAGE 10
3. Words
Example 2.28 : “f is a function that assigns the sum product of integers to its square”. 4. Source Code Example 2.29 :
Counting function |x| (the absolute value of). function abs(x:integer):integer; begin
if x > 0 then abs := x else
abs := –x; end;
Suppose that g is the function from set A to set B, and f is the function from set B to set C. The composition of the function f and g,
denoted by f g, is the function from A to C and is defined by:
(f g)(a) = f(g(a)), for an a of A. Pay attention to the following illustration of the compoditiond of functions
below:
1
2
3
2
4
6
8
s
t
u
Example 2.30 :
Let f : Z Z and g : Z Z. given the function f(x) = x + 1 and
g(x) = x2, find f g and g f!
Answer :
(i) (f g)(x) = f(g(x)) = f(x2 ) = x2 + 1 .
a
b
c
g f
A B
C
Telkom Polytechnic Discrete Mathematics
42 Relasi dan Fungsi PAGE 10
(ii) (g f)(x) = g(f(x)) = g(x + 1) = (x + 1)2 = x2 + 2x + 1.
A function f form set A to set B is said to be one-to-one or injective, if
set A do not have two elements with similar reflection in set B.
Example 2.31 :
Suppose that f : Z Z and g : R R.
Determine whether the functions f(x)=x2 and g(x)=x+1 are one-to-one!
Answer :
a. Function f(x) = x2 is not one-to-one since f(2) = f(–2) = 4, while –2
2.
b. Function g(x)=x+1 is one-to-one sincesince for a b, a +1 b+1. Suppose that for x = 1, g(1)=2. Meanwhile, for x=2, g(2) = 3.
A function f form set A to set B is said to be onto or surjective, if every element of set B is the the reflection of one or more of the elements of set A. In other words, all elements of set B are the range of f. The function f is
called the onto function of set B. Example 2.32:
Let f : Z Z and g : R R. Determine whether f(x) = x2 and g(x) = x + 1 are onto functions!
Answer :
a. Function f(x) = x2 is not onto since not all integers are the range of f, like the negative integers.
b. Function g(x) = x +1 is onto since for for every real number y
there is a real number x such that y = x + 1.
A function f form set A to set B is said to beone-to-one correspondence, or
bijection, if it is both one-to-one and onto.
Pay attention to the following illustration for better understanding of the above explanation.
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 43 PAGE 10
A one-to-one function, An onto function, but not onto pada but not one-to-one
Suppose that f is a function from set A to set B that is one-to-one
correspondence, we will always be able to find the invers function of f. Inverse function is denotted by f –1. Suppose that a is an element of set A and b is an element of set B, then f -1(b) = a jika f(a) = b. A one-t-one
correspondence is called invertible since we can can define an invers of this function. A function is not invertible if it is not a one-to-one correspondence, since the inverse of such a function does not exist.
Example 2.33 :
What is the invers of functionf(x) = x + 1?
Answer : Function f(x) = x + 1 is a one-to-one correspondence function that we can find its inverse.
Suppose that f(x) = y, that y = x + 1, then x = y – 1. Thus, the inverse function is f-1(y) = y – 1.
Example 2.34 : What is the invers of function f(x) = x2.
Answer :
Like the previous example, f(x) = x2 is not a one-to one corespondence that the inverse does not exist. Thus, f(x) = x2 is not invertible.
Recursively Defined Functions
a1
AB
2
3b
c4
a1
AB
2
3
b
c
cd
Telkom Polytechnic Discrete Mathematics
44 Relasi dan Fungsi PAGE 10
A function is a specific form of a relation. A function is called
recursive if it is defined in terms of itself. The component that construct the recursively defined function are:
1. Basis Value This component is the innitial value of the function.
2. Recurence This component definies the argument of the function in terms of itself.
An example of simple recursively defined function is factorial formula. Refer to the formula for factorial function:
a. Basis Value
n! = 1, untuk n = 0 b. Recurence
n! = n x (n-1) !, for n 1.
Therefore, when we try to define the value of function 4!, then: 4 ! = 4 . 3 ! = 4 . 3 . 2! = 4 . 3 . 2 . 1! = 4 . 3 . 2. 1 . 0! = 24
In an algorithm, usually the appearance of a recursively defined function occurs in a looping. Suppose that the function when t = 0 is a, then function f(k) = 2 . f(k – 1) + 3. Thus, in simple way, the variable of recursively defined function is a function of the previous iteration. This is the reason why
we need an innitial value of the function.
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 45 PAGE 10
Summary
1. Rule that relate two sets is called binary relation.
2. Binary relation R between set A and set B is the subset of a cartesian
product A B or R (A B).
3. The notasi of a binary relation biner is a R b or (a, b) R.
4. Relation can be presented using arrows, ordered pairs, table, matrix, and directed graph.
5. If R1 and R2 are the relations from set A to set B, then R1 R2, R1 R2,
R1 – R2, and R1 R2 are alos the relation from A to B.
6. A relation R on a set A is called reflexive, if (a, a) R for every a A.
7. A relation R on a set A is called transitive, if (a, b)R and (b, c) R,
then (a, c) R, for a, b, c A.
8. A relation R on a set A is called symmetric, if (a, b)R, for every a, b
A, then (b, a) R.
9. A relation on a set A is called equivalence, if it is reflexive, symmetric and transitive.
10. A function f from A to B is a rule that relate the each element of set A with each element of B.
11. A function f from set A to set B is calledone-to-one, or injective, if set A
doesnot have two elements that have similar reflections in set B. 12. A function f from set A to set B is said onto, or surjective, if each
element of set B is the reflection of one or more elements of set A.
13. A function f from set A to set B is said tobe one-to-one correspondence, or bijection, if it is both one-to-one and onto.
Telkom Polytechnic Discrete Mathematics
46 Relasi dan Fungsi PAGE 10
True or False Quiz
(For questions no. 1 – 5) Given that A = {2, 3, 5, 7}, the relation on A is defined in sets:
R = {(2, 2), (3, 3), (3, 5), (5, 3), (7, 3), (7, 7)}
11. R is reflexive 12. R is not symmetric 13. R is transitive 14. R is not antisymmetric
15. R R2 16. The relation of ‘the factor of’ of set A = {1, 2, 4, 8} is transitive.
17. A relation that is not symmetric is called antisymmetric. 18. Equivalence relation is a relation that is symmetric and transitive. 19. If each element of set B is the reflection of one or more elements of set
A, the function from A to B is injective. 20. Let R and S be the relations of A = {a, b, c}. If R and S are symmetric,
then R S is symmetric.
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 47 PAGE 10
Multiple Choices
1. An equivalence relation must meet the following properties:
A. Reflexive and symmetric D.
Reflexive, antisymmetric,
transitive
B. Reflexive, symmetric, transitive E. Reflexive, symmetric , antisymmetric
C. Symmetric and transitive
2. Function f(x) = x3 is
A. Injectie Function D. Recursive Function
B. Surjective Function E. Antisymmetric Function
C. Bijective Function
3. A relation defined by “a R b jif and only if + b Z”, meet the following
properties, EXCEPT:
A. Reflexive D. Anti Symmetric
B. Recursive E. Transitive
C. Symmetric
4. If relation R = {(1,2)} then R R-1 is:
A. not transitive D. not symmetric
B. reflexive E. Recursive
C. not antisymmetric
5. Given that U1 = 5 and Un = 2Un-1+ 3, then U4 = ....
A. 29 D. 73
B. 58 E. 0
Telkom Polytechnic Discrete Mathematics
48 Relasi dan Fungsi PAGE 10
C. 61
6 A relation is called partial ordering if it satisfies the following properties:
A. Reflexive and symmetric D. Reflexive, antisymmetric, and transitive
B.
Reflexive, symmetric, and
transitive E.
Reflexive, symmetric , and
antisymmetric
C. Symmetric and transitive
7 Suppose that R is a relation of a finite set. If the matrix of the relation is
an identity matrix, the relation is:
A Reflexive, but not transitive D Symmetric and transitive
B Recursive and transitive E Reflexive and total ordering
C Reflexsive, but not symmetric
(For questions no. 8 – 10) Let R and S be the relations of A = {1, 2, 3},
R = {(1,1), (1,2), (2,3), (3,1), (3,3)} and S = {(1,2), (1,3), (2,1), (3,3)}
8 The sets of relation Rc = ....
A {(1,3), (2,1)} D {(1,3), (2,2), (3,2)}
B {(1,3), (2,1), (2,2), (3,2)} E {(1,1), (2,2), (3,3)}
C {(1,2), (3,3)}
9 The sets of composition relation R S = ....
A {(1,3), (2,1), (2,2), (3,2)} D {(1,1), (1,3), (2,2), (3,2)}
B {(1,3), (2,2), (3,2)} E {(1,1),(1,2),(1,3) (2,3), (3,2), (3,3)}
C {(1,2), (1,3), (2,3), (3,2)}
10 The sets of composition relation S2 = ....
A {(1,3), (2,1), (2,2), (3,2)} D {(1,1), (1,3), (2,2), (3,2)}
B {(1,3), (2,2), (3,2)} E {(1,1),(1,2),(1,3) (2,3), (3,2), (3,3)}
C {(1,2), (1,3), (2,3), (3,2)}
Politeknik Telkom Matematika Diskrit
Relasi dan Fungsi 49 PAGE 10
Exercise
(For questions no. 1 – 3) Let A = {a, b, c, d, e} and B = {x, y, z}. Let R be the relation of A to B in the:
R = {(a, y), (a, z), (c, y), (d, x), (d, z)} 1. Find the matrix for relation R 2. Draw the directed graph for relation R
3. Find the inverse relation of relation R 4. Find whether the following relations (in the forms of ordered pairs) are
equivalence:
a. {(0,0), (1,1), (2,2), (3,3) } b. {(0,0), (1,1), (1,3), (2,2), (2,3), (3,1), (3,2), (3,3) } 5. Suppose that the matrix of a relation is represented as:
MR =
111
110
111
Find whether the relation is reflexsive, symmetric, antisymmetric, and transitive.
6. Proove that the relation represented in the following matrix is equiivalence relation.
MR =
1000
0111
0111
0111
7. Suppose that a relation R is represented in the following matrix:
Telkom Polytechnic Discrete Mathematics
50 Relasi dan Fungsi PAGE 10
1000
0100
1010
0111
RM
Find whether the relation is an ordered relation!
8. Let A be the set of integers taknol and R is the relation on the set A X A, which is defined by:
(a, b) R (c, d) if ad = bc Show that R is equivalence relation!
9. Suppose that a relation R is represented in the following matrix:
1000
0100
1010
0111
RM
Find two matrixes that represent the inverse relations R–1
and che omposition of R R–1 !
10. Draw the Hasse diagram of poset {B , }
in which B = {1, 2, 3, 4, 6, 8, 12} and = {(a,b) | b is divisible by a}}
Politeknik Telkom Matematika Diskrit
Kombinatorik 51 PAGE 10
3 COMBINATORICS
Overview
Combinatorics is animportant part of discrete mathemathics. This chapter
will discuss the techniques of counting, permutation, and comniation. One of the advantages of counting technique is to determine the complexity in an algorithm. It is expected that basic knowledge about combinatorics will
provide basis in understanding optimization or in developing or using the applications of combinatorics related to computerization.
Objective
1. Students understand the basic concept of combinatorics.
2. Students are able to differentiate between permutation and combination.
3. Students are able to solve various problems related to combinatorics.
Telkom Polytechnic Discrete Mathematics
52 Kombinatorik PAGE 10
3.1 Basic Principle of Counting
Two basic principles used in counting are the sum and product rules.
The Sum Rule
If a set A is devided into subsets A1, A2, …, An, the number of the
elements of set A will be the same with the number of all elements
of every subset A1, A2, …, An.
Indirectly, according to the sum rule, the subsets A1, A2, …, An do not
overlap (disjoint). The sum rule does not apply to sets that overlie one
another t. Such case must be solved using the principle of inclusion-exclusion
that will be explained in the next section.
Example 1 :
An elementary teacher in a village teaches 4th, 5th, and 6th graders. If
the number of students in grade 4 is 25, the number of students in
grade 5 is 27, and the number of students in grade 6 is 20, the total
number of students taught by the teacher is 25 + 27 + 20 = 72
students.
Example 2 :
A university students wants to by a motorcycle. He has to choose one
type over three kinds of motorcycle. Honda offers 3 types of
motorcycles, Suzuki offers 2 types of motorcycles, and Yamaha
offers 2 pili types of motorcycles. Thus, the number of choices for the
student is 3 + 2 + 2 = 7 choices.
The Product Rule
Suppose that a procedure can be broken down into two tasks.
There are n1 ways to do the first task and n2 ways to do the
second task after the first task has been done. Thus, there are (n1 x
n2) ways to do the procedures.
Politeknik Telkom Matematika Diskrit
Kombinatorik 53 PAGE 10
In product rule, idirectly, the sets operated do not have to be disjoint.
Example 1:
How many strings are there of length 7 out of two bits (0 and 1)
Answer :
Each of the seven bits has two possibilities, i.e. 0 or 1.
Terefore, the product rule shows there are a total of
2 x 2 x 2 x 2 x 2 x 2 x 2 = 27 = 128 different bit strings of
length seven
Example 2 :
An elementary teacher in a village teaches students of grade 4, 5, and 6. Suppose that the number of students in grade 4 is 25, the number of students in grade 5 is 27, the number of students in
grade 6 is 20. If the teacher wants to choose three students, one from each class, out of all students he taught, the teacher has 25 x 27 x 20 = 13.500 ways in choosing the three students.
Example 3 :
How many odd numbers are there between 1000 and 9999
(including 1000 and 9999) in which (a) all numbers are different (b) there are repeated numbers.
Answer :
(a) the first digit from the right: 5 possible numbers (they are 1, 3, 5,
7 and 9); the fourth digit from the right: 8 possible numbers (1 to 9 except
numbers that have been chosen)
the third digit from the right: 8 possible numbers the second digit from the right: 7 possible numbers Thus, the total number of odd numbers is (5)(8)(8)(7) = 2240.
Telkom Polytechnic Discrete Mathematics
54 Kombinatorik PAGE 10
(b) the first digit from the right: 5 possible numbers (they are 1, 3, 5, 7 and 9);
the fourth digit from the right: 9 possible numbers (1 to 9)
the third digit from the right: 10 possible numbers (0 to 9) the second digit from the right: 10 possible numbers (0 to 9)
Thus, the total number of odd numbers is (5)(9)(10)(10) = 4500. Example 5 :
A login password of a computer system is five to seven characters long. Every character may be a letter (can be upper or lower cases)
or number. How many passwords are there for a login ?
Answer :
The number of alphabets is 26 (A – Z) and the number of numbers
is 10 (0 – 9). Thus, the total number of the characters is 36.
The number of possible 5-character passwords is
(36)(36)(36)(36)(36) = 365 = 60.466.176,
the number of possible 6-character passwords is
(36)(36)(36)(36)(36)(36)(36) = 366 = 2.176.782.336,
and The number of possible 8-character passwords is
(36)(36)(36)(36)(36)(36)(36)(36) = 367 = 78.364.164.096.
Thus, the total number of all possible passwords is:
60.466.176 + 2.176.782.336 + 78.364.164.096 =
80.601.412.608.
In other words, one login will have 80.601.412.608 possible passwords.
Politeknik Telkom Matematika Diskrit
Kombinatorik 55 PAGE 10
When two processes are done at the same time, the sum rule
cannot be used to count the number of ways of choosing one out of the two
processes. Such case must be solved by using the principle of inclusion-
exclussion.
Example :
How many bytes of 8 bits are there if the byte starts with ‘11’ or
ends with ‘00’?
Answer :
Suppose that A is a set of byte starting with ‘11’, and B is a set of byte ending with ‘00’,
A B is a set of byte starting with ‘11’ and ending with ‘00’,
and
A B is a set of byte starting with ‘11’ or ending with ‘00’.
The number of possible byte that can be arranged on set A is (1)(1)(2)(2)(2)(2)(2)(2) = 26.
It can be denoted by A = 26 = 64
Meanwhile, the number of possible byte that can be arranged on the set B is (2)(2)(2)(2)(2)(2)(1)(1) = 26.
Thus, B = 26 = 64,
Using similar ways, the number of possible byte that can be arranged
on the set A B is (1)(1)(2)(2)(2)(2)(1)(1) = 24
that A B = 24 = 16. Then,
A B = A + B – A B = 64 + 64 – 16 = 112.
Therefore, the number of 8-bit bytes that starts with ‘11’ or ends with ‘00’ is 112.
Telkom Polytechnic Discrete Mathematics
56 Kombinatorik PAGE 10
3.2 Permutations and Combinations
Permutations
A Suatu permutation is possible arrangement done according to
certain order. In other words, permutation is a specific application of
product rule. Let A be a set with n, number of elements. The ordered arrangement that consits of r number of elements is called r-permutation of A and is denoted by P(n, r). To make this clearer, pay attention to this
explanation: If r > n, it is obvious that P(n, r) = 0 becuase it is impossible to
arrange r elements of A that only contains n number of elements in which n < r.
If r n,
The first element of the permutation can be chosen in n ways, since there are n elements in the set. There are n – 1 ways to choose the second element of the permutation, since there are n – 1 elements left in the set
after using the element picked for the first posisiton. Similarly, there are n – 2 ways to choose the third element, and so on until there are exactly n – r + 1 ways to choose the r element. Consequently, by the product rule, there
are n(n – 1) (n – 2) … (n – r + 1) r-permutation of the set.
Therefore, r-permutation of n objects is the number of possible order of r
objects chosen from n objects, with r n, and for each possible arranggement of r objects there will be no similar arragement of objects.
This can be expressed by:
P(n, r) = n(n – 1) (n – 2) … (n – r + 1)= )!(
!
rn
n
Example 1 :
Suppose that S = {p, q, r}. How many wasy are there to arrange two
letters on S that there will not be any similar arrangement? Answer :
The possible arragements of two letters are:
pq, pr, qr, qp, rp, rq Thus, the arrangement can be done in six ways. In this case, the definition of permutation can be used. It states that:
Politeknik Telkom Matematika Diskrit
Kombinatorik 57 PAGE 10
6
1
1.2.3
!23
!3)2,3(
P
By using the definition of permutation, the arrangement can be done in
six ways.
Example 2 :
Suppose that we have five balls with different colors and three boxes. We will put the balls into the boxes. Each box is only for one ball. How many order of different-clolor balls that can be made by placing
the balls into the boxes? Answer :
Box 1 can be filled with one of the 5 balls (there are 5 choices);
kotak 2 dapat diisi oleh salah satu dari 4 bola (there are 4 choices); kotak 3 dapat diisi oleh salah satu dari 3 bola (there are 3 choices). The number of different orders is = (5)(4)(3) = 60
By using the definition of permutation, then:
60
1.2
1.2.3.4.5
!35
!5)3,5(
P
Combination Suppose that r is an element of infinite negative integers. An r-
combination of n different elements of a set B is the number of subsets of set
B with r elements. Another interpretation of combination is ordering or choosing r out of n elements.
Example 1 : Suppose that A = {p, q, r }, find all subsets of set A with cardinality of 2.
Answer :
Telkom Polytechnic Discrete Mathematics
58 Kombinatorik PAGE 10
The subsets are: {p, q}, {p, r}, and {q, r}.
Thus, the combinations are: pq, pr, and qr
In the case of sets, the order of element is not considered. Therefore, 2 combinations of th set A (combining two letters without considering the
order) is 3, i.e., pq, pr, and qr. This is different with permutation that considers order. Using permutation, there are six ways in combining process the letters, i.e., yaitu pq, pr, qr, qp, rp, and rq.
Example 2 :
Suppose that there are 2 balls with the same color and and 3 boxes.
The balls will be put in the boxes in such a way that each box will contain only one ball. How many ways are there to put the balls into the boxes ?
Answer :
Suppose that the boxes are placed horizontally, one box is placed next
to another. There will be 3 ways to put the 2 balls into the boxes. They are: First method : the first and second balls are put into the first and
second boxes. Second method: the first and second balls are put intothe first and
third boxes.
Third method : the first and second balls are put into the second and third boxes.
Generally, the number of ways to put r balls of the same color into n boxes is:
)!(!
!
!
))1()...(2)(1(
rnr
n
r
rnnnn
This is the formula of combination, that is denoted by C(n,r) or
r
n
Suppose that there are n balls (some balls are differnt in color and
some are similar in color). They will be put into n boxes. If the compostions
of the balls are: n1 balls are colored 1,
Politeknik Telkom Matematika Diskrit
Kombinatorik 59 PAGE 10
n2 balls are colored 2,
nk balls are colored 1k bola diantaranya berwarna k,
then n1 + n2 + … + nk = n.
How many ways are there to put the n balls into the boxes (each box contains only one ball?
If all the n balls are considered different in color, there number of ways
to put the n balls into n buah boxes is: P(n, n) = n!. Therefore,
there are n1! ways of putting balls having color 1 there are n2! ways of putting balls having color 2
there are nk! ways of putting balls having color k
The permutation of n balls in which n1 consists of some balls having
color 1, n2 consists of some balls having color 2, …, nk consists of some balls havin color k is:
!!...!
!
!!...!
),(),...,,;(
212121
kkk
nnn
n
nnn
nnPnnnnP
Other method:
There are C(n, n1) ways to put n1 balls which color is 1. There are C(n – n1, n2) ways to put n2 balls which color is 2. There are C(n – n1 – n3, n3) ways to put n3 balls which color is 3.
There are C(n – n1 – n2 – … – nk-1, nk ) ways to put nk balls which color
is k. The total number of ways to put the balls into the boxes is:
C(n; n1, n2, …, nk) = C(n, n1) C(n – n1, n2) C(n – n1 – n2 , n3)
… C(n – n1 – n2 – … – nk-1, nk)
= )!(!
!
11 nnn
n
)!(!
)!(
212
1
nnnn
nn
)!(!
)!(
213
21
knnnnn
nnn
… )!...(!
)!...(
121
121
kkk
k
nnnnnn
nnnn
= !!...!!
!
321 knnnn
n
Conclusion:
Telkom Polytechnic Discrete Mathematics
60 Kombinatorik PAGE 10
!!...!
!),...,,;(),...,,;(
212121
kkk
nnn
nnnnnCnnnnP
Combinations with Repetition Suppose that there are r balls with the same color and n boxes.
Each box must contain only one ball. The number of ways to put the balls into the boxes is C(n, r).
If each box may contains more than one ball (no limitation on the
number of balls), the number of ways to put the balls into the boxes is:
C(n + r – 1, r) = C(n + r –1, n – 1).
For example :
Twenty apples and 15 oranges are going to be shared out to 5
children. Each child may have more than one aple or orangge, or none of them. How many ways are there to share out the aples and oranges?
Answer :
n = 5, r1 = 20 (apel) and r2 = 15 (jeruk)
Sharing out 20 apples to 5 children: C(5 + 20 – 1, 20) ways, Sharing out 15 oranges to 5 children: C(5 + 15 – 1, 15) ways. The total number of ways to share out the apples and oranges is:
C(5 + 20 – 1, 20) C(5 + 15 – 1, 15) = C(24, 20) C(19, 15)
Binomial Coefficients
Suppose that n is postive integers, using biinomial theorem, the power function of (x + y)n can be represented in Pascal’s triangle as follows: (x + y)0 = 1
(x + y)1 = x + y (x + y)2 = x2 + 2xy + y2 (x + y)3 = x3 + 3x2y + 3xy2 + y3
(x + y)4 = x4 + 4x3y + 6x2y2 + 4xy3 + y4 (x + y)5 = x5 + 5x4y + 10x3y2 + 10x2y3 + 5xy4 + y5 Generaly, it will result in the following formula:
(x + y)n = C(n, 0) xn + C(n, 1) xn-1 y +…+ C(n, k) xn-k yk +…+ C(n, n)yn
= kknn
k
yxknC
0
),(
C(n, k) is the coefficient for x(n–k)yk and it is called binomial coefficient.
Politeknik Telkom Matematika Diskrit
Kombinatorik 61 PAGE 10
Example :
What is the expansion of (2x + y)3. Answer : Let a = 2x and b = y, (a + b)3 = C(3, 0) a3 + C(3, 1) a2b1 + C(3, 2) a1b2 + C(3, 3) b3
= 1 (2x)3 + 3 (2x)2 (y) + 3 (2x) (y)2 + 1 (y)3 = 8 x3 + 12x2 y + 6x y2 – y3
Example : Find the expansion of (2x – 3)3.
Answer :
Let a = 2x and b = –3, (a + b)3 = C(3, 0) a3 + C(3, 1) a2b1 + C(3, 2) a1b2 + C(3, 3) b3
= 1 (2x)3 + 3 (2x)2 (–3) + 3 (2x) (–3)2 + 1 (–3)3
= 8x3 – 36x2 + 54x – 27 Example :
Find the fifth order from the expansion of (x – y)5. Answer :
(x – y)5 = (x + (–y))5.
The fifth order obtained from the expansion is: C(5, 4) x5– 4 (–y)4 = –10 x y4.
Telkom Polytechnic Discrete Mathematics
62 Kombinatorik PAGE 10
Summary
1. Two basic principles of counting are the sum and product rules.
2. A permutation is a possible arrangement according to certaine order. 3. Suppose that B has n different elements. The r-combination of the set B
is the sum of the subset of B that contains elements of r objects.
4. The formula of r-permutation of n objets is:
P(n, r) = n(n – 1) (n – 2) … (n – r + 1)= )!(
!
rn
n
5. The formula of r-combination of n elements is denoted by C(n,r) =
)!(!
!
rnr
n
r
n
6. On polynom (x – y)n, the number C(n, k) is coeficient for x(n–k)yk and is called binomial coefficient.
Politeknik Telkom Matematika Diskrit
Kombinatorik 63 PAGE 10
True or False Quiz
21. The sum principle is the same with the product principle. 22. The value of 5! is 120.
23. A permutation is an arragement that is possible to be made without regarding order.
24. Choosing the formation of 3 futsal teams out of 15 players can be done
using combination principle. 25. The value of P(5, 3) is 15. 26. The value of C(5, 2) is 10 27. (2x + y)4 = x4 + 4x3y + 6x2y2 + 4xy3 + y4
28. P (10, 5) = C (10, 2) 29. Permutation can counted by using product rule. 30. C(n + r – 1, r) = C(n + r –1, n – 1)
Telkom Polytechnic Discrete Mathematics
64 Kombinatorik PAGE 10
Multiple Choices
1. Suppose that there are 3 male lecturers and 2 female lecturers. A student can choose one out of those five lecturers in ….
A. 1 way D. 5 ways B. 2 ways E. 6 ways C. 3 ways
2. How many ways are there for a set of 50 students to choose one chief,
one secretary, and one treasurer, in condition that no student has more than one position?
A. 25 ! ways D. 3 ways B. 25 ways E. 25 x 24 x23 ways
C. 25x3 ways
3. ....
2
8
A. 2 D. 56
B. 8 E. 128
C. 28 4. A farmer bought 3 cows, 4 sheep, and 5 chickens from a person who
have 4 cows, 5 sheep, and 7 chickens. How many are there for the farmer to choose the three kinds of animals?
A. 420 ways D. 7 ways
B. 140 ways E. 1 way
C. 35 ways
5. There are 9 kinds of toys to be distributed to 4 children. Each child will
Politeknik Telkom Matematika Diskrit
Kombinatorik 65 PAGE 10
be given 2 kinds of toys, except the youngest. The youngest will be given
3 kinds of toys. How many ways are there to distribute the toys?
A. !9 ways D. )!2!.2.!3(/!9 ways
B. !2/!9 ways E. )!2.!2!.2.!3(/!9 ways
C. )!3.!2(/!9 ways
Excercises
1. Find the value of :
a.
13
15 b.
9
11
2. Find the value of: a. P(6, 3) b. C(5, 1)
3. Show that
6
16
5
16
6
17
4. Find n if : a. P(n,2) = 72 b. P(n,4) = 42 P(n,2)
5. Twenty students will be divided into three teams. How many formation
of teams are there?
6. There are five people who are attending a seminar. How many wasy are there for the pople to take a seat if:
a. 5 seats are placed in one row. b. 5 seats are placed in circle behind a round table.
7. ‘Duny donut’ store offers four different kinds of donuts (the stock of
each kind is 10 donuts). How many ways are there to choose six donuts?
8. How many strings of lenght ten are there that can be formed out of two
bits (0 and 1), that contain exactly seven 1s.
Telkom Polytechnic Discrete Mathematics
66 Kombinatorik PAGE 10
9. There 12 racers (it is assumed that all racers are able to reach the finish
line) in a horse race Dalam suatu pacuan kuda dengan 12 peserta. How many possible arrangement of winners (first, second, and third) are there at the end of the race?
10. Using binomial theorm, find: a. coeficient x5y8 in (x + y)13 b. coeficient x7 in (1 + x)11
c. coeficient x9 in (1 – x)19
Politeknik Telkom Matematika Diskrit
Teori Graf 67 PAGE 10
4 GRAPHS THEORY
Overview
Graphs is applied to solve different kinds of problems, for example in determining the shortest path related to communication as well as transportation, frequency assignment in telecommunication, schedule
optimation, and so on. The explanation of graphs in this chapter covers definition and terminology related to graphs, essential problems of the shortest path, which are used in application.
Objective
1. Students understand the concept and terminology related to graphs. 2. Students model problems in the form of graphs.
3. Students are able to solve problems related to graphs theory.
Telkom Polytechnic Discrete Mathematics
68 Teori Graf PAGE 10
4.1 Definiton of Graphs
Graphs is a discrete structure consisting of a collection of vertices or ‘nodes’ and a collection of edges that connec pairs of vertices. Graphs is used
to represent discrete objects and the relationship among these objects. A notation of a graphs is G = (V, E), in which:
V is a set, whose elements are called vertices or nodes, i.e. V
= { v1 , v2 , ... , vn } E is a set of pairs (unordered) of distinct vertives called edges
or line, i.e. E = {e1 , e2 , ... , en }
For example:
Graphs of Königsberg bridge problem is presented below:
Suppose that the graph is called G(V, E) with: V = { A, B, C, D }
E = { (A, C), (A, C), (A, B), (A, B), (B, D), (A, D), (C, D)} = { e1, e2, e3, e4, e5, e6, e7}
On the graph above, edge e1 = (A, C) and edge e2 = (A, C) are called multiple edges or paralel edges as both of the edges connect two same vertices: vertex A and vertex C. Edge e3 and edge e4 are likewise. However, there is no loop on it. Loop is an edge (directed or undirected)
which starts and ends on the same vertex.
e2
e3 e4 e5
e6
e7 e1
B
A
C
D
Politeknik Telkom Matematika Diskrit
Teori Graf 69 PAGE 10
Considering graph definition, edge (E) collection enables null
collection. If a graph contains null collection, it is called null graph or empty graph. For example : Null graph with 3 vertices (graph 3)
By considering graph’s edges, a graph is classified into directed and undirected graph. Undirected graph has been explained on the Bridge of
Königsberg’s example. Directed graph or digraph is a graph having directed
edges. It means a vertex connected by the edges is an initial vertex and other vertex is called terminal vertex.
Several worth knowing graphs are shown below: I. Simple graph is an undirected graph with no loops and multiple
edges
For example : Simple graph
Furthemore, the word “graph”in this book represents simple graph unless there is additional word such as pseudograph, directed graph,
etc.
2. Multigraph
v1
v2 v3
P
S Q
R
Telkom Polytechnic Discrete Mathematics
70 Teori Graf PAGE 10
Multigraph is an undirected graph without loop.
For example :
Multigraph
Thus, a simple graph is a multigraph as well.
3. Pseudo graph
Pseudo graph is a graph which is allowed to contain loop.
For example :
Pseudo graph:
P
S Q
R
P
S Q
R
Politeknik Telkom Matematika Diskrit
Teori Graf 71 PAGE 10
4. Directed graph or digraph
Directed graph or digraph is a graph in which its edges have direction but do not have two contradicted edges between two vertices. In other words, they do not have multiple edges.
For example :
a. Directed graph or digraph:
b. Directed multigraph Directed multigraph is a graph which allows multiple edges on it. (It is allowed to have contradicted edges between two vertices).
Based on the explanation above, we can make conclusions as follow :
P
S Q
R
R
P
S Q
Telkom Polytechnic Discrete Mathematics
72 Teori Graf PAGE 10
Table 4.1 Types of Graphs
Types Edges Multiple edges
Loop
Simple graph Multigraph
Pseudograph
Directed graph Directed multigraph
Undirected Undirected Undirected
Directed Directed
Disallowed Allowed Allowed
Disallowed Allowed
Disallowed Disallowed
Allowed
Allowed Allowed
For example : The following graph is a directed graph:
It can be seen that e1 = (P, S), e3 = (R, Q), and e5 = (Q, Q) Vertex P is an initial vertex for edge e1 and vertex S is a terminal
vertex for edge e1.
4.2 Graph Terminology
There are several graph terminologies which are worthy to know, such as: two vertices adjacency, incidency, vertex degree, etc.
1. Adjacent
Two vertices are said to be adjacent if they are directly connected by an
edge. For example:
e6
P
S Q
R
e1 e4
e3 e2
Politeknik Telkom Matematika Diskrit
Teori Graf 73 PAGE 10
Observe the graph below:
On the graph above: vertex P is adjacent to vertex Q and vertex S. However, vertex P is not adjacent to vertex R.
2. Incidency Edge e is said to be incident to vertex v1 and v2 if e connects both of the
vertices. In other words, e = (v1, v2).
For example :
Observe the graph of Bridges of Königsberg as follow:
edge e1 is incident to vertex A and C, but this edge is not incident to vertex B.
3. Isolated Vertex
If a vertex does not have edge which is adjacent to it then the vertex is called isolated vertex.
For example :
P
S Q
R
e2
e3 e4 e5
e6
e7 e1
B
A
C
D
Telkom Polytechnic Discrete Mathematics
74 Teori Graf PAGE 10
Observe the following graph:
Vertex T and U are isolated vertices
5. Degree A vertex’s degree is the number of edges which are adjacent to the vertex. For example, vertex v has 3 edges which are adjacent to it. Then, it can be
said that the vertex has the degree of 3 or it is denoted by d(v) = 3.
For example 1: Observe the graph presented below:
On the graph above : d(P) = d(Q) = d (S)= 5, while d(R) = 3.
The degree of a vertex on a directed graph can be explained as follow::
din(v) is the number of arc coming into the vertex v dout(v) is the number of arc coming out of the vertex v
Therefore, the degree of the vertex is:
d(v) = din(v) + dout(v)
P
S Q
R
T
U
P
S Q
R
Politeknik Telkom Matematika Diskrit
Teori Graf 75 PAGE 10
For example 2 :
Observe the following directed graph:
On the graph above : din (P) = 1 and dout (P) = 3 then d (P) = 4
din (Q) = 4 and dout (Q) = 1 then d (Q) = 5 din (R) = 1 and dout (R) = 1 then d (R) = 2 din (S) = 1 and dout (S) = 2 then d (S) = 3
The number of all vertices’ degree on a graph is always even which is twice of the edges number. If G = (V, E) is a graph, then:
Evd
Vv
2)(
For example 3 :
Observe the graph on Example 1. It has 9 edges. Therefore, the degree is :
18
9.2
.2)(
Evd
Vv
or
18
3555
)()()()()(
SdRdQdPdvd
Vv
Observe the graph on Example 2. It has 7 edges, thus the number of degree is:
147.2.2)(
EvdVv
P
S Q
R
Telkom Polytechnic Discrete Mathematics
76 Teori Graf PAGE 10
or
143254
)()()()()(
SdRdQdPdvdVv
Hence, we cannot draw a graph which the degre of its edges is known but its total degree is odd.
6. Path 31. Lane of initial vertex v0 to destination vertex vT on a graph is a series of
an edge or more (x0, x1), (x1, x2), (x2, x3), …, (xn-1, xn) on G, which x0 = v0 and xn = vT. A lane does not experienced edge repetition. Lane is denoted by vertices passed by it:
x0, x1, x2, x3, …, xn If a lane does not experience vertex repetition, it is called path. A path is said to have length n, if it contains n edges passed by from the initial
vertex v0 to destination vertex vT on a graph G. A lane which starts and ends at the same vertex is called Circuit. While, a path which starts and ends at the same vertex is called cycle.
For example : Observe the following graph :
On the graph above, the length of path P, Q, R is 2. The length of
path P, Q, S, R is 3. The path P, Q, R, S, P is called cycles with the length of 4. There is no path between vertex P, U and T.
The shortest cycle length on a simple graph is 3. It means that a cycle has to pass 3 edges. Meanwhile, the shortest cycle length on a pseudo graph is 1. It means that this cycle can be a loop. Graph’s diameter
is the longest path.
P
S Q
R
T
U
Politeknik Telkom Matematika Diskrit
Teori Graf 77 PAGE 10
The graphs presented below are the most common ones: a. Complete Graph
A complete graph is a simple graph in which its vertices are connected to each other. In other words, its vertices are adjacent to each other.
A complete graph with n vertices is denoted by Kn. The number of edges on a complete graph with n vertices is n(n – 1)/2. Example :
K1 K2 K3 K4 K5 K6
Figure 4.3 Complete Graphs Kn, 1 n 6
b. Cycle Graph A cycle graph is a simple graph which each vertices degree is 2. Cycle graph with n vertex is denoted by Cn.
C3 C4 C5 C6
Figure 4.4 Cycle Graphs Cn, 3 n 6
c. Wheels Graph A wheels graph is made by adding a vertex to a cycle graph Cn and connecting the new vertex with all vertices on it.
Telkom Polytechnic Discrete Mathematics
78 Teori Graf PAGE 10
W3 W4 W5
Figure 4.5 Wheels Graph Wn, 3 n 5
d. Regular Graphs
A regular graphs is a graph with each vertex has similar degree. If the degree of each vertex is r, then the graph is called regular graph with r
degree. The number of edges on a regular graph with n vertex is 2
nr .
Figure 4.5 Regular Graph with 3 Degree e. Planar Graphand Plane Graph
A graph which can be drawn on a flat plane without its edges
crossing each other is called planar graph. If it is not so, the graph is called non-planar graph. Several examples of planar graphs:
- All cycle graphs are planar graph. - Complete graphs K1, K2, K3, K4 are planar graphs.
However, a complete graph Kn with n 5 is non-planar graph.
Planar graph K4 illustration is presented below.
Figure 4.6 K4 is planar graph
Politeknik Telkom Matematika Diskrit
Teori Graf 79 PAGE 10
Planar graph which is drawn without its edges crossing each other
is called plane graph.. Observe the following illustration on graph K4 to differentiate planar graph and a plane graph:
(a) (b) (c)
Figure 4.7 Three Planar Graphs. Graph(b) and (c) are plane
graph
Several features of planar graph G(V, E) are: (Formula Euler) For example G is planar graph connected to
edges e and vertices v, and r is the number of area on the graph, then r = e – v + 2.
If G is a planar graph connected to edges e and vertices v (v
3) then e 3v – 6 (unsimilarity Euler).
If G is a planar graph connected to edges e and vertices v (v
3) but it does not contain circuit with the length of 3 then e
2v – 4.
f. Bipartite Graph
A simple grap G is said to be bipartite graph if its vertices collection can be divided into two non-null disjoint collection V1 dan V2... Therefore, each edge on G connects a vertex on V1 and a vertex on V2. On
bipartite graph, there is no edge connecting two vertices on V1 or V2. Bipartite graph is denoted by G(V1, V2).
Telkom Polytechnic Discrete Mathematics
80 Teori Graf PAGE 10
For example :
The following graph G is a bipartite graph:
The graph above can be represented by bipartite graph G(V1, V2), with V1= {a, b} and V2 = {c, d, e}
Bipartite graph representation based on the graph above is presented below:
Figure 4.7 Bipartite Graph
V1 V2
a
c
d
e
b
a
c
d
e
b
Politeknik Telkom Matematika Diskrit
Teori Graf 81 PAGE 10
g. Labeled Graph
Labeled graph is a graph with each edge is given a label (weight).
Figure 4.8 Graph K5 with its labeled edges A graph can be labeled on its vertex. It depends on given label
representation.
4.3 Connection and Sub Graph
Vertex v1 and v2 on a graph are said to be connected if there is a path between them. If vertex vi and vj in V collection on graph G have a path from vi to vj then the graph is said to be connected graph. If it is not so, the graph
G is called disconnected graph.
For example 1 :
Wheel graph is one of connected graph:
For example 2 :
p
t
s r
q
8 9
10
13 12
11
7
Telkom Polytechnic Discrete Mathematics
82 Teori Graf PAGE 10
Observe the following graph:
(i) (ii) (iii)
Obviously, (i) C3 and (ii) C4 are connected graph. Meanwhile, graph
(iii) is disconnected graph because there is no path connecting vertices on {p, q, r} and vertices on {a, b, c, d}.
Furthermore, we will study a connection on a directed graph. A directed graph is said to be connected if we eliminate its direction (undirected graph) so it is called connected graph. Two vertices, u and v,
on graph G are strongly connected if there is a directed path from u to v and vice versa. If u and v are not strongly connected or in other words the graph is only connected on its undirected one, then u and v are said to be
weakly connected. If each pair of vertices on a directed graph G is strongly connected, then graph G is called strongly connected graph. If it is not so, the graph is called weakly connected graph.
For example :
Directed graph which is strongly connected Directed graph which is weakly connected
For example G = (V, E) is a graph, then G1 = (V1, E1) is called
subgraph of G if V1 V dan E1 E. Complement of subgraph G1 to
graph G is graph G2 = (V2, E2) in such a way that E2 = E – E1 and V2 is
p
q r
a
b
c
d
a
b
c
d
p
q r
p
q r
p
q
r
c
Politeknik Telkom Matematika Diskrit
Teori Graf 83 PAGE 10
vertices collection which E2 members are incident to it. For example, G1 =
(V1, E1) is a subgraph of graph G = (V, E). If V1 =V (G1 contains all G’s vertices) then G1 is called Spanning Subgraph Example :
(a) Graph G1 (b) Subgraph (c) Spanning subgraph
Figure 4.9 Subgraph and Spanning Subgraph of a Graph
4.4 Adjacency Matrix and Incidency Matrix of a Graph
On previous discussion, we have introduced that two vertices are said to be adjacent if both of them are directly connected by an edge.
Adjacency matrix of a simple graph is a square matrix in which its elements consist of two numbers: 0 (zero) and 1 (one). The line and column of the matrix represent each vertex of the graph. For
example, aij is element of the matrix, then: If aij = 1 then vertex i and vertex j are adjacent. If aij = 0 then vertex i and vertex j are not adjacent.
p
t
s r
q
p
t
r
q
p
t
s r
q
Telkom Polytechnic Discrete Mathematics
84 Teori Graf PAGE 10
For example :
Observe a simple graph presented below:
Adjacency matrix of the graph above is presented below :
SRQP
S
R
Q
P
0111
1010
1101
1010
It is obvious that the matrix is symmetrical and its diagonal element
is zero (0).
Meanwhile, an edge e is said to be incident to vertex v1 and v2 if e connects both of them. In other words, e = (v1, v2). Like adjacency matrix,
the elements of incidency matrix consist of two numbers, 0 (zero) and 1 (one). However, it must not be a square because the line and column on incidency matrix represent vertex and edge of the mentioned graph. For
example, aij is the element of the matrix, then: If aij = 1, it means vertex i and edge j are incident. If aij = 0, it means vertex i and edge j are not incident..
For example :
Observe the graph presented below :
P
S Q
R
Politeknik Telkom Matematika Diskrit
Teori Graf 85 PAGE 10
The form of incidency matrix of the graph is :
7654321 eeeeeee
D
C
B
A
1110000
1000011
0011100
0101111
4.5 Eulerian and Hamiltonian
4.5.1 Eulerian Circuit Eulerian circuit is a circuit passing each edge just once. A graph
containing Eulerian circuit is called Eulerian graph. While a graph which
contains an Eulerian lane is called semi-Eulerian graph. For example :
Observe the graph presented below :
p q
r s
t
G1
e2
e3 e4 e5
e6
e7 e1
B
A D
C
Telkom Polytechnic Discrete Mathematics
86 Teori Graf PAGE 10
Graph G1 is an Eulerian graph because it has a lane forming a circuit
which is : pr–rt– ts – sq – qt – tp.
It can be seen that graph G2 is a semi-Eulerian graph because it has a lane passing by each edge just once. The lane is : pq – qs – st – tp – pr – rt – tq.
Several characteristics of Eulerian Graph and Semi-Eulerian Graph :
A graph is called Eulerian graph (having Eulerian circuit) only if each
vertex has even degree. A directed graph is called semi-Eulerian graph (having Eulerian lane)
only if the graph contains two vertices with odd degree.
A connected directed graph G is called Eulerian graph only if each vertex has the same input and output degree.
A connected directed graph G is called Semi-Eulerian graph only if G is
connected to each vertex and it has the same input and output degree except the first vertex (initial vertex) has output degree more than input degree and the second vertex (terminal vertex) has input degree
more than output degree. The degree differences is only one point.
4.5.2 Hamilton Circuit
In 1859, Sir Wiliam Hamilton created a game namely dodecahedron. He offered it to a toys factory in Dublin. The game consisted of 12 pentagon
and it had 20 angles (each angle is named after the capital of a country). It provided a travel around the world visiting each capital city just once and coming back to the starting point city. It is a Hamilton circuit searching. The
problem can be illustrated by the following graph.
p q
r s
t
G2
Politeknik Telkom Matematika Diskrit
Teori Graf 87 PAGE 10
Figure 4.10 Hamilton Circuit of a Graph
On the illustration above, Hamilton circuit is denoted by bold type path. If the path is back to the initial vertex to make closed path (circuit), then it is
called Hamilton circuit. Therefore, Hamilton circuit is a circuit passing by each edge just
once. A graph containing Hamilton circuit is called Hamiltonian graph. Meanwhile, a graph containing Hamiltonpath is called semi- Hamiltonian graph.
Example :
Observe 3 graphs below:
p q
r s
G1 p q
r s
t
G3
t
p q
r s
G2
Telkom Polytechnic Discrete Mathematics
88 Teori Graf PAGE 10
Graph G1 is a semi-Hamiltonian graph. Its Hamilton path is: s – r – p – q – r.
While graph G2 is a Hamiltonian graph. Its Hamilton circuit is t – p –
r – q – p – s – q – t . Meanwhile, there is no Hamilton path or circuit on graph G3 .
For example, G is a simple graph containing n edges (at least n=3). If each
vertex’s degree is at least n/2 vertex then graph G is a Hamiltonian graph. Several things about Hamiltonian graph:
Every complete graph is a Hamiltonian graph.
On a complete graph G with n vertices (n 3), there are 2
!1n
Hamilton circuits.
On a complete graph G with n vertices (n 3 and n is odd), there
are 2
1n Hamilton circuits which are independent. If n is even and
n 4, then on a graph G there are 2
1n Hamilton circuits which
are independent.
4.6 Isomorphic Graph
Observe the graphs presented below:
Figure 4.10 Hamilton Circuit of a Graph The two graphs above consist of 4 vertices which its degree is 3. Viewed from geometry, the two graphs are different. However, both of them are not
different based on the graph principles. It can be proved by pulling the middle vertex on the second graph. It will be the same as the first graph. They are called isomorphic. In addition to the graphs above, there are many
isomorphic graphs.
Politeknik Telkom Matematika Diskrit
Teori Graf 89 PAGE 10
Two graphs are said to be isomorphic if there is one on one
correspondence between each vertex and edge. If edge e is incident to vertex u and v on G then edge e’ on G2 is also incident to vertex u’ and v’. Two graphs are said to be isomorphic if they meet the three following requirements:
a. They have similar vertices number. b. They have similar edges number. c. They have similar number of vertices which have certain degree.
To understand easily the concept of two isomorphic graphs, observe the following graph.
Example :
Check whether the graphs above are isomorphic. If yes, decide the
vertices which correspond between G1 and G2
Answer:
Yes, the two graphs are isomorphic. The graphs containing vertices in which each vertex has the degree of 3. The vertices which correspond to each other are:
Vertex u1 with vertex v1
Vertex u2 with vertex v3
Vertex u3 with vertex v5
Vertex u4 with vertex v6
Vertex u5 with vertex v4
Vertex u6 with vertex v2
u1 u2 u3
u4 u5 u6 G1
v1 v2
v6
v5 v4
v3
G2
Telkom Polytechnic Discrete Mathematics
90 Teori Graf PAGE 10
Two isomorphic graphs have the same adjacency matrix. Surely, it is decided
after corresponding matrix is sorted out by the same sequence. Observe adjacency matrix of the two graphs. Here is the adjacency matrix of G1:
654321 uuuuuu
MG1 =
6
5
4
3
2
1
u
u
u
u
u
u
000111
000111
000111
111000
111000
111000
While, the adjacency matrix of G2 is presented below: 246531 vvvvvv
MG2 =
2
4
6
5
3
1
v
v
v
v
v
v
000111
000111
000111
111000
111000
111000
It can be seen that the two graphs have the same adjacency matrix. They are
MG1 = MG2.
4.7 Several Graph Applications
a. The shortest path and lane For example: G is a weighted graph. Each edge has certain weight as the following illustration depicts:
a b c
d e f
12
28
3 10 172
132
9 11
25
8
9
9
102
Politeknik Telkom Matematika Diskrit
Teori Graf 91 PAGE 10
Figure 4.11 The Shortest Path and Lane Ilustration on a Graph
The shortest path from a to d is 22, with the path a – b – d. If we use the path a – d, a – e – d, dan a – b – c – d then the path weight will be 28, 26, dan 29.
A common thing is to decide the shortest path of the graph or to decide the path which has the minimum weight. For example:
Determine the shortest distance, the fastest time, the cheapest fare
between two cities. Determine the fastest time of sending a message between two
terminal on a computer network.
Several problems related to the shortest path are presented below:
The shortest path between two certain vertices.
The shortest path between all couples of vertices. The shortest path from certain vertex to all vertices. The shortest path between two vertices passing by certain vertices.
Dijkstra Shortest Path Algorithm Dijkstra Algorithm is an algorithm used to determine the shortest path from
a vertex to all vertices. To make it easier in understanding Dijkstra Algorithm, observe the graph below which its vertices represent the cities in the U.S. The graph edges represent the distance between two cities (in
kilometers) For example:
800
1200
1500
1000
1700
1000300
1400
250
900
1000
Boston(5)
New
York(6)
Miami(7)New
Orleans(8)
Chicago(4)
Denver(3)
Los
Angeles
(1)
San
Fransisco
(2)
Telkom Polytechnic Discrete Mathematics
92 Teori Graf PAGE 10
Using Dijkstra Algorithm, determine the shortest distance from Boston to another cities.
Then, the shortest path from: 5 to 6 is 5, 6 with the distance = 250 km
5 to 7 is 5, 6, 7 with the distance = 1150 km 5 to 4 is 5, 6, 4 with the distance = 1250 km 5 to 8 is 5, 6, 8 with the distance = 1650 km
5 to 3 is 5, 6, 4, 3 with the distance = 2450 km 5 to 2 is 5, 6, 4, 3, 2 with the distance = 3250 km 5 to 1 is 5, 6, 8, 1 with the distance = 3350 km
b. Travelling Salesperson Problem (TSP)
It is the same as the example on (a), for example you are given a number of cities and their distances. Determine the shortest circuit which has to
be passed by a salesperson if s/he goes from a city and s/he has to stop by in each city just once and goes back to the city where s/he starts. It is a problem of determining Hamilton circuit with the minimum weight.
For example :
Determine the circuit having the shortest path from a complete graph K4:
a b
c d
20
8
25
10 15 18
Politeknik Telkom Matematika Diskrit
Teori Graf 93 PAGE 10
The number of Hamilton circuit on a complete graph with n vertex: (n -
1)!/2. The graph above has (4 – 1)!/2 = 3 Hamilton circuits, they are:
Circuit 1 = (a, b, c, d, a) has the length of = 20 + 8 + 25 + 10 = 53
Circuit 2 = (a, c, d, b, a) has the length of = 18 + 8 + 15 + 10 = 51 Circuit 3 = (a, c, b, d, a) has the length of = 20 + 15 + 25 + 18 = 73 Then, the shortest Hamilton circuit is circuit 2 = (a, c, d, b, a) or (a, d, b,
c, a) with the circuit length of 51. c. Chinese Postman Problem
This problem was firstly proposed by Mei Gan (a Chinese) in 1962. It is about a postman who will deliver some letters to the addresses along the street of an area. How does he plan his traveling route in order that he
pass each street just once and go back to his starting point. It is a problem about determining Eulerian circuit on a graph.
For example : Determine the lane for the postman so that he can pass all the streets.
The lane passed by the postman is A, B, C, D, E, F, C, E, B, F, A.
a b
c d
20
8
25
10
a b
c d
8 10 15 18
a b
c d
20
25
15 18
B C
E F
7
5
4 A D
9
2
3
5
4 4
3
Telkom Polytechnic Discrete Mathematics
94 Teori Graf PAGE 10
Summary
1. A graph is a discrete structure consisting of a collection of vertices or ‘nodes’ and a collection of edges that connect pairs of vertices.
2. Two vertices are said to be adjacent if they are directly connected by an edge.
3. An edge e is said to be incident to vertex v1 and vertex v2 if e connects
both of the vertices, in other words e = (v1, v2). 4. The vertex’s degree is the number of edges which are incident to the
vertex.
5. Lane of initial vertex v0 to destination vertex vT on a graph is a series of an edge or more (x0, x1), (x1, x2), (x2, x3), …, (xn-1, xn) on G, which x0 = v0 and xn = vT. A lane does not experienced edge repetition.
6. If a lane does not experience vertex repetition, it is called path. A path is said to have length n, if it contains n edges passed by from the initial vertex v0 to destination vertex vT on a graph G.
7. A lane which starts and ends at the same vertex is called Circuit. While, a path which starts and ends at the same vertex is called cycle.
8. Eulerian circuit is a circuit passing each edge just once. A graph
containing Eulerian circuit is called Eulerian graph. While a graph which contains an Eulerian lane is called semi-Eulerian graph.
9. Hamiltonian path of a graph is a path passing by every vertex just once. If
the path comes back to the initial vertex forming a closed path (circuit) then it is called Hamiltonian circuit.
10. Two graph are said to be isomorphic if they meet the three requirements below:
a. They have similar vertices number. b. They have similar edges number. c. They have similar number of vertices which have certain degree.
Politeknik Telkom Matematika Diskrit
Teori Graf 95 PAGE 10
True or False Quiz
1. We cannot draw a simple graph with 5 vertices which each vertex’s
degree are 4, 3, 3, 2, 1 2. We can draw a simple graph with 5 vertices which each vertex’s
degree are 6, 4, 4, 2, 2
3. Every eulerian graph is a semi euler graph. 4. Graph K5 is Hamilton graph. 5. Graph C4 is bipartit graph.
6. A reguler graph with 3 degree and 4 vertices is a complete graph. 7. On a semi euler graph, all vertices have even degree. 8. W3 is a regular graph with vertex’s degree of 3.
9. The shortest path on a graph is the graph’s diameter. 10. Two isomorphic graph always have the same adjacency matrix.
Telkom Polytechnic Discrete Mathematics
96 Teori Graf PAGE 10
Multiple Choices
1. Graph C4 is isomorphic with the graph….
A. K4 D. K3,3
B. W3 E. P4
C. K2,2
2. How many Hamiltonian circuits are there on a complete graph having 5 vertices?
A. 1 D. 4
B. 2 E. 5
C. 3
3. Which one is the non planar graph?
A. Graph C4 D. K2,2
B. Graph K4 E. K5
C. Graph W4
4. The number of edges on a complete graph is…
A. 21 D. 15
B. 20 E. 12
C. 18
5. The diameter of a wheel graph W10 is
A. 1 D. 4
B. 2 E. 5
C. 3
Politeknik Telkom Matematika Diskrit
Teori Graf 97 PAGE 10
Exercises
1. Draw a graph containing five vertices. Each vertex’s degree is 2, 3, 4, 1,
and 3 !
2. Check the following graph whether it is an Eulerian graph, semi-Eulerian graph or its is none of them! (Explain it.)
(For question number 3 – 7) Observe the graph presented below :
3. Determine the graphs’ adjacency matrix.
4. Give an example of spanning subgraph of the graph above. 5. Mention a complete graph which is its subgraph of the graph above. 6. Determine the shortest lane of the label graph presented below :
u1 u2 u3
u4 u5 u6
b
c
d e
f g
6 2
3 4
1
5
6 2
4
a
Telkom Polytechnic Discrete Mathematics
98 Teori Graf PAGE 10
7. Check whether the graph above is a Hamiltonian graph.
8. See the following graph :
Check if the graph above is a planar graph. If yes, write its plane graph. If no, explain its reason.
(For Question no. 9 – 13) Observe the following graphs :
G1 G2
a
b
c d
e g
f
h
j
i
o p q r
s t u v
a
c d
b a
e f t u
s r
q p
Politeknik Telkom Matematika Diskrit
Teori Graf 99 PAGE 10
9. Are the two graphs above an Eulerian Graph, Semi Eulerian Graph or
not both of them? Explain it! 10. Check if graph G1 or G2 is a Hamiltonian Graph, Semi-Hamiltonian
Graph or not both of them. Explain it! Write one of Hamiltonian circuit or Hamiltonian path, if any.
11. Check if G1 or G2 is a complete graph or regular graph or not both of them. Explain it!
12. Check if G1 or G2 is a Bipartite graph. Explain it!
13. Is graph G1 isomorphic to graph G2? If it is not, explain its reason. If it is yes, explain and prove it by providing adjacency matrix.
Telkom Polytechnic Discrete Mathematics
100 Pohon dan Pewarnaan
Graf PAGE 10
TREE AND GRAPH COLORING
Overview
Tree is an important part on a graph theory which does not have a cycle. It is usually used in binary theory starting from binary tree expression up to
binary tree tracking. Tree application discussed in this chapter are expression tree and its use on decision tree and Hufman coding. Meanwhile, coloring is one of aplication on optimization field. Graph coloring discussion covers
vertex coloring and area coloring. Graph coloring is widely used in scheduling problem optimization to determine minimum color on a graph which represents scheduling problems.
Objective
1. Students understand the tree concept and graph coloring. 2. Students understand minimum application of spanning tree and
graph coloring.
3. Students are able to understand and solve problems and phenomena related to tree and graph coloring.
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 101 PAGE 10
Tree is a special form of a graph structure. For example A is a
collection of vertices on a connected graph G. For each pair of vertices on A, we can determine a path connecting pairs of vertices. A connected graph with its pair of vertices that can be connected only by certain path is called tree. In other words, a tree is undirected graph which is connected but it
does not have cycle or circuit.
Figure 5.1 G1 and G2 are trees, G3 is not a tree
A forest is a collection of independent trees. In other words, a forest is a disconnected graph which does not have a circuit. Every
component in connected graph is the trees. Figure 6. 1 G4 is an example of a forest consisting of two trees.
Several trees’ characteristics are presented below :
For example G is a graph with n vertices and n – 1 edges. If G does not
have a circuit, then it is a tree.
A tree with n vertices has n – 1 edges.
Every pairs of vertices in a tree connects to a single path.
Suppose that G is a simple graph with n vertices. If G does not contain
circuit then one edge addition on the graph will make only one circuit.
G1 G2 G3
a b
c d
e f
a b
c d
e f
a b
c d
e f
Telkom Polytechnic Discrete Mathematics
102 Pohon dan Pewarnaan
Graf PAGE 10
4.8 Minimum Spanning Tree
Spanning Tree of a connected graph is a spanning subgraph in the
form of tree. Spanning tree is obtained by eliminating the circuit on the graph.
G T1 T2 T3 T4
Figure 5.2 Graph and Spanning Tree
It is obvious that T1, T2, T3, T4 are spanning trees of graph G. Bear in mind that every connected graph with the minimum weight has a spanning tree. A
tree having minimum weight is called minimum spanning tree. One of spanning tree applications is to determine series of streets with a very minimum total distance to connect all cities so that every city is connected
to each other. To determine a spanning tree of a connected graph, we can use two ways e.g. Prim algorithm and Kruskal algorithm. Prim algorithm has several steps below:
Choose a minimum weighted edge of the graph G. Insert it into T. Choose edge (u, v) on G which has a minimum weight and is
incident to vertex on T. This edge does not form a circuit on T.
Insert (u, v) into T. Repeat step 2 for n – 2.
The number of steps in Prim algorithm is equivalent to the number of edges in the spanning tree with n vertices which is (n – 1).
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 103 PAGE 10
Example 5.1 :
Determine minimum spanning tree of the graph presented below :
Answer :
Choose edge fg so that we have T ({f, g}, fg)
Next steps can be choosing edge ef because this edge has a minimum weight and it is adjacent to vertex f.
Next, choose edge ae or as these edges have minimum weight and
they are incident to vertex T, which are e and g. If the process continues, we will obtain the following minimum spanning tree :
It can be noticed that the spanning tree has the total weight 2 + 3 + 4 + 4 + 4 + 4 + 3 = 24.
Kruskal algorithm steps are slightly different from Prim algorithm. In Kruskal
algorithm, all edges having minimum weight are put into T consecutively.
a
b
c
d
e
f
g
h
5
5
4
4
5
4 5
4
3 2
3
4
a
b
c d
e
f
g
h 4
4
4
3 2
3
4
Telkom Polytechnic Discrete Mathematics
104 Pohon dan Pewarnaan
Graf PAGE 10
The steps to determine minimum spanning tree by Kruskal algorithm are as follows : Step I : T form is like the following tree
Step II : Inserting edges weighted 3 so the form of T is
Step III : Inserting edges weighted 4 so finally we get minimum spanning tree as the following picture:
4.9 Rooted Tree
A tree which its edges are given direction is similar to directed graph.
All vertices connected to all vertices on the tree are called root. A tree with
f
g
2
c
e
f
g
3 2
3
a
b
c d
e
f
g
h 4
4
4
3 2
3
4
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 105 PAGE 10
its vertex treated as a root is called rooted tree. See Figure 5.3 (a). A vertex
role as a root has input degree 0. A vertex which functions a root has input-degree equal to 0. While, other vertices has input-degree equal to one. On a rooted tree, vertices whose output-degree equal to 0 is called leaf. Later on, direction component are abandoned so a rooted tree is depicted as an
undirected graph 5.3 (b)
(a) (b)
Figure 5.3 Rooted Tree
Several terminologies on rooted tree are as follow: a. Child or children and parents
If there is an edge between two vertices, the vertex which is closer to the root is called parents while other edges are called children. It can be noted on Figure 5.3 that b, c, and d are the children of vertex a, and a is the parent of the children. G and h are the children of d, while d is their
parents. Furthermore, a is called the ancestor of e, f, g and h. While e, f, g and h are called descendant of a. In addition, f is e sibling, but g is not e sibling,
because their parents are different.
b. Path
The path from a to h is a, d, h with its length is 2. On a tree, the path between two random vertices are unique as there is only one path.
a
b
c d
e f g
a
b
c d
e f g h h
Telkom Polytechnic Discrete Mathematics
106 Pohon dan Pewarnaan
Graf PAGE 10
c. Subtree
For example d is a vertex on a tree, then subgraph (tree) consisting of d with all descendants are called subtree. On the following example, the inside part is the subtree of the main tree.
c. Degree The degree of the vertex is the number of children on it. On Figure 5.3 :
Vertices having 0 degree are vertices of c, e, f, g, and h
No vertices having 1 degree.
Vertices having 2 degree are vertices b and d.
Vertex having 3 degree is vertex a.
Degree on this context is output-degree. Maximum degree of all vertices is the degree of the tree itself. Thus, the tree on Figure 5.3 having 3 degree.
d. Leaf
Vertex with 0 degree (or having no children) is called leaf. Vertices c, e, f, g and h are leaves.
e. Internal vertex
Vertex (except root) having children is called internal vertex. Vertices b
and d are called internal vertex.
a
b
c d
e f g h
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 107 PAGE 10
f. Level
Root has the same level with 0, while other vertex depends on its position. For example, on Figure 5.3, it can be seen that b, c and d are on level 2. While e, f, g and h are on level 3.
Rooted tree whose children order are important is called ordered tree. While, rooted tree which its branch vertex having maximum n children is called n-ary tree. If n = 2, its tree is called binary tree.
Example 5.2 :
The followings are several examples of binary tree:
1. Expression Tree Aritmetic expression (a * b) – ((c + d) / e) can be stated in a binary tree, in which the alteration is as the leaf and aritmetic
operator as the internal vertex and root.
2. Decision Tree
a b
c
e
d
+
* /
–
Telkom Polytechnic Discrete Mathematics
108 Pohon dan Pewarnaan
Graf PAGE 10
A tree in which its internal vertex corresponds to a decision is
called decision tree. One function of the decision tree is to sort complexity from any kinds of algorithm.
Figure 5.4 Decision Tree to Sort Three Diferent Elements [4]
3. Prefix code Prefix code is code collections (one of them is binary code) in such a way that there is no collection member which is the prefix of
other codes. Example :
{ 001, 010, 011, 11} is a prefix code. If it is stated in binary
tree, it will be :
a : b
a : c b : c
b : c c > a > b a : c c > b > b
a > b > c a > c > b b > a > c b > c > a
b>c a>c
a>b
b>c
b<c a<c
b<c a>c a<c
A<b
1
11
0
0
0
1
11
1
010000 011
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 109 PAGE 10
4. Hufman Code
Hufman coding is often used in data compression. Observe the table of ASCII code:
Symbol ASCII Code
A 01000001 B 01000010
C 01000011 D 01000100
Then bit series for string ‘ADABACA’ , can be represented inthe form of :
01000001010001000100000101000010010000010100001101000001
Code length of the string is
7 8 = 56 bit (7 byte).
Table 5.1 Table of Huffman Code for string ’ADABACA’
Symbol Frequency Possibility Huffman Code
A 4 4/7 0
B 1 1/7 10
C 1 1/7 11
D 1 1/7 110
Thus, bit series for string ’ ADABACA’ is :
01100100110 or the 56 bit can be written in 11 bit.
4.10 Binary Tree Tracking
For example, the following picture is a binary tree in which A is the root. S and T are subtree of the binary tree.
S T
A
Telkom Polytechnic Discrete Mathematics
110 Pohon dan Pewarnaan
Graf PAGE 10
There are 3 kinds of binary tree tracking :
1. Preorder : A, S, T - visit A - visit S preorderly - visit T preorderly
2. Inorder : S , A, T - visit S inorderly - visit A
- visit T inorderly 3. Postorder : S, T , A - visit S post-orderly
- visit T post-orderly - visit A
For example : Determine the result of preorder, inorder, and postorder tracking of the tree presented below:
Answer :
preorder : – * a b / + c d e (prefix)
inorder : a * b – c + d / e (infix) postorder : a b * c d + e / – (postfix)
a b
c
e
d
+
* /
–
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 111 PAGE 10
4.11 Graph Coloring
Graph coloring is an assignment of colors to several vertices on graph
G in such a way that no two adjacent vertices share the same color. In addition to vertex coloring, there is edge coloring. However, this chapter will be focused on vertex coloring.
A graph is said to have color n if there is n color in graph G
coloring. Minimum colors required in graph coloring are called chromatic
numbers denoted as )(G ( : read or pronounced chi).
For example :
Chromatic number of a complete graph -n (Kn) is n. It is caused by
every vertex on a complete graph is adjacent. Then (Kn) = n. Observe a complete graph with 5 vertices presented below :
Its graph coloring needs 5 colors.
Welch-Powell algorithm in graph coloring can be illustrated as follow : 1. Sort all vertices on graph G based on their degree starting from the
biggest to the smallest. This order is not unique because several
vertices perhaps have similar degree. 2. Use first color to color first vertex and other vertex which is on the
order as long as the vertex is not adjacent to the previous vertex.
3. Give second color to color vertex on the highest order (which has not been colored). Do it just like the previous step.
4. It is like the third step. Do it continuously until every vertex on the
graph becomes colorful.
a
b c
d e
Telkom Polytechnic Discrete Mathematics
112 Pohon dan Pewarnaan
Graf PAGE 10
5. Welch-Powell algorithm only gives top limit of chromatic number.
Thus, this algorithm does not always give the number of minimum color needed in graph coloring.
Example :
Use Welch-Powell algorithm for graph coloring :
The order of vertex degree is as follow: a b c d e f 4 3 3 3 2 1
Thus, graph coloring can be done as follow : Color I for vertices : b, f
Color II for vertices : a, d, e Color III for vertex : c
For example G ia a graph, the following statements are euivalent :
G is a bipartite graph
Chromatic number of G is two ( )(G = 2 )
Every circuit of G has an even length
For example :
a
b c
d e
f
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 113 PAGE 10
Observe the following bipartite graph K3,3 :
Graph coloring on the graph above can be done by two colors, such as :
Color I for vertices a, b, c
Color II for vertices d, e, f If we want to make a circuit on the graph, the circuit will pass 3 or 5 vertices before it comes back to the initial vertex. Thus, the circuit has
an even length.
Map Coloring
Before discussing area coloring on a planar graph, observe the following definitions related to planar graph :
Area r1, r2, r3, r4, and r5 are called region of the planar graph. Two regions
on a planar graph are said to be adjacent if they have at least one similar vertex.
The example of adjacent regions:
r1 and r2
a b c
d e f
p
q r
t
s
u
r1 r2 r5 r3 r4
Telkom Polytechnic Discrete Mathematics
114 Pohon dan Pewarnaan
Graf PAGE 10
r2 and r3
r2 and r5 r4 and r5 r1 and r5 r2 and r4
The example of non-adjacent regions: r1 and r4 r5 and r3
r3 and r4 The number of regions adjacent to a region on a graph can be obtained by calculating the number of regions which have at least an edge with the region
itself. Thus, each region has adjacent region as follow :
r1 has 2 adjacent regions : r2 and r5
r2 has 3 adjacent regions : r1, r3 dan r5 r3 has 1 adjacent region : r2 r4 has 2 adjacent regions : r2 and r5
r5 has 3 adjacent regions r1, r2 and r4 Region coloring (map) on a planar graph G is a mapping of color collection to
several regions on a planar graph G in such a way that the adjacent regions do not share the same colors.
For example : Observe the graph presented below :
Conduct a region coloring using : a. 3 colors b. 2 colors
Answer :
a. Graph coloring using 3 colors :
Color I for regions r1 and r4
p
q r
t
s
u
r1 r21 r51 r31 r41
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 115 PAGE 10
Color II for region r2
Color III for regions r3 and r5 b. Graph coloring using 2 color is impossible to do. It is because
region r2 , r4 and r5 are adjacent to each other.
The duality of map coloring is vertex coloring of a planar graph. Bear in mind that graph coloring will connect to vertex coloring of dual G*. In other words, a map G is colored n if only planar graph of dual G with n color. To
make it clearer, observe the following graph:
Choose a vertex on the graph below. Connect the two vertices with an edge if the two regions are adjacent.
If we draw a graph, it will be as follow :
r1 r2
r3
r4
r1 r2
r3
r4
r4
Telkom Polytechnic Discrete Mathematics
116 Pohon dan Pewarnaan
Graf PAGE 10
Map coloring can be represented in vertex coloring. The most important thing is a given graph model represents real problems.
r1
r2
r3
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 117 PAGE 10
Summary
1. A connected graph with its pair of vertices that can be connected only by certain path is called tree. In other words, a tree is undirected graph which is connected but it does not have cycle or circuit.
2. Spanning Tree of a connected graph is a spanning subgraph in the form of tree. Spanning tree is obtained by eliminating the circuit on the graph.
3. A tree having minimum weight is called minimum spanning tree.
4. There are several terminologies worthed to know such as root, leaf, subtree, the shortest path, etc.
5. There are two algorithms to determine minimum spanning tree, Prim and Kruskal.
6. Graph coloring is an assignment of colors to several vertices on graph G in such a way that no two adjacent vertices share the same color. In addition to vertex coloring, there is edge coloring.
7. Minimum colors required in graph coloring are called chromatic
numbers denoted as )(G ( : dibaca chi).
8. Map coloring is the duality of vertex coloring of a graph.
Telkom Polytechnic Discrete Mathematics
118 Pohon dan Pewarnaan
Graf PAGE 10
True or False Quiz
1. Tree is a subgraph of a graph.
2. Two vertices on a tree are only connected by a path. 3. Chromatic number of a tree is 2. 4. If two vertices having the degree of 1 are connected by an edge, then
the graph is still a tree. 5. Minimum spanning tree of a graph K10 is a tree with 10 edges. 6. For example, G is a graph, the complement of minimum spanning tree
graph G is a tree. 7. The number of colors used to color wheel graph W7 is 3. 8. Hufman code is usually used in graph coloring. 9. An aritmetic expression can only be stated on a expression tree.
10. Map coloring can be analogized with common vertex coloring.
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 119 PAGE 10
Multiple Choices
1. It is impossible to find it on a tree.
A. Root D. Cycle
B. Leaf E. Children
C. Path
2. Chromatic number of graph C5 is ….
A. 2 D. 5
B. 3 E. 6
C. 4
3. The minimum number of color for coloring bipartite graph is ….
A. 1 D. 5
B. 2 E. 4
C. 3
4. A complete bipartite graph K3,3 is not a tree because
A. Disconnected D. Vertex’s degree is the same
B. Impossible to color E. Must have cycle
C. Divided into two
5. The following is the example of the use of binary tree, except….
A. Expression tree D. Decision Tree
B. Minimum spanning tree E. Prefix code
C. Hufman code
Telkom Polytechnic Discrete Mathematics
120 Pohon dan Pewarnaan
Graf PAGE 10
Exercise
1. Determine all spanning trees of the following graph :
2. Observe the following graph data : a. Graph G1
b. Graph G2
Determine minimum spanning tree using Prim Algorithm and Kruskal
Algorithm
B C
EF
8
5
3A D
8
2
1
6
44
2
p q
r s
t
a b
c
d e
f g
3 4
1
5
6 2
4
Politeknik Telkom Matematika Diskrit
Pohon dan Pewarnaan Graf 121 PAGE 10
3. Make a sketch of binary graph (expression tree) representing expression
: a. p / (q – r )*(s + t) b. (p + q) / r – (s + t * u)
4. Determine the result of expression tree tracking on question number 3 in the form of preorder, inorder, and postorder.
5. On the following graph, vertices collection defines a collection of villages in a district. A budget for village street development is created as weight (in million rupiahs) on each edge. Determine minimum cost prepared for
the village street development so that all villages in the district will be connected. (Bear in mind the definition of ’connected’ in a graph).
6. Use Welch-Powell algorithm to color the following graph :
a
f e d c
h
b
j i
g
a
f e d
c
h
b
j i
g
6
5
7
3
5
4
6
3 5 4
7 8
6
6
Telkom Polytechnic Discrete Mathematics
122 Pohon dan Pewarnaan
Graf PAGE 10
7. In a semester, the schedule of final exam will be created. The schedule
covers Calculus, Discrete Mathematics, Physic, English, Bahasa Indonesia, Religion, Pancasila and Chemistry. There is no students who take the following pair of subjects on a smilar time in the same semester :
- Calculus & Chemistry
- Discrete Mathematics & Chemistry
- English & Bahasa Indonesia - English & Religion
- Calculus & Discrete Mathematics - Calculus & Physic
- Physic & English However, there are students who take a combination of subject at similar time in the semester.
How many minimum time slot required to create the final exam schedule so that the students will not encounter two or more exams at the same time?
8. How many colors required for map coloring (map) below?
p q
r s
t
Telkom Polytechnic Discrete Mathematics
Daftar Pustaka
Kolman, B., Busby, R. C., Discrete mathemetical Structures for Computer
Science, 2nd edition, Prentice Hall, New Delhi, 1992
Munir, R., Matematika Diskrit, Edisi kedua, Informatika, Bandung, 2003
Lipschutz S., Lipson M., Discrete Mathematics, McGraw Hill USA, 1997
Rosen, K. H., Discrete Mathematics and Its Applications, 5th edition,
McGraw-Hill, Singapore, 2003
Slamet, S., Makaliwe, H., Matematika Kombinatorik, Elek Media
Komputindo, Jakarta, 1991