+ All Categories
Home > Documents > Graph Theory

Graph Theory

Date post: 21-Feb-2016
Category:
Upload: paley
View: 58 times
Download: 0 times
Share this document with a friend
Description:
Graph Theory. Hamilton Paths and Hamilton Circuits. WHAT YOU WILL LEARN. • Hamilton paths and Hamilton circuits • Traveling salesman problem • Brute force method • Nearest neighbor method. Definitions. - PowerPoint PPT Presentation
29
Graph Theory Hamilton Paths and Hamilton Circuits
Transcript
Page 1: Graph Theory

Graph Theory

Hamilton Paths and Hamilton Circuits

Page 2: Graph Theory

WHAT YOU WILL LEARN• Hamilton paths and Hamilton

circuits• Traveling salesman problem• Brute force method• Nearest neighbor method

Page 3: Graph Theory

Definitions

A Hamilton path is a path that contains each vertex of a graph exactly once.

A Hamilton circuit is a path that begins and ends at the same vertex and passes through all other vertices of the graph exactly one time.

Page 4: Graph Theory

Example: Hamilton Path

Graph (a) shown has Hamilton path A, B, C, E, D. The graph also has Hamilton path C, B, A, D, E. Can you find some others?

Graph (b) shown has Hamilton path A, B, C, F, H, E, G, D. The graph also has Hamilton path G, D, E, H, F, C, B, A. Can you find some others?

Page 5: Graph Theory

Example: Hamilton Circuit

Graph (a) shown has Hamilton circuit A, B, D, G, E, H, F, C, A.

Graph (b) shown has Hamilton circuit A, B, C, E, D, A. Can you find another?

Page 6: Graph Theory

Definition

A complete graph is a graph that has an edge between each pair of its vertices.

Page 7: Graph Theory

Example: Finding Hamilton Circuits

Determine a Hamilton circuit for the graph shown.

One solution isA, G, F, E, C, D, B, A

A B C

EFG

D

Page 8: Graph Theory

Number of Unique Hamilton Circuits in a Complete Graph

The number of unique Hamilton circuits in a complete graph with n vertices is

(n 1)! , where

(n 1)! = (n 1)(n 2)(n 3)…(3)(2)(1)

Page 9: Graph Theory

Example: Number of Hamilton Circuits

How many unique Hamilton circuits are there in a complete graph with the following number of vertices?

a) 4 b) 9

a) 4 = (4 1)! = 3•2•1 = 6

b) 9 = (9 1)! = 8•7•6•5•4•3•2•1 = 40,320

Page 10: Graph Theory

The Brute Force Method of Solving Traveling Salesman Problems

To determine the optimal solution:1. Represent the problem with a complete,

weighted graph.2. List all possible Hamilton circuits for this

graph.3. Determine the cost (or distance) associated

with each of these Hamilton circuits.4. The Hamilton circuit with the lowest cost (or

shortest distance) is the optimal solution.

Page 11: Graph Theory

Example: Brute Force Method

Find a minimum Hamilton circuit for the complete, weighted graph shown.

List all the Hamilton circuits.

Since there are 4 vertices there are (4 1)! = 3! = 6 possible circuits.

A B

CD

6

12822

6

Page 12: Graph Theory

Example: Brute Force Method continued

2661262A, D, C, B, A2421282A, D, B, C, A226862A, C, D, B, A

222

Fourth Leg

248122A, C, B, D, A22686A, B, D, C, A266126A, B, C, D, A

TotalThird Leg

Second Leg

First Leg

Circuit

The minimum amount for the graph would be 22.

A B

CD

6

12822

6

Page 13: Graph Theory

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem To approximate a optimal solution:

1. Represent the problem with a complete, weighted graph.

2. Identify the starting vertex.3. Of all the edges attached to the starting

vertex, choose the edge that has the smallest weight. This edge is generally either the shortest distance or the lowest cost. Travel along this edge to the second vertex.

Page 14: Graph Theory

Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem (continued)

4. At the second vertex, choose the edge that has the smallest weight that does not lead to a vertex already visited. Travel along this edge to the third vertex.

5. Continue this process, each time moving along the edge with the smallest weight until all vertices are visited.

6. Travel back to the original vertex.

Page 15: Graph Theory

Example: Nearest Neighbor

An appliance repair man must repair four appliances at the locations shown in the graph on the next slide. The estimated travel time (in minutes) is shown between the four locations. The repair man wants to visit the four locations in an order that takes the least amount of time. Use the nearest neighbor algorithm to find an approximate solution to the problem.

Page 16: Graph Theory

Example: Nearest Neighbor (continued)

