Download as pdf
Download as pdf
You are on page 1of 55
Contents Chapter) : Page No. 1. Foundamental 1-22 1.0. Introduction 1 1.1. Basic Ideas 1 LLD Set a i 1.1.2 Operation on the sets 3 113° Function 4 1.14 Matrix 10 1.2. Algorithm 1 Definition ll Properties of algorithm, MW Searching Algorithm u Sorting 14 Greedy Algorithm a iG The Growth of Function 17 Growth of Combination of Function» 20 Big Omega notation 21 Big Theta @ notation 21 1.2.10 Complexity of algorithms 21 Exercise 1 22 2. Relations . 23-48 2.0 Introduction 23 2.1. Relations 24 2.1.1 Function as relation 24 2.1.2 Relation ona set . 25 2.2. Properties of relation 25 2.2.1 Reflexive . 25 2.2.2 Symmetric 26 2.2.3. Anti-symmetric 26 2.2.4 Transitive oe 2.2.5 Combining relations 26 2.3. Theorem 28 2.4 n-ary relation and their applications 29 24.1 nary relation 29 24.2 Application 29 2.5 Representating relation 29 2.5.1 Using matrices 29 2.5.2. Using diagram or (directed graph) 31 ‘Scanned with CamScanner 26 Closure of elation 261 Closure 262. Paths in directed graphs 263 Equivalence relation 264 Equivalence Class 27 Partial Ordering 27.1 Lexicographic Order 2.72 Hasse diagram Exercise 2 Graph therory 30 Introduction 31 Graph 3.1 Simple graph 312 Loop 313 Midi-graph BIA Pscudographs 32 rected graph 4.21 Simpl directed graph 422 Directed mult-grophs 323. Directed Pseudograph 324 Maced graph 323. Graph Terminology 33. Degree of vertex 331 Isolated verter 332 Pendant verter 333 Indegree of verter 334 Ouedegrec of Vertex 3.4 Complete Graphs 35 Cycles 3.6. Wheels 37. Bipartite Graphs 371 Compete Bipartte Graphs 3.8. Subgraph 38.1 Union of simple graph 3.9. Representation of graph JIL. Adjacen list 4.9.2 Adjacency Matrices for simple graph 393. Adjacency Matrices for mult graph 3.94 Incidence Matrices 3.10 Isomorphism of Graphs 33 3 34 38 38 a 4 49-104 3:11 Path 6 JULI Crew n 3112 Simple path 1 3113 Single crews n 4 Conmeced graph p % 3.113 Cur vertices fr cat point or articulation, 2 3.118 Curger Ore? an) 3117 Bridge or cut edge) 0 | He cet : 9 Underying undirected rf HILO Meld comeced 7" 0 31111 Buler past a 3.1.12 Euler circuit 2 3.11.13 Hamilton path 2 3.11.14 Hamilton eircut 2 3.12 Matching 85 3.13 Planar graph 86 3.121 Degree of region "7 3.14 Weighted graph 90 341 Disa’ Algoritim 0 3.14.2 Steps to find the shortest path by tsing Distr’ algorithm. a1 bvercive 3 99 Trees 105-108 40 Introduction 105 41 Tree 106, 411. Rooted ree 108 412 Parem of vina rooted ree 109 403. Chia 109 AIS Siblings 10 413 Ancestors na 416 Descendants m 417 Leaf in 418° Internal vertices 12 419° mary ree 1B 41.10 Full mary ree 1B 41.11 Binary ree ua 412 Lef and Right hid us 41.13 Subtree us 4114 Lef subtree A 415 Right subree Ww 4.1.16 Level of a vertex ty 4LLIT Height of arooted ree Scanned with CamScanner 4118 Balanced ay 4.2. Binary Search Tree ae 43. Traversal Algorithms Ls 431 Preorder Traversal 126 43.2. Inorder Traversal 127 433. Postorder Traversal 19 4.4 Spanning trees i 7 445. Algorithm to produce a spanning t : 451 Breath-First Search 132 132. Depth-Firs Search bs ‘46 Representation of algebraic structure by binary trees 136 “17 tix postfix and prefix notation of an arithmetic expression 137 47.1 Inficnotaion 7 472 Prefix notation a 473 Postfix notation BB 4,8. Tree teaversalin binary tree 139 481 Preorder traversal 39 482. Postorder traversal 140 483. Inorder traversal 40 484. Constructing binary ree when inorder fand preorder maversal ofthe are is giver. 140 485 Constructing binary iree when inorder ‘and postorder traversal ofthe tee is given m exercise & 13 Network flows 149.168 50. Introduction us 5.1. Network (Graph as model of flow) asi 5.2. Network flows, 2 53 Maximal flow and minimal cut 153 54. Alabeling Algorithm 163 exercise 5 ie TU Question 2072 367 TU Question 2073, 168 Bibliography Ba Index i 1.0 Introduct ‘The German mathematician and logician George Cantor (1885-1918) known as the inventor of set theory created a theory and made it into & mathematical discipline. A set is a collection of objects, nothing more and nothing Tess. It sounds simple, but set theory is one of the basic building blocks for higher mathematics. To give ita more precise shape, by 8st, it means a collection of objects such that given any object, it is possible to ascertain whether that object belongs to the given callection of not. For example, we can take a set of integers, set of students in the particular class, fic. Ifx is an member (element) ofa set A we ‘say x belongs to and is expressed as xed. fy isnot a element of 4 we say y does not belong to ‘A and is written as yet, The capital leters 4, B, X, Y ete. are used for Genoting sets and smal letters a 6, c, x, yete.for the elements (or members ‘or objects). Georg Cantor 18854.D.- 1918 AD. 1.1 Basic Ideas 1.1.1 Set. A sets a well defined and unordered list or collection of objects. The objects in a set are called the elements or members of a set. Set is denoted by capital leters and its elements are denoted by small letters. ‘The collection of good teachers in 9 Tri-chandra Campus is nota s sinee the term "good teacher i vague and it is not well defines However, the collection of all teachers in a Tri-chandra Campus is @ set ve Scanned with CamScanner 2 Fundomentols Example: 1 2) The set of al vowels inthe English alphabet can be writen a Ve (ae, i,0,u}, 1) The set Eof even postive integers less than 10 can be expresseg by Evo = (0,2, 4,6, 8}. Types of sets 1 Empty set (or null set) Asset is said 0 be empay oF null or void set ifit has no element, The empty set is denoted by ¢ oF {} Example: 2 2) Themumber of male students in PK campus i empty set 1) Thenarurl number between 0 and 1 is empty set ©) (re Rix=-9} isa empyy set Asetis sid 0 be nonempty or non-void fit has at leas one element 2. Singleton set ‘A set contain oly one single element is called singleton ser, * Example: 3 8) These (1) isa singleton set b) These of satellite ofan earth isa singleton set. 3. Equal sets ‘Two sets are equal if and only if they have the same elements. For example two sets 4 = {1, 3, 5} and B= (3, 5, 1) are equal because they have same element. Note that the order of element in a set does not mater, Subset Let and B be two sets, Then, the set 4 is said to be a subset of B if and only if each element ofA is also an element of B. To indicate that A is subset of B, we use A c B notation, Mathematically, €A>x eB iff Ac B) Fact: for every set 4, O bcAandGiyaca ITA is not a subset of B, we write A ¢ B. “acconsise Tertbook of Discrete Mathematics /3 5. Finite set ‘Ast is sai to be finite if it contains finite mumber of elements Example: 4 . {fis the set of natural numbers less than 5, then st 5 finite because has only 4 elements namely 1, 2,3 and 4 6. Infinite set ‘A set is said to be infinite if t contains infinite number of elements. The set of irrational numbers between 0 and | is infinite 7. Power set Let Abe the set. Then the power set ofA isthe set ofall subsets of the set A, Its denoted by P(A). Example:5 Let A= {0, 1,2} then the power set of 4 is POA) = 44. (0), (1. (29, (0,19, 0,29. (1e2H, £05121) Note: The power set of empty set @ is 6 and the power set of non- ‘empty set is always non emp. Cardinality of a set “The total numbers of element contain in the set is called eardinality of that set. IFA = (1,2. 3,4 5, 6,7, 8} then its cardinality is 8 be, (4) = 8. nis denoted by 4), 1.1.2 Operation on the sets (@) () Union 7] Let A and B be two sets. Then, the union of 2 the sets 4 and 8, denoted by 4 U 8, is the 7 set that contains those elements that are either in or in B, or in both, Mathematically, AU B= {x © A orx © B) AUB Interseetion i 7 Let A and B be two sels. Then, the ICQ or itesecton ofthe sets A and B, denoted by “4.0 By isthe set containing those elements that ae in both and 8 408 Mathematically, AQB= (xix € A andx € BY . Scanned with CamScanner 4 J Fundamental (©) _ Difference ; wet and B be oats THEN IE vigeance of 4 and 8, dened 9 A= ‘thoser containing those elements that STS + A butt arin AB ‘Mathematically, A-B= (xix Aandxe B) ; Note: Symmetric difference Between A and B is denoted by A 4 B any ghenby A AB = (4-8) UB-A (€) Complement Ten Ube the uivral set and AU: Then the Ford’ complement ofthe st A is denoted by 7 or A is Free fal hose elements of U which are notind Ff ADB BY, Mathematically, 4 = (zx € Uandx € A. Cartesian product Let and B be two non-empty sets. Then, the Cartesian produc EStoten and B isthe set of all ordered pairs in which ist element belongs to 4 and second element belongs t0 Leta= {a,b,c} and B= (1,2) “Then, A ~ B=((0 1) (4,2) Cb, 148.2) (6, 16.20) Relation Let A and B be any ses and A * B be the cartesian product between them. Then any subst of» Bis called relation from Ato B. 1.1.3 Function Let and B be two non-empty sets. Then, the relaion f: A —> Bis ssid to be funtion from 4 to B if every elements of 4 has unique association of elements of B, f “A consis Textbook of Discrete Mathematics /5 Set A is domain and B is co-domain of / > The collection RCS) = (y LE): € A) is called rane oF image off Typesoffunetion 1. One toone (injective) fun [A function fA -> Bis sid to be injective function if distinct Clements oF4 have distinct images in B Mathematically, fsa € Athen #528) 4/29) By contrapositive, if x1, x; € A, then f(x1) =/(2) > Example:6 2) f:R-> Rsuch/(a)=x+ 1 Ve € Ris oneto one by) f: ZT such that f (x) = x7 for all x € Z is not one to one ‘because f(-2) ~ 4 and f(2) = 4. Thus,-2,2 ¢ Z and -2 #2 but Hence, f is not one to one. 2. Onto (Surjective) function {A function f: A > Bis said to be surjective (or onto) if each elements in B have atleast one pre-image in 4. ‘Mathematically, for any y € Bx € A such that /(x) Example: 7 a) f:E> Zsuch that (x)= x +1 Ve € Zis onto b) f:Z> Zouch that/(x)=x7 Vx € Zisnot onto, 3. Bijective function (one-one correspondence) A function fA > B is said to be bijective if it is both injective and surjective Example: 8 a) If A= {1,23} and B= (1, 4,9} then the function defined by fa) =2 Vx € A isbijective. 4, Composition of function Let fd > Band g : B > C be any two functions. Then we can Schoen gf: A» Cty Gop 6) vreatns fiction weed compe ncn, OY #6 ATS Scanned with CamScanner 6 /Fundomentos Let be any se, Then a function f : A> A defined by f(x) =x Vx e Ais called identity faction. It is usually denoted by Thus, 4) =x Vee. 4 \ f Let A, BR. Then f:A > Bis called increasing function if fr any ny eAx Biscalled deere itforany nye A.2/4), Strictly decreasing function ing function Let A Be: ABSR Then f:A- Bis called srcly decreasing = -- “aconise Tetbook of Discrete Mathematics /7 if for any x,y € A,r B be any function. Then the graph ofthe function J is the set of all ordered pairs ((s.y) sx © A andy € 2} Example: 9 8) Display the graph of the fimetion ': Z + Z defined by x Vee Z where Z= (0, #1, 22...) is the set of b) Display the graph ofthe function f: RR defined by J@)=a Vee R Scanned with CamScanner 1a a4 Aq sopis og SunsidiAI, ont wy "91 i tenes) 9 te} dod wxp'9:¢pueoqunu jar3m 4 pa 231 Leas ae se uanum st" 4° ° 204 ous aL si zr iadues us yess 2 wt gt a1 pat i*0 ai2ym fro) joqus a Aq unin sp" 20 HOD ssounbos a wt a ka prop su) fst Cu) /95 aBeU aH UH > 430) "H) fa 3p Jo nn29 fur 01 s29quR ruowtaury ain st souanbos ay jo WOU AL'S PS Fen jobs amr oo pauyop . N 'f uubuy © s aakenbor y suonewuns pue sasuanbas b'L"L PECTS M POE ETI = NN ewan EHT vag pouyop_N ENS voNDu 95! MeNDunY OR AL sg smnoweusry 212280 f 7D 2840) ¥ Bey © oz) @ Tl @ tei § uy be aiden | Kapaa 0 ame 21 tn ol ee X squat 301 Soon wouunf Bayes ne (sou suny 1083)01ysoyetas 99) aonsany Zama s-[t0-] @ 7 a OL idee 1] 6 peousp x won 04 ame eb 0 mp 9 5 ony 2800 lean sy x qui feat ap of SSO opounf sof 24 (wonsuny s08apuy 359}6043 aq) 40) woHDURy Joy *T area oem eee “wonduny wueyodu! awos sionsowepuns / 8 ———== . § “| } Scanned with CamScanner {yuouiqa 1598s ay) st zu) ‘p= DU NAHL > 0m aL woLt=!404 ) Jo wnuNeY :TMAGADONA ‘ouanbas ayy © ur uewway> wnuuIxeU! 2Ip Supt (si8aq 0-30) wyywobly Buryaieas £71 12 renoned © oj isn you asea 2 40} pljen aq pmoys aunpao0.g Ges2099 (W umowe 24 © u ajgeatjdde pu annayja 2g pjnoys emnpaoo1g ssumumaya (9) ‘sonyes indino pau0> daqpoudpynoys un 52192140) ‘ua|goud v yo wornyos So1 sonjes yndino song wnquodje anjen indus wouy sanding, 425 pay}zads e woy anjea induy sey wy wyiobje yo sansadoug Z°7"L ‘ua|goud © anos co} S@ojopornaus 40 sdais Jo saUas © st UNO Ue ‘spiOM JO4T0 Uy ua|goad eSursos 0} 40 uoneaqe> fe Suiuojied soy suouonasur Pex? Jo ws aTUY e st wuymO%p UY (eac"zu02 25a vonmuyag LL wyyoBly Z°L Lb /souowayaoyy 2121289 fo x00q)2] 21540) ¥ q poiousp xsoue pajte> 89° Gy tp ay | Mop ity uy s29q]jns a}gnop yius si9H9,peus Nujet Jo wowa|9 pue i212] je11de> Kq poiousp st a, Stuinjoo pue sod ur siaquinu jo Keure sejnuciaa4 y URW S°L" +e o-f 00) +45 = "5010 o-f Hatley = o- 1491+ frepa om Beyys) yo e teu o-f waz syowuowepuns / Ob L @ Scanned with CamScanner BB (Linear Search) ‘The linear search algorithm, PROCEDURE: Linear search (x : integer a, a, integers.) real mandx #4) sit 05. y distinet WHILI IF i'm THEN location: = 1 ELSE location: = 0 {Location is the subscript of the term that equals x, or is 0 if x is not found}, (Binary Search Algorithm) se, 2072, 2073} PROCEDURE: binary search (x : integer, a ay; increasing, left end point of search interval) i= {jis right end point of search interval} WHILE i aq THEN i= m+ 1 ELSE j=m END IF x= a, THEN location = 4 ELSE location =0 cation isthe subscript of the term equal to x or O ix isnot found} Example: 13, Search 19 from the lis: (se, 2073) 123567810 12 13 15 16 18 19 20 22 Solution The given list is 123567810 12 13 15 16 18 19 20 22 ‘A Consse Tertbook of Discrete Mathematics / 13, ing above list into two equal halves 123567810 12:13 15 16 18 19 20 22 term i into two equal halves 19,i€,, 10<19 12131516 18.19 20 22 again a, = 16<19 x80; Spliting into two halves 18 19 20 2 Comparing a, = 19 Split into two halves 18 9 I< 19 search is So, x#a; restricted only in one term 719 ‘Thus, location i= 1. Example: 14 Using the binary search algorithm, search a number 37 from the ist of the numbers 1 69. The given list is BID 1€,1,3,7,9) 13, 24, 25,27, 31, 33, 37, 39, 43,45, 47, 51,53, 51, 59, 63, 65, 69. Splitting above list into two equal haves as First half: 1,3, 7 5, 19,21, 25, 27,31, 33, Second half: 37, 39, 43, 45, 47, 51, 53, $7, $9, 63, 65, 69 "Now comparing the number 37 and the largest term in the first list 33637 Scanned with CamScanner 14 / Fundomentals A.Consise Textbook of Discrete Mathematics / 15 Thus, we cannot get 37 in the first half, So our search is directed Example: 15 tier Use the Bubble sort to put 3, 2,4, 1,5 into increasing order. Spliting second ist into two equal halves eae 37,3943, 45, 47,31 53,37, 59, 63,65, 69, ope Best 3 2 22 ‘The required number 37 isin he fist list So we neglect the second Goa list in this case Gael Spliting first list into two halves, we get eee at ‘Second Pass: wee terms. So : G22 7 31 By algorithm, Gey number of term (n):= + 1 ate Ga Now spiting the list finally into two sublists Bao 37,39 8 “Third Pass Spliting into two halves 201 | G yw 3 Search is restricted only in one term a, = 37 Thus, location i= 13. 1.2.4 Sorting aan Past the process of putting element of set into increasing order. 2 |(The bubble sort algorithm) 5 FOR i= lton-1 Ss FOR j:=lton-i ano IF a> a,, then interchange a, end a+ C canintertange, (pair conect oda, 1, d; dyin increasing ord Clovumbers are guaranted order) ‘The required final list in increasing order is Scanned with CamScanner 16 / Fundamentals Bi The insertion sort: PROCEDURE: Insertion sort ( FOR j:=2T0n i: Feal no, with n 2 2) BEGIN WHILE 90, tet FOR k=Otoj-i-t ay} ae sored Bramples 46 ‘Use the insertion sort to put 3,2 4,1 Sin increasing order. Solution ‘The given _ 3@4 since, 3>2 Step @us 4>2,403 ‘Step 3 2>1,3>1,4>1 sep: LEZ] @ sep: (ETE3 ‘This is the required final result. 5>1,9>2,5>3,5>4 .2.5 Greedy Algorithm (Greedy change making algorithm) PROCEDURE: Change 6x: values of denominations of coins where cy > €3 > ¢,: a positive integers) FOR i:ltor wi BEGH END The greedy algorithm produces change using the fewest coin possible. add a coin with value , to the change n: = n—c, A Consise Testbook of Discrete Mathematics / 17 Example 17, 3 ‘Change 67 cents by using fewest number of coins. Solution 6 so 2x 25-5 ~2 quarters 10 axiom 1 dime 5 es oS = I nickel 2 an <2 ~2 pennies Note: I quarter = 25paisa, 1 dime = 10 paisa I nickel = 5 paisa, 1 penny = 1 paisa 1.2.6 The Growth of Function 1.2.6.1 Big-0 notation Let f and g be two functions from the set of integers or the set of real umber tothe el numbers, Then. /() if big-O of g (2) and writen as {6 is (G0) and read as big-Ohof (nif there are constants ¢ and Asch that (9 < cl) whenever «> k Example: 18 Show that f(2)=20 + 2x + 1is O60) Solution When x> I thenx? >x=> 2¢>2¢ Also, 1 1. Then, [2)]= lage" + apnx" +--+ a+ ao) By using triangle inequality YOO S ae? + lag w+ +> Sf B+ lay be + (a+ la] ‘Thus, |f (x)| $ cx” whenever x > 1 Hence, f(x) is O (x"). Taking. ¢ [a+ ay-i|++ +++ Jal and k= 125 witnesses Example: 19 Show that 1 +243 +... + is O(n), where m is the integer. Solution Let f(m) = 14243 +44--.4 0. Then L424 4tecen Santen =n(l4l tect) =n.n(n-times) =? Thus, (1) =142+..-4nsg(n)=r? So, f(r) is O(g (0) ie, 1+243+-+-+misO (7) taking, c= 1 and k= 1 as witnesses. ‘A Consise Tertbook of Discrete Mathematics / 19 Example:20 ‘Show that nis (7?) Solution Let nbe a positive integer. Then n! = 1x2¥3x---% 0 Snxneneecen “0 Thus, nl so So, n! is O (0) aking ¢= k= 1 is as witnesses. Example: 21 Show that log nis O (1 og n). Solution nisit ‘Taking natural log on both sides, we get logn! slog" =nlogn ‘Thus, log n! Sm log So, log n! is O (nog n) taking, c= k= | as witnesses. Example: 22 Show that logan is O (7). Solution Let m be a positive integer. Then n <2", Taking logarithm with base 2, we have Toga < log:2" Togan ky and whenever x> hy. S(atadig@ I A ConsseTertbock of Dscrete Mathematics / 21 1.2.8 Big Omega notation Let fand g be two functions from the set of integers or the set of real number to the real numbers. Then we say that, f(x) is big omega of § (2) and written as 0 (g (x) if 3 two positive constants ¢ and & such that, I/(2)12 ¢ whenever > k Example: 23 Show that f(x) = Bx + 5x2 +3 is 0”) ie, f@Neelg Since, 8" +52 +3 > 2° = 8 +57 +3 is A(w), 1.2.9 Big Theta © notation Let fand g be two fictions from the set of integers or the set of real ‘number to the real numbers. Then we say that f(x) is big shera of g (x) and writen 35,/(0) 5 0 ) is OG ()) and fUrdis O&O 1.2.10 Complexity of algorithms 3s, 2072,2073 ode! Ques ‘An anal time required to solve a problem ofa particular size involves the time complexity of the algorithms, An analysis of the computer memory required to solve a problem of a particular size involves the space complenity ofthe algorithms. 1, Time complexity ‘The complexity of an algorithm can be expressed in terms of the number of operations used by the algorithm to solve the problem of a particular size. 2, Worst-case complexity By the worse-case performance of an algorithms, we mean the largest possible number of operation to solve a problem using the algorithm, Scanned with CamScanner 122 /Fundomentols Complexity of the sorting algorithm Example: 24 ‘What is the worst case complexity of bubble sort to the order list of elements using the bubble sort algorithm? [n= 1 += 2 ++ comparison} Solution ‘The largest possible number of comparison or operation used by the algorithm. no. of enaLtn-2eeotl ‘What is empty set? Show that the empty set isa subset of every set, ‘Show that if4 is subset of B, then the power set of 4 is subset of the 6) Does either for g have an inverse? Ifo, find his inverse 5. fis integer, then prove that n=[51+13 ] 6. List all the steps used to search for 6 in the sequence 1, 3,4, 5, 6, 8,9, using linear search b) binary search used by the insertion sort and bubble sort to short algorithm to make change using quarters, dimes, nickels and pennies for a) 85cents —b)._ 36 cents ©) 93 eents 9. Show that x’ is O (24) but that *is not O°). Give a big: O estimate for f (7) = 3m log(n!) + (r? + 3) log n, where m isa positive integer. ‘A Consse Textbook of Discrete Mathematics /23 2.0 Introduction ‘The Cartesian product between two sets the x-axis and Y is the set of points on the y= Peer Dirichlet sia Then, 4x7 isthe zy-plane I707AD.=1783 AD. Relat 8 exist Between objects of the between objects of two ver, a relation is any defined by an anal i theory by Cantor, the demands ofthe development of analysis by Weierstrass and others and the reformulation of geometry in terms of analysis eventually Scanned with CamScanner 124 / Relotions led to the more general modem concept of a function as a single-valued ‘mapping from one set to another. . 3 2.1 Relations be any two sets. Then any subset of cartesian product A Bis called a binary relation from A to B. Wocel gusto Example: 1 3.4} and B= (5,6) 6), B,5).G, 6), 4,5). (4, 6)} 6,025), 6). (3,5) Then, Ris relation from A to B. )€ Rithen we write a & b (we say that ais related to 6) and if (2, 6) € Rthen we write aXXb (we say that a is not related to b. 2.1.1 Function as relation Let 4 and B be two non empty sets. A function from A to B is a rule or ‘elation which associates every element of A to unique element of B. Mathematically, V a ¢ A, 3 unique b € B such that f(a) = b. Example:2 Let A= {1,2, 3) and B= {5, 6, 7}. 4 Here, each element of 4 has unique image in B, ic.,f(1) = $,f(2)= 6 and f (3)=7. So, is function from 4 to B. If we map ffrom A to B as follows A .Consise Textbook of Discrete Mothematics /25 Here, since 2 has no image and 1 has two image, f is not function. However, f isa relation from A to B, Note: Every function is a relation but every relation may not be function. 2.1.2 Relation ona set empty set then any subset of Cartesian product A * A is led a relation on 4, 3.1.4), 2,2). (2,4), 3,3). (4, 4D}, 2.2 Properties of relation 2.2.1 Reflexive ‘Acrelation on a set dis called reflexive if the ordered pair eRVaEA a) Let A=(1,2,3) and R= (( reflexive since x Rx Vx € A. b) The relation &= {(a, 6) « RY:@ 6) isreflexive relation since aSa for any a € R where Ris a set of real numbers, Scanned with CamScanner 2.2.2 Symmetric A relation is called symmetric if (a, b) € R= (b, 0) € R. Example:5 a) Let d= {x,y 2) and R= {(8y) 042), Gs 2h 2). Then, Ris Rix +y= 5} is symmetric relation symmetric ie, € R there is not 2.2.3 Anti-symmetric Arrelation on a set 4 is called antissymmetric if, whenever (a, ) € R and (b,) € R then, a= 6. 2.2.4 Transitive Arelation R on a set A is called transitive if (a, b) € R and (b,c) € R implies (a,c) € R 20721 Example: 6 2.2.5 Combining relations Let Ry and R, be two relation from A to B then Ry U A Consise Tetbook of Discrete Mathematics / 27 The relation R = ((1, 1), 2,2). )} can be combined to obtain. aa) to B and S be a relation from B to C. Then the comp denoted by SoR, isthe set consisting of all ordered pairs Scanned with CamScanner !_ 126 /Relotions Then, composite relation of R and Sis iby 2.3 Theorem ee ‘The relation Ron a set A is transitive iff R"& R for n= oR RGR M=1,2,3,...) > Ris transitive Proof: Let "CR, forn= 1,2, We have to show Ris transitive For this, let in particular R&R. Let (a, b) R and (b, c) © R. Then, by the definition of composite © RoR = R°. But RC R.So (a,c) © Rand hence R is (2072, Model Question) fe. Then, we show R&R for n= 1, 2,.. ‘We use mathematical induction on n to prove this assertion, ‘A Consise Testbook of iscrete Mathematics /29 For n~ 1, the theorem is obvious because R'c R Suppose, the theorem is true for n = k ie, Rc R, where kis a positive integer. Now we have to show that theorem is true for n = k + eR CR For, let (a, 6) € R'*'. By the definition of composite relation Re" = RoR Then, 3x € A such that (a,x) € R and (e, b) eR Since R' CR. So, (x,b) € R(x, bye R. Ris transitive and (a,x) € R,(x,6) € Rso Therefore, R*' c Rt This completes the proof, BER 2.4 rary relation and their applications 2.4.1 n-ary relation + Ay be sets then ary sub-set of Ay « dy x °° > dy is called an n-ary relation on these 2.4.2 Application Ins are used to represent computer databases. These representations help us answer queries about the information stored in databases. The information ike as employces of a company cam 30,000 Rs per month, student of university more are in mathematics, flight lands airport between 8 pm to 9 pm etc. 2.5 Representating relation 2.5.1 Using matrices Let & be a relation from A = ( +a} 10 B — then the relation R can be representating by the matrix Mg = [m, 1 if @aeR where.=1 9 it (an ayeR Scanned with CamScanner 130 / Relations Leta=( a relation from A to B. Represent the above rel Solution ‘The matrix representation ofthis relation R is given by Example: 11 1 My= 2 I ab 10 o1 el Let A = {ay, dy, 03}, B= (by bs, bs, Bay bs}, which ordered pairs are in the ‘elation R represented by the matrix 0 lo 15) such that my 1 for € R. So, cequired ordered pairs in ‘A Consise Textbook of Discrete Mathematics / 31 } and B = (1,2). Let R be a relation from A to B containing Band a> b, What is the matrix representation of R if, 1 1yay* 2,0, = 3 and b= 1, 6)=27 saedandb € Banda>b) G2) 1poo 3Lid \Note: A relation Rona setA = (ay dy... ay) i | reflexive i my = I for alt i= sprimeric Ma = (My). 4 Example: 13 110 Let R be a relation on a set represented by, ve! 1 0 | is Rreflexive? ot diagram or (directed graph) ‘Another important way of “directed graph (digraph), lement of a set is, represented by nodes ind each ordered pair is represented by using are (edge) with its direction indicated by an arrow. using a figure is Scanned with CamScanner sot Ate A.Consise Textbook of Discrete Mathematics / 33 Example: 14 List the order pairs in the represented by directed graph. 2.6 Closure of relation a . a 2.6.1 Closure 1. Reflexive closure 7 The reflexive closure ofa binary relation R on a set Ais the smallest ; e reflexive relation on 4 that contain Example: 17 ay Let A = {1, 2, 3} and R= reflexive closure of Ris S= b) closure of Ris equa ©) What isthe reflexive closute of relation R defined by R= (a,b): a 1, Then the relation 2 = b (mod m)} is an equivalence relation on Z. asamod(m)V¥aeZ Since, mla—a = 0. The relation is reflexive, Let a = b (mod m). Then by definition, m\(a—b) = m|-(a-2) >m|(b-a) So, b= a (mod m) ‘Thus, the relation is symmetric, ii) Let a= 8 (mod m) and b = ¢ (mod m), Then, m\(a~8)and m ie, mia-o) $0, a= (mod m). ‘Thus, the relation R is wansitive, ‘Hence, 8 is an equivalence relation on Z. 2.6.4 Equivalence Class Let R be an equivalence relation on a set A. The set of all elements that are related to an element a of 4 is called the equivalence class of 4. The equivalence class of a wit is denoted by [2]. we can delete the ‘equivalence class of the element a is [a]e= (x etbook of Discrete Mathematics / 39 Example: 24 0, 1,2 and 3 on the relation Wehave, Pigeonhole “The pigeonhole principle states that “if m items are put into m contair “ith n> m, then at least one container must contain more than one i Lemma Let be a set with n elements, and let R be a relation on A. If there is 1 path of length at least one in R from a to 6, then there is such a path ‘with length not exceeding n. Moreover, when a # b, if there is path of length at least one in R from a to b, then there is such a path with length not exceeding n ~ 1. Proof ‘Suppose there is a path from a to b in R. Let m be the length of the shortest such path. Suppose that Xo Xi, #2,» Sts Ze Where X9 = a and xq = bis such a path, Scanned with CamScanner 40 /felorons Suppose a = b and suppose m > n, so that m 2 n+ 1. By the pigeon hole principle, there are n vertices in A, among the m vertices Xo, x1, 1 Teast two are equal Suppose x, x, where x, and x, are two distinct vertices of ‘ «%ei}. Then the path contains a cite This circuit can be deleted from the path from a to bin order to make path of shortest Iength namely, 335. 2 fiom a ‘to b. Hence the path of shortest length must have length less than or equal to In the case when a # b, we can prove the above statement by the similar manner desribed above. 2.7 Partial Ordering A relation R on a set Sis called partial ordering os partial order if it is reflexive, antisymmetric and transitive, (BSc, 2073 Mode! Question, Partial ordered set A set 5 together with a partial ordering R is called the partially ordered set ot poset and itis denoted by (S, R). The members of $ are called elements of the poset. Example: 25, ‘Show that “greater than or equal” relation (2) is a partial ordering on the set of integers. ‘Solution a) Reflexive Since a> a. So'>'is reflexive, b) Antisymmetric Ifa>b and b 2a then.a~ 6 So'> is antisymmetric. ©) Transitive Ifa>bandb>cthena>c So is transitive Hence, "greater than or equal” relation (2) is partial order relation. A Consse Tertbook of Oscrete Mathematics /41 Example: 26 Let Rbe the relation onthe set of people such that x Ry if andy are people ler than y- Show that R is antisymmete, tranaive but not [Mode Querion Ifa person x is older than a person p, then y is not older than x ‘That is rRy: then yx. So, Ris antisymmetric. b) Transitive fa person x is older than a person y and y is older than person =. n clearly x is older than z. That is xRy and ye, then xR=. So. R ransitive. ©) Reflexive Since no person is older than himself or herself That is x Rx; for all people x. So, Ris not reflexive. Hence, R is not a partial ordering, «partial ordering on 2” Reflexive da ¥ a € 2°, soitis reflexive. b) Antisymmen Let a[b and dja then a=, s ©) Transitive Let ab and bj, then oe, soit is transitive Hence, (Z|) isa partial ordered set. Example: 28 Let S be any set then the relation‘ isa partial ordering on p(S) (i.e. power set the set of all subset of ), Solution a) Reflexive Since, 4 cA, V A € p(S), 30s reflexive +B) Antisymmetric Let dc Band BA then, A= B,s0 itis antisymmetric. antisymmetric, Scanned with CamScanner 142 [Relations ©) Transitive Let dc B and Bc Cthen A c C30 itis transitive. Hence, (p(S), 5) isa partial ordering set. Comparable elements Let (S, <) be a poset. Two elements x and y of poset (S, <) are comparable if either x < y ory < x for x,y € S. Incomparable elements ‘The elements x and y of poset (S, <) are incomparable if nether x = y nory a - Scanned with CamScanner 84 /Groph 3.2.4 Mixed graph A graph with both directed and undirected edges is called a mixeg ‘graph. A mixed graph may also contains loops. A d P 3.2.5 Graph Terminology Multiple Edges: Loops Te es ‘Allowed | Allowed Single ph lniieced [No No [Mult-graph | Undirected Yes No [Pseudographs Undirected Yes Yes simple deesedgagh —[Dieded Ne No Dieses Mal gph [Diese Ys No Dieced Peuiopaph —[Dvesed es Ye Mice raph iseced@| Yes Yer lundirected 3.3 Degree of Vertex ‘The degree ofa vertex in an undirected graph isthe number of edges incident with it. The degree of vertex u is denoted by deg (u), WoteiA loop at a veriéx conmibutes twice tte degree of that erie ‘The degree of vertex a,b,c and dare as follows deg (a) = 4, deg (b)= 5, deg ()= 5 deg (d)= 8 A Consse Textbook of Dscrete Mathematics / 55 3,3.1 Isolated vertex ‘The vertex din above graph isan isolated vertex. 3.3.2 Pendant vertex A vertex is pendant if and only if it has degree one. A pendant vertex is adjacent to enactly one other vertex. e 4 In the above graph vertex a and dare pendant LetG=(V, E) be an undirected graph with e edges. Then 2e= = y- deg (u) Proof Since each edge contributes a degree 2. So the sum of the degrees of all the vertices in graph G is twice the number of edges in G. z uel \Note: From Handshaking theorem, we can conclude that sum of degree of vertices is always even. 2e= > degiud Scanned with CamScanner => 56 / Groph Example: 1 Verify Handshaking theorem by giving suitable example Solution From the above graph, we have total numberof edges (e) = 8 Also, deg (0) = 3, deg (8) =3 deg (0) = 8, deg (d) = 5 Here, : A we 748 u)= deg (a) + deg (b)+ deg () + deg (d) or ey deg (nya 3 434545 or, veraetor 16 ver 4e(0)=2 Bangle? Cana simple raph eis with 9 verze each of degee 3? — 343+ | we Ey este) eet =27 ‘The sum of degree of vertices cannot be odd « Hence the simple gra With 9 vertices each of degree 3 does not exists | A Conse Tertbaok of Oscrete Mathematics /5T Example: 3 How many edges are there ina graph with 20 vences each of degree 4? From Hand = theorem, we have de nye cee “ver eto weds 4 20 tines 22004 or 2e =80 e=40 Hence, there are 40 edges. Example: 4 Does there exists a simple graph with seven vertices having degree 5,6, 6)? Suppose there exist a graph with seven vertices satsfing the given properties. Since two vertices have degree 6, each of these two vertices is adjacent with very other vertex. Hence the degree of each vertex is at lest 2, so that graph has no venex of degree I which is a contradiction. Hence there does not exist a simple graph with the given properties ‘An undirected graph has an even number of vertices of odd degree. |&se, 2072], Proof Let F be the set of vertices of even degree and ¥; be the set of vertices of odd degree in an undirected graph G. Then, by oS theorem, we have 2e deg(u) ater C7 a ee F dest) ye 7,28 Scanned with CamScanner Since deg (u) is even for u ¢ Vp the first term on the right hand side of equation (i) is even. Also, the sum of the two terms on the righ, even because the left hand side is even right hand side must be even. AS al the tems of, © yeu are od So tere must be an even numberof = wel Thas, there are an even number of vertices of odd degree. such terms to get the quantity deg (u) even. 3.3.3 In-degree of vertex ‘The in-degree of vertex (9) in a ditected graph G is the number of ‘edges with v as their terminal vertex. The in-degree of vertex v is denoted by deg (v). ‘ @ L-] ‘The in-degree of vertex a,b, c,d are as follows: deg (a)=2 deg (b)=0 deg’ (e)=0 deg (d)=3 3.3.4 Out-degree of Vertex ‘The outegree of vertex edges with » as their denoted by deg” (»). in a directed graph G is the number of vertex. The out-degree of vertex ¥ is 5 d “ é ‘The outdegree of vertex ab, dare as follows: 7. AConsise Textbook of Discrete Mathematics /59 deg’ (a)= 1 deg’ (6)= 1 deg’ (c)=3 deg" (@)=3 INote: A loop at a vertex contributes 1 10 both in-degree and out- ‘degree. Example: 5 Calculate the in-degree and out-degree ofa vertex a,b and — 6 Solution The in-degree of vertex a,b, care as follows: deg (a)=1 deg (b)=2 ‘The outdegree of vertex a, b,c area follows: LetG= (1 £) bea graph with directed edges. Then = = (u)= we VEE = where 2] denotes the total number of edges. Proof When the in-deges ofthe vertices are summed, each are is counted exactly once. z wer © dese) =16 wel deg” (x) = no. of ar =[E] Scanned with CamScanner (60 / Graph When the out-degree of the vertices are summed, each arc is countey exactly once Ede (i) no of =18 we! Thus, z pee ys 2 y eee" (u)=18) Enanpl6 Verify above theorem by giving suitable example Soltion Now, cere | wee v ABW) = degi(a) + deg'(b) + deg (e) + deg’ (ah =24040+3 -s Also, ‘The out-degree of vertex a,b, c, dare as follows: A Consise Textbook of Discrete Mathematics / 64 = 2 yey desu keg (a) + deg) + de’ (e) + deg'(d) =1424240 “3 Again, otal number of divested edges fe] = 5 (2, (b.), (bd. (ea, (6,4) Thus, ‘Sum of in-degree of each vert ‘Total number of directed edges. ie, 2) deg) _ = Sum of out-degree of each vertex = 3.4 Complete Graphs ‘one edge between each pair ‘graph. The complete graph ted by Ky. The complete graphs K. for m= 1, 2,3, wi}. The eyele| and C, are shown below. Scanned with CamScanner C G Let C,;m23 bea cycle. A simple graph is said to be wheel if we add ‘anew vertex to the cycle C,, and connect this new vertex to each ofthe | ners in Cy by new edge, The wheels Ws, We, Wand W, ae show | elow: 3.6 Wheels Ws We A Consise Tertbook of Discrete Mathematics /63 3.7 Bipartite Graphs ase, 2073) Let G bea simple graph and be its 7 vertex set. simple graph G is called bipartite if the venex set can be arttioned ino two disjoint sets Vand such that every aie ige in the vertex in Vy and a vertex in Vy Beth Gcomect sce ‘The graph above is bipartite graph because its vertex set can be Partitioned into two disjoint sets ¥,= (a,c, e} and Vs ~ (8, ‘every edge of above graph connects a vertex in V; and verte AA simple graph is bipartite if and only i tis possible to assign one of two different colours to each vertex ofthe graph so that no two adjacent vertices are assigned the same colour. (as, 272.2073) be a bipartite graph. Then =, U Vs where insets and every edge E connects a vertex in V f we assign one colour to each vertex in F and a second colour to each vertex in 1, then no two adjacent vertex are assigned the same colour. Conversely Suppose that it is possible to assign only two colours tothe vertices of that no two adjacent vertices are assigned the same set of vertices assigned the other colour. Then ¥; and and V= ¥, UIs Also, every edge connects a vertex in in Vz because no two adjacent vertices are either both in ¥, or both in Va, Hence, G is bipartite. Scanned with CamScanner — 64 /Graph 3.7.1 Complete Bipartite Graphs it V can be parti Let G =(V,E)be simple graph. Let the vertex set into two disjoint subsets Vy and V3 ; where Vi has m venice has n vertices such that m < n. Then the graph G is said to be compley. bipartite graph if each vertex of Vis connected to each vertex of ‘The complete bipartite graph is denoted by Km »- The graph Khas ann edges. The complete bipartite graph K; are shown below 3.8 Subgraph LetG = (¥, £) bea graph. A graph H = of if i. Allthe vertices of Hare in G. Allthe edges of H are in G and Each edge of H has the same end points in H as in G. a b Oh LI CI e d del a G a Ay Here, #1, is subgraph of G but is said to be subgraph not subgraph of G. ‘Conse Textbook of Discrete Mathematics / 65 3.8.1 Union of simple graph LetG= be two simple graphs. Then the union of two simple graphs G and 11s te simple graph with verex set Vu W and edge set EF. The union of G and His denoted by GU H. 4 4 < x Lt vs a - é ui é iS G ” GuH. 3.9 Representation of graph 3.9.1 Adjacent list In this method of representation of graph, all vertices are listed with their neighbor (adjacent vertices) Example: 7 Represent an undirected graph shown in figure below by an adjacent list e J a é a b Solution ‘Adjacency list for a simple graph Vertex | Adjacent Vertex | Vertex | Adjacent Vertex a |bod ¢ af b lacd ad jaboe Pe e ld f_le | Scanned with CamScanner 66 / Gp Example: 4 Represent the directed graph shown in figure below by listing all the vertices that are the terminal vertices of edges starting at each vertex of the graph, la 5 e Solution ‘An adjacency list for a directed graph Initial Vertex | Terminal Vertex a abe o bed ¢ 6 d ab e 6 3.9.2 Adjacency Matrices for simple graph Let G=(¥, £) bea simple graph with n vertices. Let the vert are ordered as v 1% Then the adjacency matrix A o Tespect to this ordering ofthe vertices is A = [a], where { 1 is an edge of G 2 } otherwise ‘The adjacency matrix A of G with n vertices is always m * m square ‘matrix ‘A Consise Tertbook of Discrete Mathematics / 67 Example: 9 Use an adjacency matrix to represent the graph shown below. p a 6 Solution We order the vertices as a , c,d ‘The matrix representing this raph is abed Example: 10 Draw a graph with the adjacency matrix with respect tothe ordering ofthe vertices a,b Solution a 6 Scanned with CamScanner ey 68 / Groph 3.9.3 Adjacency Matrices for multi graph Let G = (VB) be a multi graph with n vertices. Let the vertices of G are ordered a5, Then the adjacency matrix A of G, wig, respect to this ordering ofthe vertices is A = [ay] where ‘number of edges from ito - 0; otherwise Example: 11 Use an adjacency matrix to represent the pseudograph shown in figure below, e a a 6 Solution The adjacency matrix using the ordering of vertices a,b,c, dis a bed apo2rt b) 2012 ce] 1103 ali23i Example: 12 Find the adjacency matrix 4(G) = (a,)q 9 of the multigraph G in figure. ¥, % vy % | | | A Consse Tertbook of Discrete Mathematics /69 Since G has four vertices, 4(G) will be a 4 » 4 matrix. Set a = where 7 is the number of edges between 1, and, and set a, = 0 otherwise. This gives the following matrix. o 1 2 3 a 3 a) 02 23 3.9.4 Incidence Matrices tas, 2970) ta be n vertices where {! when edge eis incident with i ae O,othenwise Example: 13 Represent the graph shown below with an incidence matrix, Solution “The incidence matrix ofthe given graph is 2 6 eo % 0 1 1 ° 1 1 0 0 0 0 Scanned with CamScanner y 10 / Graph Example: 14 7 Find the incidence matrix Af(G) = (m,) ofthe graph G in given figure, e | ep ——*, eo + Solution Since has four verces and six edges, so M(G) will be a 4 x tmatrix Set m, = 1 if vertex v belongs tothe edge my = 0 if verexy, oes not belong to thee and set m, = 2 ther is a loop ¢, on the verter aphid ml to Mae wl OD wlboo This given the following ee 00 oo i iy Note: ‘We have labeled the rows and column by the corresponding edges and ae 8 0 1 1 0 vertices for easier reading through this is not necessary. 3.10 Isomorphism of Graphs Let Gy = (V1 Ei) and Gz (Vs, E2)_be two simple graphs. Then the graphs G, and G; are isomorphic if le graphs must have the same number of vertices because there is a one-to-one correspondence between the sets 0 Vertis ofthe graphs. Isomorphie simple graph also must same number of edges. The degree of verices in isomorphi raph must be the same, A Comsise ebook of Oxcrete Mathematics /71 1t is not always easy to determine whether or not two graph are isomorphic. But in genera following condition are required to be isomorphic. a) Same number of ). Same number of c) Same degree seque any of above ‘isomorphic. However these condition along are not sufficient for isomorphism, Example: 15 Show thatthe graphs G and H shown below are isomorphic. 4 4 LL] My G ny » y % H Solution ‘The function defined by = vy and (u) * 93 is @ one-to-one and onto cency preserved by this correspondence. xin G are uy and uj and uy, 1 and uy uy and Ma Now, Scanned with CamScanner Hence, H and G are isomorphic. Example: 16 ‘Show thatthe graph displayed below are not isomorphic. e XxX | I ¢ d i h G u" Solution The graph G has only four vertices whereas the graph H has five Vertices. Henee, the one-to-one correspondence between the vertex doesnot exist. Thus G and H are not isomorphic. Example: 17 ‘Are the following graphs isomorphic? a f A OO d eT 6 J 4 book of Oncrte Mothemetes/ 7 ution Fhe rh G and 1 bth bs ve Kes edges but H has only six edges lowever, G has seven that G and H are not isomorphic. empl: 18 “Are the following grophs isomorphic? x L a ¢ 5 : ¢ a ‘ ‘ 6 " Solut Both G and H has five vertices and si ed vertes of one. It Example: 19 ‘Are the following graphs isomorphic? ws that G and H are not isomorphic, correspondence. Hence G and H are isomor Scanned with CamScanner ey 74 Groph ‘A Consise Textbook of Discrete Mathematics /75 22 Example:20 “peample: 22 ‘Arete following graphs isomorphic? pete following eaphs isomorphic? e ” ; eI“ N. ‘Tas copto-ane comespndene between the vetoes is shown belo > < vertices and edges. They ywing graphs isomorphic? ik” 6 H c l a ote] 4 % abdef c Solution ‘2 and '3' are the vertices of graph G having degree "2. Thus 2 and 3 ‘must corresponds tices 'b" and’ in H. However 2’ and'3' are s adjacent in'G' but ‘eae not adjacent in 'H', So, graphs H and ‘The vertex sequence a, 5, dis nota path because {b, d} is not an edge G are not isomorphic. in the graph above. Scanned with CamScanner a ? 16 / Graph However a, b ¢,fis path of length 3 becausse (a, are all edges (ne) LetG bea graph with adjacency matin A with respect othe ordering 1.2, “ae 7 edges and lowed). The number of different paths of length r positive integer, equals the (i entry of 4” Proof We prove the theorem b be an edge of length 1 from is tue from r= 1 the theorem is true for Since, A’ =A""1A E ant ,(i,j)= is obtained by summing gives the number of rem is true forall k= r 2)= Number of path of length 1 form )= Number of path of length 2 form Example: 23 How many paths of length four are there from a to d in the simple graph G shown below? i: a 6 ‘The graph G | Ss A Conse Tertbook of Discrete Mathematics / 77 Solution ‘The adjacency matrix of G (ordering the venices as a, b,c, dys o 11 o | oot fe oo1 iio 2,c,0, bd) ht paths from a tod. 3.11.1 Circuit ‘The path is said to be circu if't begins and ends atthe same vertex. a ° a e 3.11.2 Simple path “The path is suid to be a simple path if it does not contains the same edge more than once. Scanned with CamScanner b,c, dis simple path of length 4 because (a,c), ‘d} are all edges and this path does not contains the to be simple cireuit if it does not contain the same ‘edge more than once. 4 be DPQ Ra d e z cis a simple circuit of length 5 because {a, e}, + ca} are all edges the path begins and ends at ‘and doesnot contains the same edge twice. 3.11.4 Connected graph ‘An undirected graph is sid tobe connected if there is path between ‘very pai of distinet vertices in the graph a, 2 f a : e G The graph shown above is connected because there is a path between every pair of distinct vertices in the graph A Conse Tertbcok of Oscrete Mathematics / 79 ‘The graph (H) shown above is not connected (or disconnected) because there is nota path between the verices. ie, Thre isnot path between ato b and ctod. 3.115 Cut vertices (or cut points or articulation points) Let G be a connected graph. A vertex v in Gis called a cut vertices if the removable of the vertex v and edges incident with it disconnects the graph. In the above graph G, the vertex dis a cut vertex 3.11.6 Cut-set cted graph. A cul-set is set of edges whose removal . Provided removal of no proper subset ofthese edges. Scanned with CamScanner > 180 / Graph 3.11.7 Bridge (or cut edge) ‘An edge e is called bridge of G ifthe removal ofthe edge e from hg raph G disconnects the graph. Inthe above graph the edge {c,e) is the bridge of the graph G, 3.11.8 Strongly connected A directed graph is strongly connected if there is a path from a to b and bto.a whenever a and 6 are vertices in the graph, Strongly connected graph G. 3.11.9 Underlying undirected grapiy The undirected graph that resus from ignoring di undirected graph. A graph 4 Directed graph Underlying undirected graph 3.11.10 Weakly connected A directed graph is weakly connected if there isa path between every ‘wo distint vertices in the underlying undirected graph. Any strong ‘connected directed graph is also weakly connected A Conse Textbook of Ducrete Mathematics /81 The above graph G is not strongly connected because thee is no directed path from ato b. However, the graph G is weakly connected because there isa path between any two veries in the unde undirected graph of G. z a ce ‘There is a simple path berween every par of different vertices ofa connected undirected graph. Proof Let G be a connected undirected graph. Let w and » vertices in G. Since G is connected, so, there is at least one path between u and v Let the vertex sequence ofthe path from u to Be xy, 2, --» Ee Which is of last length. Then this path must be a simp path, Suppose the path from u tow with venex sequence 35, is not simple ‘Then x, = x, for some j and with 0 < i 3, then, es 36. Proof Let r, @ and » be the number of regions, edges and vertices respectively in a planar representation of G. By Euler's formula, ervtr-2....@) Now, the sum of the degrees of the regions equals 2e. But eack region has degree 3 or more, hence ACen retoo of crete Methemancs 89 Jon ce 2e = all region 8 (R) on, 26234 2 or rsze ing the value ofr is (), we get fG= (1, £) isa connected planar simple graph then G has a venen of degree not exceeding five Proof Let g.and.y be the numer of reponse an series ly. Suppose deg (1) > 6 for each vertex u of G. By Handshaking theorem, we have or e23v>3v-6 or, € > 3~6 which is not true. ‘Thus, some vertex of G has degree 5 or less. Example: 26 A connected planar simple graph has 20 vertices, each of degreed. Into how ‘many regions does a representation ofthis planar graph splits the plane. Solution ‘The graph has 20 vertices, each of degree 4. v=20 By Handshaking theorem, we have e=40 Scanned with CamScanner 90/Groph By Eulers formula, we have reeny42 1 = 40-20+2 “2 Hence, connected planar simple graph splits the plane into 22 regions 3.14 Weighted graph the murober is asigned to each edge of the graph, the graph is sig to be weighted graphs. 2 7 7 The graph shown above is weighted graph The length of a path in a weighted graph is the sum of the weights of the edges ofthis path. The path of least length between two. given vertex is called shortest path. The number may represent distance Cost, time or some other quantity. There are several algorithms that find the shortest path between two ve weighted graph. One of the algorithm discovered by E.W. Di discussed here. 3.14.1 Dijkstra’s Algorithm PROCEDURE Dijkstra (G : weighted connected simple graph, with all weights positive) AG has vertices a= vy, ¥), WHILE: «S A Comsse Textbook of Dserete Mathemavcs/91 BEGIN { = a vertex not inS with £(u) minimal S:- Su tut FOR all vertices vnot in S IF L(u) + w(u. ¥) <8) THEN Li END { L42)= length ofa shortest path fom ato 43,142 Steps to find the shortest path by using algorithm. ‘Step 1: Label the initial vertex ofthe praph with weight zero Step 2: Calculate the weights of all vertices adjacent to the instal vertex corresponding to the weight of the edges incident on the initial verte. Step 3 : Label these vertices with smatiest possible value of their weights Step 4 : Calculate the weights ofall those vertices which are adjacent to the vertices with minimum weighs determined instep 3. Step 5 : Label these vertices Step 6 : Continue this process unt all the vertices of weighted graph are labeled. Step 7 : Trace the path of cumulative minimum vertex to desire vertex. Example: 27 ; Compute the shortest path between source o and destination = using Dijkstra minimum weight, ight from the in 6 3 d : i c iT e Solution Let abe the selected vertex Scanned with CamScanner 92 /Groph Ne Let € V L(x) denotes the shortest distance and P (x) denotes thy Set pth Loe P(b)= {a,b} L(=2 P(C)= {a,c} L@-e P=o L@=e Ple=% L@=e P= Since L (c) is minimum. So next selected vertex isc. V= (b.dve,2} and S= (a, 0) Now, £(b) = min {L (b)L(C) + w (C,B)) = min {4,241} = min {4,3} =3 L (d= min {L (A), L (0) + we.) = min {20,2 +8) = min {e2, 10) =10 L(@)= min {L (e), L (0) + w(c.e)} = min {20,2 + 10} = min {s0, 12) =12 L (2) = min{L (2), L(e) + w(e.2)) =min (20,2 +20} min (20, 0} P(p)={a,c.b} P(d= {acd} P= {a,cveb PR=o A Comite Textbook of oscrete Methemanes/93 (8) is minimum, so nen selected vee is . V={de,2) andS= {a,c} Ud) = min (Ld, £ (6) + (6,49) ‘min( 10,3 + 5) ‘min(10,8) =8 | Ue) = min {Le L (6) + w(b,e)) = min (10,3 + 20} = min (12,20) =12 min (L(2), (6) + 0 (0,2) min {2,3 +20} min (:0, 2) 2) P(d={a,c,b,d) P()=lacbe} Pe-% Since L(d) is minimum. So next selected vertex isd. 2 V={ezhand $= (a,b,¢,d) Now Ue) = min{ Le), Ld) + w (d,e)} = min} 12, 8 +2} = min 12, 10) =10 Ue) = min{L(2),L (d) + w (d,2)} = min{ca, 8 + 6) = minco, 14} =14 PC (aebode) PO)= aed, ‘Scanned with CamScanner 94 /Gr0ph Since L (¢) is minimum. So next selected vertex ise v s}and S= (0,b,¢, de) Now LG) = min(L), L (@) + w (e,2)) 10+3) Now next selected vertex is 2, Hence stop. Solution Let Shortest distance between @ and z ‘Shortest path between aan zis 2,8, e,2- Example: 28 Compute the shortest distance between source a and destination = using Dijkstra’ algorithm for following weighted graph, abe the selected vertex listance and P(x) denotes the shortest P(b) = {a, bb ‘A Consise Textbook of Oscrete Mathematics /95 (6) + m(b,0)) +2) = min{4, 3} cn] Ld) = min {L(4), Lb) + w(b,)) = min (22,147) = min (2, 8) -8 L{e) = min {L(e), L(6) + (6, €)) = min (2,1 +5) = min (00, 6) =6 Lz) = min | LE), L6) + Wb, min {2,1 +a} =min (2.2) ¥ = {d,e,2) and S= (a, ot L(A), Le) + wle a} Ue) = min (Le), Le) + w{e,e)) 6,341) = min {6,4} -4 Scanned with CamScanner 96 / Graph U2) ~ min {L(@), Le) + (64 2)) = min («2,3 +00) = min {v0 0) Ud) = min (L(A), Le) + w(e, d)} = min (8,4 +3) = min {8,7} “7 U2) = min {L2), Le) + w(e,2)) = min {0,4 +6) = min (co, 10) =10 2) inimum. So, next selected vertex isd. V= (2) and S= (a,b,c, dye} Now, Us)= min (L(2), Ud) + w(d 2) PO) = tabeve,d.2} ‘Now next selected veriex is z, hence stop Shortest distance between a andz = 9 ‘A Consise Textbook of Discrete Mathematics /97 example: 29 mine the shortest path fiom the vertex ato ¢ ee by using Dilksal algorithm, ae ion In the graph of given figure, we have to find the shortest path from vertex 10 z, we label the vertex a with weight zero, Then we ealoulate the weight of ll he adjacent vertices tothe inal verex @ and label them with minimum weight. Continuing this process until Or @ “The shortest path om a0 is a and its lengths 25. Example: 30 : the vertex ato Applying Dijkstra's algorithm to find the shortest path fom ach ofthe other vertices ofthe following weighted graph. Scanned with CamScanner 98 /Groph Solution ‘Since we have to find the shortest path from the vertex a to each of the other vertices, then we assign weight 0 to vertex a and © to al] remaining vertices. vertex a & a € ‘Diabet 0 2 © 0 2 ‘Now, the vertices adjacent to a are 6 and ¢, we calculate weights of 6 ith minimum weight : a € lace previous weight a e 7 6 so we select it d and replace its vertex. @) (e) label 4 6 2) The shortest path from ato b) The shortest path from a to ©) The shortest path fom a to 4). The shortest path from ato Remarks A Conse Tertco of Oserete Methemates/99 Exercise 3 Determine which of the graph shown below graph, pseudosraph, simple directed graph directed pseudograph, a) b) Ke Bh Yo& Draw the graphs ofthe chemical molecules of is Simple graph, mul directed multi graph, 4 9 a) Methane ‘b) Ethane 6) Propane d) Butane 3. How many vertices and edges do the following gaps hve? a) K& b ©) @) Kye Scanned with CamScanner teMathemovcs/101 in-degree and out-degree of the vertices a, b,c, d and ae 6. Represent the given graph using an adjacency matces b qj i c 7 Represent the given graph using an incidence matrices. 6. “Represent an undizected praph shown in figure below by an adjacen fist, ag, an 7. Find the adjacency matrix for the graph G shown below, b a id f e 8. Represent the given graph with the adjacency matrix. (ase 207 Draw a graph withthe given incidence matrix. 20: | od eo Scanned with CamScanner 102 / Grooh A Conse Tentbok ef crete Mathematics / 103 14, Are the simple graphs with the following adjacency matrices ‘Are the following graphs isomorphicr isomorphic. a oO 1yor 1 ooifli oo é 11 o0jlioo g Ss 2 15. What do the indegree and outdegree of a vertex in a directed graph ‘modeling a round-robin tournament represent? 16. Are the graphs shown below are bipartite? di c 4 5 i) ii) - G H 5 “20, How many paths of length tee are there fi a q a a apderdate om a 0 ¢ inthe simple i c ad a @ dj 17, Are the following graphs isomorphic? EI |} 18. Are the following graphs isomorphic? Pe 7 . 23. Show that the graph displayed below has an Euler circuit. a b : s e " * d c G a G Scanned with CamScanner 4 aavy Ydes3 sim sop saoruda AUeWL Sopiatp ydesd sty Jo uouejuasasdas eid seuejd paysouuos v yey asoddng oy ‘SuoIBa1 QZ oyu! ouejd up seumd @ J] “sa8pa og sey ydi "87 [euoz 28a) going Suymoyjoy ouput uMoYs ydexs Pasion up Ut Z 2p uDdMjaq wed ysayoys & Jo WBual ay rey — “zz “Ydesd parysiom Sumoyiog 10y unos s, Pue D somos uaamjaq s0uE)si i) a easHfiq| Sutsn 7 uoueunsap P SONOS ayy ayndwioy —-¢z DP & (a a « “Mojaq paxeidsip yde3 Sutmoyjoy ayy soy Mo109Ip saaing| Aja, “’z 4yda1 / voR Scanned with CamScanner

You might also like