graphs paths circuits euler. traveling salesman problems

42
Graphs Paths Circuits Euler Last Chapter

Upload: melanie-bruce

Post on 20-Jan-2016

234 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Graphs

Paths

Circuits

Euler

Last Chapter

Page 2: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Discrete MathTraveling Salesman Problems

Page 3: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

You are invited to go on a lecture circuit to colleges across the country.

The company said they will cover for a part of your travel expense and you will have to cover the rest.

The cities you are able to visit are…

Lecture Circuit

Page 4: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Pick 5 of the cities below Seattle Portland Spokane Boise Salt Lake City Reno Sacramento San Francisco San Jose Las Vegas Los Angeles San Diego Phoenix Charleston Tampa Orlando Ft. Lauderdale Raleigh Richmond Washington DC Philadelphia New York Providence Boston

Denver Albuquerque San Antonio Austin Houston Dallas Oklahoma City Kansas City Little Rock New Orleans Jackson Memphis St. Louis Pensacola Atlanta Nashville Chicago Indianapolis Minneapolis/St. Paul Detroit Cleveland Pittsburgh Charlotte

Page 5: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Create a graph so that all of the cities are connected.

Make it easy to read for yourself.

Create a Graph

Page 6: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Find the cost for your flights.

You should have 10 flights to look up.

Write the cost on each edge.

Go to Southwest Airlines

Page 7: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

How many different circuits do you make?

Which circuit would you use?

What was its cost?

How did you find this circuit? What was your process for choosing flights?

Page 8: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Hamilton Path- A path that crosses ever VERTEX once and only once

Hamilton Circuit- A Circuit that crosses ever VERTEX once and ends in the place it started.

Hamilton Paths and Circuits

Page 9: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Hamilton v. Euler

Page 10: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Hamilton v. Euler

Page 11: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Euler Circuit Euler Path Hamilton

CircuitHamilton

Path

(a) Yes No Yes Yes

(b) No Yes No Yes

(c) No No Yes Yes

(d) Yes No No Yes

(e) No Yes No No

(f) No No No No

Page 12: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

If there is a Hamilton Circuit, then there is a Hamilton Path (Drop the last edge that creates the circuit).

There is no connection between Euler and Hamilton

There is no easy theorem to see if there is a Hamilton Circuit or Path.

What we learn from this table

Page 13: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Find 3 different Hamilton circuits Find a Hamilton path that starts at A and

ends at B Find a Hamilton path that starts at D and

ends at F

#1

Page 14: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Find the weight of edge BD. Find a Hamilton circuit that starts with BD

and give its weight. Find a Hamilton circuit that starts withDB and give its weight.

#13

Page 15: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Page 226 #2,5,6,9,10,

14,15, and 16

Problems

Page 16: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

When every vertex is connected by an edge

Complete Graphs

Page 17: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

The notation for a complete graph

The number of edges is equal to

Complete Graph

Page 18: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

◦ 1225 edges

How many edges

Page 19: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Use a factorial!!!

Hamilton Circuits

How many paths

Page 20: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Given that

#17 (a)

Page 21: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

(9!+11!)10 !

#19 (a)

Page 22: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

20!

#21 (a)

Page 23: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

A super computer can generate one billion Hamilton circuits per second.

Estimate the number of years it will take for the computer to generate Hamilton circuits.

#23 (a)

Page 24: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

If the number of edges in is x, and the number edges in is y, what is the value of ?

#25 (c)

Page 25: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Find the value of N when:◦ has 45 edges

#27 (b)

Page 26: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Page 229 #17-28

Problems

Page 27: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Sites: The vertices on the graph

Costs: The weight of the edges

Tour: A Hamilton Circuit

Optimal Tour: Hamilton Circuit of least weight

TSP vocab

Page 28: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Try to find the optimal route

Page 29: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Exhaustive Search: Make a list of all possible routes. The previous example has 24 possible.

Go Cheap: Go to the cheapest city. Continue by going through the cheapest routes possible.

Simple Strategies

Page 30: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

1. Make a list of all possible routes2. Calculate all the tours3. Choose the one with the smallest number

Brute-Force Algorithm

Page 31: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

This will ALWAYS get you the optimal tour.

Problem: it is an INEFFICIENT ALGORITHM. This means that it can take way to long to find your solution.◦ Even with computers

Brute-Force

Page 32: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

If a computer can calculate one quadrillion tours a second (1,000,000,000,000,000). It will take the computer seconds to calculate until we hit

Super Computer

Page 33: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

n Time

20 2 mins

21 40 mins

22 14 hours

23 13 days

24 10 months

25 20 years

26 500 years

27 13,000 years

28 350,000 years

29 9.8 million years

30 284 million years

Page 34: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Start at the starting vertex Go to the “nearest neighbor” (edge with the

lowest amount) Continue through all the points End at your starting vertex

Nearest-Neighbor

Page 35: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

This is not optimal because it might not give us our optimal route

But this is effective because it is proportional to the size of the graph

◦ 10 vertices= 10 steps◦ 30 vertices= 30 steps

Nearest-Neighbor

Page 36: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Relative Error

Page 37: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Using Algorithms to get close to the optimal but might not be the optimal.

Ask yourself: Is a 12.49% relative error good or would we have to be closer?

Approximate Algorithms

Page 38: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Just like Nearest-Neighbor, but you create a circuit for all the vertices to be your starting point.

Repetitive Nearest-Neighbor

Page 39: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

A C E D B A◦ 773

B C A E D B◦ 722

C A E D B C◦ 722

D B C A E D◦ 722

E C A D B E◦ 741

Page 40: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Find the cheapest edge and mark it Pick the next smallest edge Keep picking the smallest edges

◦ Do not close the circuit◦ Do not have 3 edges go to the same vertex

Close the circuit to finish

Cheapest Link

Page 41: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

A C E B D A

Page 42: Graphs  Paths  Circuits  Euler. Traveling Salesman Problems

Chapter 6 #30, 31, 35, 36,

38, 41, 42, 44, 47, 48

Problems