Choose a starting vertex. Let’s choose vertex A.

Choose the edge that has the smallest weight. Either AD or AB, lets choose AD (8).

At D choose the edge that has the smallest weight DE (4).

E

start here

2nd vertex

C

B

A

D

18813

4

7

6

9

7

3

8

Page 17: Graph Theory

Example: Nearest Neighbor (continued)

Continue moving along the edge with the smallest weight.

Circuit would be: A, D, E, B, C, A

8 + 4 + 3 + 9 + 13 = 37

This route would take about 37 minutes.

start here

2nd vertex

C

B

A

E

D

18813

4

7

6

9

7

3

8

Page 18: Graph Theory

Example: Nearest Neighbor (continued)

Other circuits and weights.

3 + 7 + 6 + 13 + 18 = 47E, B, D, C, A, EE4 + 3 + 8 + 13 + 6 = 34D, E, B, A, C, DD6 + 4 + 3 + 8 + 13 = 34C, D, E, B, A, CC3 + 4 + 6 + 13 + 8 = 34B, E, D, C, A, BB

Total WeightCircuitStarting Vertex

Page 19: Graph Theory

In the following graph, determine a Hamilton path.

a. HGEDABCFBE

b. GEDABCFH

c. HGEDABCF

d. FBADEGH

Page 20: Graph Theory

In the following graph, determine a Hamilton path.

a. HGEDABCFBE

b. GEDABCFH

c. HGEDABCF

d. FBADEGH

Page 21: Graph Theory

Alicia lives in Washington, D.C. and wants to take a road trip to visit her friends from college who live in the following cities: New York, Boston, Philadelphia, Dover, and Baltimore. How many ways can Alicia visit each city and return home to Washington, D.C.?

a. 120 b. 60

c. 25 d. 24

Page 22: Graph Theory

Alicia lives in Washington, D.C. and wants to take a road trip to visit her friends from college who live in the following cities: New York, Boston, Philadelphia, Dover, and Baltimore. How many ways can Alicia visit each city and return home to Washington, D.C.?

a. 120 b. 60

c. 25 d. 24

Page 23: Graph Theory

Robert decides to take a walk to run his errands. He needs to walk to the drug store, the post office, and the dry cleaners. The distances between these four locations are as follows: home (H) to the drug store (D) is 0.6 miles, home to the post office (P) is 0.5 miles, home to the dry cleaners (C) is 0.7 miles, the drug store to the post office is 0.2 miles, the drug store to the dry cleaner is 0.5 miles, and the dry cleaner to the post office is 0.2 miles.

H to D: 0.6 H to P: 0.5 H to C: 0.7D to P: 0.2 D to C: 0.5 C to P: 0.2

Page 24: Graph Theory

Represent this traveling salesman problem with a complete, weighted graph.H to D: 0.6 H to P: 0.5 H to C: 0.7D to P: 0.2 D to C: 0.5 C to P: 0.2

a.

c.

b.

d.0.50.5

0.2

0.6

0.70.2

0.2

0.6

0.50.5

0.2

0.6

0.7 0.2

Page 25: Graph Theory

Represent this traveling salesman problem with a complete, weighted graph.H to D: 0.6 H to P: 0.5 H to C: 0.7D to P: 0.2 D to C: 0.5 C to P: 0.2

a.

c.

b.

d.

0.50.5

0.2

0.6

0.7 0.2

0.50.5

0.2

0.6

0.70.2

0.2

0.6

Page 26: Graph Theory

Use the brute force method to determine the shortest route for Robert to visit each location once and return home. What is the distance when using this route?

a. HDPCH; 1. 7 miles

b. HPDCH; 1.7 miles

c. HPCD; 1.2 miles

d. HCDPH; 1.7 miles

Page 27: Graph Theory

Use the brute force method to determine the shortest route for Robert to visit each location once and return home. What is the distance when using this route?

a. HDPCH; 1. 7 miles

b. HPDCH; 1.7 miles

c. HPCD; 1.2 miles

d. HCDPH; 1.7 miles

Page 28: Graph Theory

Use the nearest neighbor method to approximate the optimal route for Robert to visit each location once and return home. What is the distance when using this route?

a. HDPCH; 1. 7 miles

b. HPDCH; 1.7 miles

c. HPCD; 1.2 miles

d. HCDPH; 1.7 miles

Page 29: Graph Theory

Use the nearest neighbor method to approximate the optimal route for Robert to visit each location once and return home. What is the distance when using this route?

a. HDPCH; 1. 7 miles

b. HPDCH; 1.7 miles

c. HPCD; 1.2 miles

d. HCDPH; 1.7 miles


Recommended