graphs paths circuits euler. traveling salesman problems
TRANSCRIPT
Graphs
Paths
Circuits
Euler
Last Chapter
Discrete MathTraveling 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
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
Create a graph so that all of the cities are connected.
Make it easy to read for yourself.
Create a Graph
Find the cost for your flights.
You should have 10 flights to look up.
Write the cost on each edge.
Go to Southwest Airlines
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?
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
Hamilton v. Euler
Hamilton v. Euler
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
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
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
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 226 #2,5,6,9,10,
14,15, and 16
Problems
When every vertex is connected by an edge
Complete Graphs
The notation for a complete graph
The number of edges is equal to
Complete Graph
◦ 1225 edges
How many edges
Use a factorial!!!
Hamilton Circuits
How many paths
Given that
#17 (a)
(9!+11!)10 !
#19 (a)
20!
#21 (a)
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)
If the number of edges in is x, and the number edges in is y, what is the value of ?
#25 (c)
Find the value of N when:◦ has 45 edges
#27 (b)
Page 229 #17-28
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
Try to find the optimal route
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
1. Make a list of all possible routes2. Calculate all the tours3. Choose the one with the smallest number
Brute-Force Algorithm
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
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
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
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
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
Relative Error
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
Just like Nearest-Neighbor, but you create a circuit for all the vertices to be your starting point.
Repetitive Nearest-Neighbor
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
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
A C E B D A
Chapter 6 #30, 31, 35, 36,
38, 41, 42, 44, 47, 48
Problems