mca 202: discrete mathematics under construction instructor neelima gupta [email protected]

25
MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta [email protected]

Upload: ashton-smuin

Post on 14-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

MCA 202: Discrete Mathematicsunder construction

InstructorNeelima Gupta

[email protected]

Page 2: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Table of Contents

• Eulerain Path and Circuits• Hamiltonian Path and Circuits• Planar Graphs

Page 3: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Eulerian Paths & Circuits

Given an undirected graph G, a path is called an eulerian path if it spans all the vertices and scan each edge exactly once.

Also, in an undirected graph G, a circuit is called an eulerian circuit if it spans all the vertices and scan each edge exactly once.

Page 4: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Examples:

Page 5: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Theorem: An undirected graph possesses an eulerian

path iff all the vertices are of even degree except possibly for two vertices.

Claim: A graph has an euler path (or circuit) if the number of odd degree vertices in the graph is two (or zero).

Page 6: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Proving by Induction:If euler path have only 1 edge, |EP| = 1Similarly, claim is true for (e - 1) edges,|EP| = e – 1Now, consider a path:

By removing an edge vp-vq , the claim holds for v1 to vq path.

V1 V2 V3 V4 V5 . . . . . . . . . Vq Vp

Page 7: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Now adding that edge vp to the initial path, the claim still follows as v1 and vp are vertices with odd degrees.

Hence, proved.

Page 8: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Shammi-37 and Shivangi-38 (MCA 202)

Converse: If the number of odd degree vertices in the graph is two (or zero), the graph has an euler path (or circuit).

Start with an odd degree vertex, and we will end with another odd vertex.Hence, it has an euler path.

V1

V3V2

V8

V4

V5

V6

V7

Vertices:DegreesV1 : 1, OddV2 : 2, EvenV3 : 2, EvenV4 : 2, EvenV5 : 2, EvenV6 : 2, Even

V7 : 2, Even

V4 : 3, OddV4 : 4, Even

V8 : 2, EvenV2 : 3, Odd

Page 9: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Hamiltonian Path/ Circuit

• It is a path/circuit that passes through each of the vertices in graph exactly once.

• This is more constraint compare to Euler path.

• There is no polynomial time solution for Hamiltonian path.

Page 10: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Hamiltonian path

Page 11: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Theorem:

If in a Graph G, the sum of the degrees for each pair of vertices in G is n-1 or larger, where n is the number of vertices in the graph, then there exists a Hamiltonian path in G.

Page 12: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

v1 v3v2 vj-1 v j v p

Figures for Proof :

Page 13: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

v1 vk-1v2 vj-1 v j v pv k

v x

(a)

Page 14: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

v1 vk-1v2 vj-1 v j v pv k

v x

(b)

Page 15: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Planar Graph

Page 16: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

PLANAR GRAPHS

•A graph is said to be planar graph if it can be drawn on a 2-D

plane in such a way that no edges cross one other

Example:- A

D C

B

Page 17: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

In a planar graph, edge is only a concept of connectivity.

Edge from vertex A to vertex C can also be drawn as follow:-

A A B

D CDC

B

Page 18: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Not A Planar Graph

A

D

C

B

E D E

A C

B

There is no other way to connect edge AD and EC

Page 19: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Region :

Edges belonging to :Region 1 – AC,CB,ABRegion 2 – CB,CD,ABRegion 3 – AB,BD,DARegion 4 – CD,DA,AC

A B

CD

34

1

2

Page 20: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Theorem:

For any connected planar graph,

v - e + r = 2

where v , e and r are the number of vertices, edges,

and regions of the graph, respectively

Page 21: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Proof :By induction on number of edges.For e = 1, Number of vertices (v) = 2Number of region(r) = 1 (outside)

Putting in formula,v – e + r = 2 - 1+ 1

= 2

Hence , it holds for e=1.

We’ll assume it holds for graph with n-1 edges.

Page 22: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Suppose, we have connected graph G with e edges. We’ll remove one edge.

CASE 1: If removing an edge leads to two disconnected graph

G’’G’(e2 , v2 , r2)

(e1 , v1 , r1)

Removed edge

Page 23: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Since, Both G' and G'' have e < n-1.

Therefore, using induction hypothesis,v1 – e1 + r1 = 2 and v2 – e2+ r2 = 2

Adding above two equations,

Þ v1 – e1 + r1 + v2 – e2 + r2 =2 + 2Þ (v1 + v2) - (e1 + e2)+ r1 + r2 = 4Þ v - (e -1) + r + 1 = 4(one extra region after removing one edge)Þ v – e + r + 2 = 4Þ v – e + r = 2

Hence, it holds for all graph with n edges.

Page 24: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

CASE 2: If removing an edge leads doesn’t lead to disconnected graph

G’Removed edge

(e’ , v’ , r’)

Page 25: MCA 202: Discrete Mathematics under construction Instructor Neelima Gupta ngupta@cs.du.ac.in

Thanks: Sonam 39 and Stuti 40 (MCA 202)

Since, G’ have e < n-1.

Therefore,v'– e'+ r' = 2

For graph G',

v' = ve' = e -1r' = r – 1 (subtracting region created by removed edge)

Þ v' + e' + r' =2 Þ v – ( e – 1 ) + r – 1 = 2Þ v – e + r = 2

Hence, it holds for all graph with n edges.