Top Banner
Foundations of Discrete Mathematics Chapter 10 By Dr. Dalia M. Gil, Ph.D.
50

Foundations of Discrete Mathematics

Jan 22, 2016

Download

Documents

Foundations of Discrete Mathematics. Chapter 10. By Dr. Dalia M. Gil, Ph.D. Path. A path is a sequence of edges hat begins at a vertex of a graph and travels along edges of the graph, always connecting pairs of adjacent vertices. Walk. - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Foundations of Discrete Mathematics

Foundations of Discrete Mathematics

Chapter 10

By Dr. Dalia M. Gil, Ph.D.

Page 2: Foundations of Discrete Mathematics

A path is a sequence of edges hat begins at a vertex of a graph and travels along edges of the graph, always connecting pairs of adjacent vertices.

Path

Page 3: Foundations of Discrete Mathematics

A walk in a pseudograph is an altering sequence of vertices and edges, beginning and ending with a vertex, in which each edge is incident with the vertex immediately preceding it and the vertex immediately following it.

Walk

Page 4: Foundations of Discrete Mathematics

The length of a walk is the number of edges in it.

A walk is closed if the first vertex is the same as the last and otherwise open.

Walk

Page 5: Foundations of Discrete Mathematics

A trail is a walk in which all edges are distinct; a path is a walk in which all vertices are distinct.

Trail

Page 6: Foundations of Discrete Mathematics

A closed trail is a circuit.

A circuit in which the first vertex appears exactly twice (at the beginning and the end) and in which no other vertex appears more than once is a cycle.

An n-cycle is a cycle with n vertices. It is even if n is even and odd if n is odd.

Circuit

Page 7: Foundations of Discrete Mathematics

Terms and their characteristics

Term Characteristics

Trail Distinct edges

Path Distinct vertices

Circuit Closed trail

Cycle Closed trail with distinct vertices (hence distinct edges too)

Page 8: Foundations of Discrete Mathematics

Example

Walk : A B C E F C B D (length : 7)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 9: Foundations of Discrete Mathematics

Example

Trail : A B C E F C D

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 10: Foundations of Discrete Mathematics

Example

Closed walk :A B C E F C B D A

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 11: Foundations of Discrete Mathematics

Example

Circuit : B C E F C D B

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 12: Foundations of Discrete Mathematics

Example

3-cycle : B C D B

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 13: Foundations of Discrete Mathematics

Example

A closed walk (not a cycle): C E F C B D C

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 305

Page 14: Foundations of Discrete Mathematics

An Eulerian or Euler circuit in a graph G is a simple circuit containing every edge of G.

An Euler path in G is a simple path containing every edge of G.

An Eulerian Circuit

Page 15: Foundations of Discrete Mathematics

The graph G1 has an Euler circuit: a, e, c, d, e, b, a

Example: An Eulerian Circuit

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 578

Page 16: Foundations of Discrete Mathematics

The graph G2 and G3 don’t have an Euler circuit.

G3 has an Euler path:a, c, d, e, b, d, a, b

G2 does not have an Euler path.

Example: An Eulerian Circuit

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 578

Page 17: Foundations of Discrete Mathematics

H2 has an Euler circuit:

a, g, c, b, g, e, d, f, a

H1 nor H3 has an Euler circuit.

H3 has an Euler path: c, a, b, c, d, b

H1 does not have an Euler path.

Example: An Eulerian Circuit

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 579

Page 18: Foundations of Discrete Mathematics

A connected multigraph has an Eulerian circuit if and only if each of its vertices has even degree.

A connected multigraph has an Eulerian path but not an Eulerian circuit if and only if it has exactly two vertices of odd degree.

An Eulerian Circuit

Page 19: Foundations of Discrete Mathematics

G1 contains two vertices of odd degree (b and d).

b and d must be the end points of this Euler path.

Example: Eulerian Path

d, a, b, c, d, b is an Euler path.

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

Page 20: Foundations of Discrete Mathematics

G2 contains exactly two vertices of odd degree (b and d).

b and d must be the end points of this Euler path.

Example: Eulerian Path

b, a, g, f, e, d, c, g, b, c, f, d is an Euler path.

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

Page 21: Foundations of Discrete Mathematics

G3 has six vertices of odd degree.

G3 has no Euler path.

Example: No Eulerian Path

“Discrete Mathematics and its Applications.” Fifth Edition, by Kenneth H. Rosen. Mc Graw Hill, 2003. pag 582

Page 22: Foundations of Discrete Mathematics

A Hamiltonian cycle in a graph is a cycle that contains every vertex of a graph.

A Hamiltonian graph is one with a Hamiltonian cycle.

A Hamiltonian circuit as a circuit in which every vertex except the first and last appears exactly once.

Hamiltonian Cycles

Page 23: Foundations of Discrete Mathematics

A Hamiltonian circuit is a cycle.

The terms Hamiltonian circuit and Hamiltonian cycle are synonymous.

Hamiltonian Cycles

Page 24: Foundations of Discrete Mathematics

Hamiltonian Cycles

Cycle A B C D E A is Hamiltonian

G2 is not Hamiltonian G1 is Hamiltonian

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 311

Page 25: Foundations of Discrete Mathematics

Many problems can be modeled using graphs with weights to their edges.

Problems associated with edge is a unit of time, distance, cost, or capacity in some sense.

Shortest Path Algorithm

Page 26: Foundations of Discrete Mathematics

A weighted graph is a graph G(V, E) together with a function w: E → [0, ). If e is an edge, the nonnegative real number w(e) is called the weight of e.

The weight of a subgraph of G (often a path or a trail) is the sum of the weights of the edges of the subgraph.

