The Traveling-Salesman Problem
Born August 4, 1805 in Dublin, Ireland Died September 2, 1865 in Dublin, Ireland Made many contributions to the Physics field including advancements in the study of optics and dynamics Introductions to the Mathematics Field formed the study of quaternion an extension of complex numbers that allows work in the 3 rd and 4 th dimensions (symbolized by a bold H) invented the Icosian Game (now called Hamilton’s Puzzle) solved by using Icosian Calculus and these solutions developed into what are now called Hamilton Paths and Hamilton Circuits
Hamilton Path: a path touching every vertex exactly once every edge does NOT have to be used F B A C D ADEBCF Hamilton Path Examples DABEGF EBADEG G C F NOT a Hamilton Path (Example) C E G
Hamilton Circuit: a circuit touching every vertex exactly once every edge does NOT have to be used F D B A C E ADBCFE Hamilton Circuit Examples DAEFCB EFDABC A D F NOT a Hamilton Circuit (Example) E
Weight: a numerical value assigned to each edge of the graph Total Weight: the sum of the edges’ weights used to complete the Hamilton Circuit or Path Hamilton Circuit Examples A E B C D ABCDEA AEBCDA Hamilton Path Examples ABCDE AEBCD
Complete Graph: a graph with N vertices with edges connecting every pair of vertices each vertex has a degree of (no loops) denoted by the symbol K N vertices can be named in any order for Hamilton Circuits Formula for the Number of Hamilton Circuits: Complete Graph Examples A CB AB CD A E B CD A G C D B F H E K 3 2 HC’s K 4 6 HC’s K 5 24 HC’s K 8 5,040 HC’s
Name originates from the classic problem of a traveling-salesman needing to find the cheapest circuit that will allow him to visit multiple clients by traveling to each city just 1 time. the acronym TSP is used to identify this type of problem TSPs are used to identify any type of problem that wants to find the cheapest route while touching every vertex exactly 1 time. Other Examples of TSPs: Package Deliveries School Bus Routes Fabricating Circuit Boards Scheduling Jobs on a Machine Running Errands Around Town
Brute-Force Algorithm a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. Nearest-Neighbor Algorithm a) Pick a Starting Vertex. b) Travel to The Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. Repetitive Nearest-Neighbor Algorithm a) Pick a Starting Vertex. b) Follow the Steps for the Nearest-Neighbor Algorithm (above). c) Repeat the process until EVERY vertex has become the starting/ending vertex. Cheapest-Link Algorithm a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Jerry is the Managing Partner of the “You’re Not Guilty” Law Firm. Part of managing one of the top law firms in the country is having to travel to all 5 of their major offices each month to meet with the partners. While Jerry lives in Dallas, he must visit Chicago, Los Angeles, Miami, and New York. Traveling obviously costs money and in order for clients not to feel like they are being overcharged, Jerry has to make sure that he travels to all 5 cities for as little as possible. We must find the most cost effective means for him to travel between these cities and end back home in Dallas. The cost of flights from each city is found on the following slides. Los Angeles Dallas Chicago Miami New York
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a DALLASn/a LOS ANGELES n/a MIAMIn/a NEW YORK n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLASn/a LOS ANGELES n/a MIAMIn/a NEW YORK n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES n/a MIAMIn/a NEW YORK n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMIn/a NEW YORK n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $937 $907 $787 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $937 $1,147 $787 $864 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $818 $907 $864 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $818 $799 $787 $864 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $1,094 $907 $1,147 $864 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $952 $1,094 $907 $799 $787 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $1,094 $787 $1,147 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–MIA–NY–LA–CHI–DAL = $799 + $937 + $1,094 + $787 + $1,147 = $4,764 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $818 $907 $1,094 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–MIA–NY–LA–CHI–DAL = $799 + $937 + $1,094 + $787 + $1,147 = $4,764 DAL–MIA–CHI–NY–LA–DAL = $799 + $907 + $818 + $1,094 + $779 = $4,397 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $1,147 $864 $818 $1,094 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–MIA–NY–LA–CHI–DAL = $799 + $937 + $1,094 + $787 + $1,147 = $4,764 DAL–MIA–CHI–NY–LA–DAL = $799 + $907 + $818 + $1,094 + $779 = $4,397 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539 DAL–MIA–LA–NY–CHI–DAL = $799 + $864 + $1,094 + $818 + $1,147 = $4,722
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $1,147 $937 $818 $864 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–MIA–NY–LA–CHI–DAL = $799 + $937 + $1,094 + $787 + $1,147 = $4,764 DAL–MIA–CHI–NY–LA–DAL = $799 + $907 + $818 + $1,094 + $779 = $4,397 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539 DAL–CHI–NY–MIA–LA–DAL = $1,147 + $818 + $937 + $864 + $779 = $4,545 DAL–MIA–LA–NY–CHI–DAL = $799 + $864 + $1,094 + $818 + $1,147 = $4,722
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $1,147 $937 $907 $1,094 $779 Brute-Force
Steps for Solving the 5 Cities Example a) Make a list of ALL possible Hamilton Circuits. b) Calculate the Total Weight of EVERY Hamilton Circuit & Find the Cheapest One. DAL–MIA–NY–CHI–LA–DAL = $799 + $937 + $818 + $787 + $779 = $4,120 DAL–MIA–NY–LA–CHI–DAL = $799 + $937 + $1,094 + $787 + $1,147 = $4,764 DAL–MIA–CHI–NY–LA–DAL = $799 + $907 + $818 + $1,094 + $779 = $4,397 DAL–NY–MIA–CHI–LA–DAL = $952 + $937 + $907 + $787 + $779 = $4,362 DAL–NY–MIA–LA–CHI–DAL = $952 + $937 + $864 + $787 + $1,147 = $4,687 DAL–NY–CHI–MIA–LA–DAL = $952 + $818 + $907 + $864 + $779 = $4,320 DAL–NY–CHI–LA–MIA–DAL = $952 + $818 + $787 + $864 + $799 = $4,220 DAL–NY–LA–MIA–CHI–DAL = $952 + $1,094 + $864 + $907 + $1,147 = $4,964 DAL–NY–LA–CHI–MIA–DAL = $952 + $1,094 + $787 + $907 + $799 = $4,539 DAL–CHI–NY–MIA–LA–DAL = $1,147 + $818 + $937 + $864 + $779 = $4,545 DAL–CHI–MIA–NY–LA–DAL = $1,147 + $907 + $937 + $1,094 + $779 = $4,864 DAL–MIA–LA–NY–CHI–DAL = $799 + $864 + $1,094 + $818 + $1,147 = $4,722
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Since each circuit can be traveled in 2 directions, we only had to look at 12 circuits to cover all 24 possibilities. This circuit can be traveled in either direction
Steps for the Nearest-Neighbor Algorithm a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. a) Once you get to the last vertex, connect it back to the starting vertex. While the Brute-Force Algorithm will ALWAYS find the cheapest method, it is not very time friendly. The Nearest-Neighbor Algorithm is a method that allows you to find the “cheapest” circuit without having to analyze every possible circuit.
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147 $ 779 $ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787$ 779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 $ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907 $ 818 DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 937
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 937
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 937 (4)
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI $799 NEW YORK $ 937 (4)
Steps for Solving the 5 Cities Example a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 907$ 818 (3) DALLAS$ 1,147$ 779 (1)$ 799$ 952 LOS ANGELES $ 787 (2)$ 864$ 1,094 MIAMI$799 (5) NEW YORK $ 937 (4)
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Nearest-Neighbor
Steps for the Repetitive Nearest-Neighbor Algorithm a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. d) Repeat the process until EVERY vertex has become the starting/ending vertex. If Jerry applied the Nearest-Neighbor Algorithm to his flight plans, he would have been able to find the cheapest route without as much work. The question that follows is, “Why ever use the Brute-Force Method if the Nearest-Neighbor Algorithm works?” Lets look at the same 5 City Example, but this time find out if the Nearest-Neighbor Algorithm works no matter what city Jerry lives in.
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 $ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $779$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $779 $ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS $ 799 $ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI $ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 937 (4) NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 937 (4) NEW YORK $ 818
Steps for Solving the 5 Cities Example – Home: Chicago a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (1)$ 907$ 818 DALLAS$ 799 (3)$ 952 LOS ANGELES $779 (2)$ 864$ 1,094 MIAMI$ 937 (4) NEW YORK $ 818 (5)
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Nearest-Neighbor
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787 $779 $ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147 $ 799 $ 952 LOS ANGELES $ 787$779 (1)$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 799 (2)$ 952 LOS ANGELES $ 787$779 (1)$ 864$ 1,094 MIAMI $ 907 $ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO $ 818 DALLAS$ 1,147$ 799 (2)$ 952 LOS ANGELES $ 787$779 (1)$ 864$ 1,094 MIAMI$ 907 (3)$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 818 (4) DALLAS$ 1,147$ 799 (2)$ 952 LOS ANGELES $ 787$779 (1)$ 864$ 1,094 MIAMI$ 907 (3)$ 937 NEW YORK $ 1,094
Steps for Solving the 5 Cities Example – Home: Los Angeles a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 818 (4) DALLAS$ 1,147$ 799 (2)$ 952 LOS ANGELES $ 787$779 (1)$ 864$ 1,094 MIAMI$ 907 (3)$ 937 NEW YORK $ 1,094 (5)
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $907 $818 $1,094 $779 Nearest-Neighbor
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907 $799 $ 864$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147 $ 779 $ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799 (1)$ 864$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779 (2)$ 952 LOS ANGELES $ 787 $ 1,094 MIAMI$ 907$799 (1)$ 864$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO $ 818 DALLAS$ 1,147$ 779 (2)$ 952 LOS ANGELES $ 787 (3)$ 1,094 MIAMI$ 907$799 (1)$ 864$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 818 (4) DALLAS$ 1,147$ 779 (2)$ 952 LOS ANGELES $ 787 (3)$ 1,094 MIAMI$ 907$799 (1)$ 864$ 937 NEW YORK $ 937
Steps for Solving the 5 Cities Example – Home: Miami a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 818 (4) DALLAS$ 1,147$ 779 (2)$ 952 LOS ANGELES $ 787 (3)$ 1,094 MIAMI$ 907$799 (1)$ 864$ 937 NEW YORK $ 937 (5)
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Nearest-Neighbor
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818 $952$ 1,094$ 937
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 $ 907 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818 (1)$952$ 1,094$ 937
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (2)$ 907 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $779 $ 864 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818 (1)$952$ 1,094$ 937
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (2)$ 907 DALLAS $ 799 LOS ANGELES $779 (3)$ 864 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818 (1)$952$ 1,094$ 937
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (2)$ 907 DALLAS$ 799 (4) LOS ANGELES $779 (3)$ 864 MIAMI $ 937 NEW YORK $ 818 (1)$952$ 1,094$ 937
Steps for Solving the 5 Cities Example – Home: New York a) Pick a Starting Vertex. b) Travel to the Closest (Cheapest) Vertex. Repeat until ALL vertices are used 1 time. c) Once you get to the last vertex, connect it back to the starting vertex. CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787 (2)$ 907 DALLAS$ 799 (4) LOS ANGELES $779 (3)$ 864 MIAMI$ 937 (5) NEW YORK $ 818 (1)$952$ 1,094$ 937
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4, $799 $937 $818 $787 $779 Nearest-Neighbor
Conclusion for the 5 Cities Example HOME CITYCOST OF CIRCUIT Chicago$ 4,120 Dallas$ 4,120 Los Angeles$ 4,397 Miami$ 4,120 New York$ 4,120 This shows us that if Jerry lived in Los Angeles, it would not have been beneficial for him to trust the Nearest-Neighbor Algorithm. This does not mean he should not live in Los Angeles. It just shows that if using the Nearest-Neighbor Algorithm, you must check it from all the possible vertices to guarantee your answer is the cheapest.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGOn/a$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147n/a$ 779$ 799$ 952 LOS ANGELES $ 787$779n/a$ 864$ 1,094 MIAMI$ 907$799$ 864n/a$ 937 NEW YORK $ 818$952$ 1,094$ 937n/a Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787$ 907$ 818 DALLAS$ 1,147$ 779$ 799$ 952 LOS ANGELES $ 787$779$ 864$ 1,094 MIAMI$ 907$799$ 864$ 937 NEW YORK $ 818$952$ 1,094$ 937 Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787$ 907$ 818 DALLAS$ 779$ 799$ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787$ 907$ 818 DALLAS $ 779 $ 799$ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147$ 787$ 907$ 818 DALLAS $ 779 (1) $ 799$ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 $ 907$ 818 DALLAS $ 779 (1) $ 799$ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link $787
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907$ 818 DALLAS $ 779 (1) $ 799$ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907$ 818 DALLAS $ 779 (1) $ 799 $ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link $787 $799
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907$ 818 DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link $787 $799 $818
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 864$ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 864 $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link $787 $799 $818 $864
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 864 $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $779 Cheapest-Link $787 $799 $818 $907
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2) $ 907 $ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2)$ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 1,094 MIAMI$ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
CITIESCHICAGODALLAS LOS ANGELES MIAMI NEW YORK CHICAGO$ 1,147 $ 787 (2)$ 818 (4) DALLAS $ 779 (1)$ 799 (3) $ 952 LOS ANGELES $ 1,094 MIAMI $ 937 NEW YORK Steps for Solving the 5 Cities Example a) Pick the edge with the smallest weight first. (if a tie, randomly choose one) b) Pick the next smallest edge. (make sure you mark each edge used – only use once) c) Repeat the process until EVERY vertex has been linked. (using each vertex once) d) Once every vertex has been used, link the last vertex back to the starting vertex.
Los Angeles Dallas Chicago Miami New York TOTAL COST: $ 4,120 $779 Cheapest-Link $787 $799 $818 $937
You Now Know All About