Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks)...

21
Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks) The Mathematics of Relationships 4

Transcript of Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 1 4 Graph Theory (Networks)...

Copyright © 2014, 2010, 2007 Pearson Education, Inc.Copyright © 2014, 2010, 2007 Pearson Education, Inc.

Section 4.2, Slide 1

4 Graph Theory (Networks)

The Mathematics of Relationships

4

Copyright © 2014, 2010, 2007 Pearson Education, Inc.Copyright © 2014, 2010, 2007 Pearson Education, Inc.

Section 4.2, Slide 2

The Traveling Salesperson Problem

4.2

• Understand how to solve the traveling salesperson problem using Hamilton circuits

• Determine all Hamilton circuits in a complete graph

(continued on next slide)

Copyright © 2014, 2010, 2007 Pearson Education, Inc.Copyright © 2014, 2010, 2007 Pearson Education, Inc.

Section 4.2, Slide 3

The Traveling Salesperson Problem

4.2

• Solve the traveling salesperson problem using the brute force

algorithm

• Solve the traveling salesperson problem using the best edge

algorithm

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 4

The Traveling Salesperson Problem

Danielle lives in Philadelphia and must make visits next week to branch offices in New York City, Cleveland, Atlanta, and Memphis. To determine which would be her cheapest trip, she has obtained prices of flights between each pair of cities.

What sequence of visits minimizes the cost?

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 5

Hamilton Paths

• Before we tackle Danielle’s problem, we need some additional tools.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 6

Hamilton Paths

• Example: Find a Hamiltonian path.

(solution on next slide)

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 7

Hamilton Paths

• Solution: answers may vary.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 8

Finding Hamilton Circuits

• Examples:

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 9

Finding Hamilton Circuits

• Often, we need to find all the Hamilton circuits in a graph.

• This is easy for complete graphs.

• Tree diagrams help us find Hamilton circuits systematically.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 10

Finding Hamilton Circuits

• Example: Find all Hamilton circuits in K4.

• Solution:Path ABCDA is a Hamilton circuit in K4.

We will consider path BCDAB to be the same path because it passes through the same vertices in the same order and the only difference is that we are beginning and ending at vertex B rather than vertex A.

So, we will assume that all circuits begin at A.

(continued on next slide)

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 11

Finding Hamilton Circuits

• Solution:

Use a tree diagram to list all Hamilton circuits systematically.

(continued on next slide)

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 12

Finding Hamilton Circuits

• Solution:

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 13

Finding Hamilton Circuits

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 14

Solving the TSP by Brute Force

• In solving a TSP problem by brute force, we consider all possible Hamiltonian circuits.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 15

Solving the TSP by Brute Force

• Example: Use the weighted graph to find the sequence of cities for Danielle to visit that will minimize her total travel cost.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 16

Solving the TSP by Brute Force

• Solution: Use brute force to explore all possible circuits:

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 17

Solving the TSP by Brute Force

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 18

The Nearest Neighbor Algorithm

• There are algorithms that give good approximations to the TSP.

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 19

The Nearest Neighbor Algorithm

• Example: Use the nearest neighbor algorithm to schedule Danielle’s trip.

• Solution:

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 20

The Best Edge Algorithm

Copyright © 2014, 2010, 2007 Pearson Education, Inc. Section 4.2, Slide 21

The Best Edge Algorithm

• Example: Use the best edge algorithm to schedule Danielle’s trip.

• Solution:

210 + 230 + 170 + 240 + 350 = 1200Notice that this circuit has a weight of 1,200, which also makes it the best solution to Danielle’s problem.