Shortest Path Algorithm

Page 27: Foundations of Discrete Mathematics

A traveling salesman visits various towns and cities.

If he wants to avoid having to pass through the same community twice, he needs a Hamiltonian cycle through the map of towns and air routs.

The Traveling Salesman’s Problem

Page 28: Foundations of Discrete Mathematics

A traveling salesman visits various towns and cities.

If he wants to avoid having to pass through the same community twice, he needs a Hamiltonian cycle through the map of towns and air routs.

The Traveling Salesman’s Problem

Page 29: Foundations of Discrete Mathematics

To find a shortest path from vertex A to vertex E in a weighted graph.

Step 1 Assign to A the label (_, 0).

Step 2 Until E or no further labels can be assigned, do the following.

a) For each labeled vertex u(x, d) and for each unlabeled vertex v adjacent to u, compute d+w(e) where e = uv.

Dijkstra’s Algorithm

Page 30: Foundations of Discrete Mathematics

b) Find the minimum value d’ of all numbers d + w(e) found in a).

c) For each u and v for which d + w(e) = d’, assign to v the label (u, d’). If a vertex can be labeled (x, d’) for various vertices x, make any choice.

Dijkstra’s Algorithm

Page 31: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

Give A the label (_, 0). There are 3 edges incident with A with weights 7, 5, and 8. d = 0

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 32: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

Since d = 0, vertex H gives the smallest value of d + w(e), H acquires the label (A, 5), G the label (A, 8), and B the label (A, 7) because they are the smallest d + w(e).

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 33: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

Vertex I and C give the smallest value of d + w(e), I acquires the label (B, 10), and C the label (B, 15)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 34: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

Vertex J, D and F give the smallest value of d + w(e), J acquires the label (I, 17), D the label (J, 20), and F the label (D, 15).

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 35: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

Vertex E gives the smallest value of d + w(e), E acquires the label (F, 21).

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 36: Foundations of Discrete Mathematics

Example: Dijkstra’s Algorithm

The shortest route from A to E has weight 21. A shortest path is AGFE.

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 328

Page 37: Foundations of Discrete Mathematics

To find a shortest path from vertex A to vertex E in a weighted graph.

Step 1 Set v1 = A and assign to this vertex the permanent label 0. Assign every other vertex a temporary label of , where is a symbol that, by definition, is deemed to be larger that any real number.

Step 2 Until E has been assigned a permanent label or no temporary labels are changed in (a) or (b) do the following:

Dijkstra’s Algorithm (Improved)

Page 38: Foundations of Discrete Mathematics

(a) Take the vertex vi that most recently acquired a permanent label, say d. For each vertex v that is adjacent to vi and has not yet received a permanent label, if d + w(vi, v) < t, the current temporary label of v, change the temporary label of v to d + w(vi, v).

(b) Take a vertex v that has a temporary label smallest among all temporary labels in the graph. Set vi+1 = v and make its temporary label permanent. If there are several vertices v that tie for smallest temporary label, make any choice.

Dijkstra’s Algorithm (Improved)

Page 39: Foundations of Discrete Mathematics

At the start, A = v1 is given the permanent label 0, all the others are given temporary label

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 40: Foundations of Discrete Mathematics

Next, H, B, and G have their temporary labels decreased to 5, 7, and 8, respectively, all other temporary labels stay at .

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 41: Foundations of Discrete Mathematics

Since 5 is the minimum of 5, 7, 8, set v2 = H, The vertices adjacent to v2. For B, 5 + 4 = 9, 9 > 7, so no

change occurs. For G, 5 + 5 = 10, 10 > 8. so no change occurs, set v3 = B.

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 42: Foundations of Discrete Mathematics

The vertices adjacent to v3. For C, 7 + 8 = 15. For I, 7 + 3 = 10. Now C, I, and G have their temporary labels 15, 10, 8, respectively. The smallest is 8. so v4 = G.

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 43: Foundations of Discrete Mathematics

The vertices adjacent to v4. For I, 8 + 2 = 10, the current label , so there is no change. For F, 8 + 7 = 15, so F gets a temporary label of 15 and set v5 = I

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 44: Foundations of Discrete Mathematics

Next, we have a choice of C or F for v6 and J gets a temporary label 17.

Assuming v6= C, then F = v7 and D obtains a temporary label 23.

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 45: Foundations of Discrete Mathematics

Finally, v10 = 21. Then D gets its temporary label lowered to 20 and becomes v9.

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 46: Foundations of Discrete Mathematics

This algorithm gives the length of the shortest path but not the path itself.

Dijkstra’s Algorithm (Improved)

“Discrete Mathematics with Graph Theory.” Fifth Edition, by E. G. Goodaire ane M. Parmenter Prentce Hall, 2006. pag 330

Page 47: Foundations of Discrete Mathematics

This algorithm gives the length of the shortest path but not the path itself.

(permanent label of vl) + (weight of edge vlvi)

= (permanent label of vi)

Dijkstra’s Algorithm (Improved)

Page 48: Foundations of Discrete Mathematics

Topics covered

Eulerian circuits.

Hamilton cycles.

Shortest path algorithms: Dijkstra’s Algorithm.

Page 49: Foundations of Discrete Mathematics

Reference

“Discrete Mathematics with Graph Theory”, Third Edition, E. Goodaire and Michael Parmenter, Pearson Prentice Hall, 2006. pp 304-338.

Page 50: Foundations of Discrete Mathematics

Reference

“Discrete Mathematics and Its Applications”, Fifth Edition, Kenneth H. Rosen, McGraw-Hill, 2003. pp 557-601.