Presentation on theme: "Chapter 2: Business Efficiency Lesson Plan"— Presentation transcript:
1Chapter 2: Business Efficiency Lesson Plan Visiting Vertices-Graph Theory ProblemHamiltonian CircuitsVacation Planning ProblemMinimum Cost-Hamiltonian CircuitMethod of TreesFundamental Principle of CountingTraveling Salesman ProblemHelping Traveling SalesmanNearest Neighbor and Sorted Edges AlgorithmsMinimum-Cost Spanning TreesKruskal’s AlgorithmCritical-Path Analysis
2Chapter 2: Business Efficiency Business Efficiency Visiting VerticesIn some graph theory problems, it is only necessary to visit specific locations (using the travel routes, or streets available).Problem: Find an efficient route along distinct edges of a graph that visits each vertex only once in a simple circuit.Applications:Salesman visiting particular citiesInspecting traffic signalsDelivering mail to drop-off boxesPharmaceutical representative visiting doctors
4Remember….Chapter 1: Urban Services Finding Euler Circuits Is there an Euler Circuit?Does it have even valence? (Yes)Is the graph connected? (Yes)Euler circuit exists if both “yes.”Create (Find) an Euler CircuitPick a point to start (if none has been given to you).Number the edges in order of travel, showing the direction with arrows.Cover every edge only once, and end at the same vertex where you started.
5Chapter 2: Business Efficiency Hamiltonian Circuit A tour that starts and ends at the same vertex (circuit definition).Visits each vertex once. (Vertices cannot be reused or revisited.)Circuits can start at any location.Use wiggly edges to show the circuit.Starting at vertex A, the tour can be written as ABDGIHFECA, or starting at E, it would be EFHIGDBACE.A different circuit visiting each vertex once and only once would be CDBIGFEHAC (starting at vertex C).
6Chapter 2: Business Efficiency Hamiltonian Circuit vs. Euler Circuits Hamiltonian vs. Euler CircuitsSimilaritiesBoth forbid re-use.Hamiltonian do not reuse vertices.Euler do not reuse edges.DifferencesHamiltonian is a circuit of vertices.Euler is a circuit of edges.Euler graphs are easy to spot (connectedness and even valence).Hamiltonian circuits are NOT as easy to determine upon inspection.(some classes of graphs have them, so do not)Hamiltonian circuit – A tour (showed by wiggly edges) that starts at a vertex of a graph and visits each vertex once and only once, returning to where it started.Euler circuit – A circuit that traverses each edge of a graph exactly once and starts and stops at the same point.
7Chapter 2: Business Efficiency Hamiltonian Circuit Example of a graph that will NEVER have a Hamiltonian circuit.A family of graphs that never has a Hamiltonian circuitConstructed with vertices on two parallel vertical columns with one column having more vertices than the other.
8Chapter 2: Business Efficiency Hamiltonian Circuit Find a Hamiltonian circuit for this graph starting at A.
9Chapter 2: Business Efficiency Hamiltonian Circuit Does this graph have a Hamiltonian circuit?
10Chapter 2: Business Efficiency Hamiltonian Circuits Vacation–Planning ProblemHamiltonian circuit concept is used to find the best route that minimizes the total distance traveled to visit friends in different cities (assume less mileage less gas minimizes costs)Hamiltonian circuit with weighted edgesEdges of the graph are given weights, or in this case mileage or distance between cities.As you travel from vertex to vertex, add the numbers (mileage in this case).Each Hamiltonian circuit will produce a particular sum.Road mileage between four cities
11Chapter 2: Business Efficiency Hamiltonian Circuit Minimum-Cost Hamiltonian CircuitA Hamiltonian circuit with the lowest possible sum of the weights of its edges.Algorithm (step-by-step process) for Solving This ProblemGenerate all possible Hamiltonian tours (starting with Chicago).Add up the distances on the edges of each tour.Choose the tour of minimum distance.Algorithm – A step-by-step description of how to solve a problem.
12Chapter 2: Business Efficiency Hamiltonian Circuits Method of TreesFor the first step of the algorithm, a systematic approach is needed to generate all possible Hamiltonian tours (disregard distances during this step).This method begins by selecting a starting vertex, say Chicago, and making a tree-diagram showing the next possible locations.At each stage down, there will be one less choice (3, 2, then 1 choice).In this example, the method of trees generated six different paths, all starting and ending with Chicago.However, only three are unique circuits.Method of trees for vacation-planning problem
13Chapter 2: Business Efficiency Hamiltonian Circuits Minimum-Cost Hamiltonian Circuit: Vacation-Planning ExampleMethod of tree used to find all tours (for four cities: three unique paths). On the graph, the unique paths are drawn with wiggly lines.Add up distance on edges of each unique tour. The smallest sum would give us the minimal distance, which is the minimum cost.Choose the tour of minimum distance. The smallest sum would give us the minimal distance, which is the minimum cost.The three Hamiltonian circuits’ sums of the tours
14Chapter 2: Business Efficiency Hamiltonian Circuit Use the method of trees to find all possible Hamiltonian circuits for this graph starting at A.
15Chapter 2: Business Efficiency Hamiltonian Circuit Use the method of trees to find all possible Hamiltonian circuits for this graph starting at A.The first three branches on the left yield three distinct Hamiltonian circuits ABCDA, ABDCA, and ABDCAThe next three are their reversals ADCBA, ACDBA, and ADBCA
16Chapter 2: Business Efficiency Hamiltonian Circuit Principle of Counting for Hamiltonian CircuitsFor a complete graph of n vertices, there are (n - 1)! possible routes.Half of these routes are repeats, the result is:Possible unique Hamiltonian circuits are(n - 1)! / 2Complete graph – A graph in which every pair of vertices is joined by an edge.Fundamental Principle of CountingIf there are a ways of choosing one thing,b ways of choosing a second after the first is chosen,c ways of choosing a third after the second is chosen…, and so on…,and z ways of choosing the last item after the earlier choices,then the total number of choice patterns is a × b × c × … × z.Example: Jack has 9 shirts and 4 pairs of pants. He can wear 9 × 4 = 36 shirt-pant outfits.
17Chapter 2: Business Efficiency Complete Graph Complete graph – A graph in which every pair of vertices is joined by an edge.
18Chapter 2: Business Efficiency Principle of Counting Determine how many Hamiltonian circuits there are for a complete graph with 10 vertices.Principle of Counting for Hamiltonian CircuitsFor a complete graph of n vertices, there are (n - 1)! possible routes.Half of these routes are repeats, the result is:Possible unique Hamiltonian circuits are(n - 1)! / 2
19Chapter 2: Business Efficiency Principle of Counting Determine how many Hamiltonian circuits there are for a complete graph with 10 vertices.For n = 10, we get:
20Chapter 2: Business Efficiency Brute Force Method
21Chapter 2: Business Efficiency Traveling Salesman Problem Traveling Salesman Problem (TSP)Difficult to solve Hamiltonian circuits when the number of vertices in a complete graph increases (n becomes very large).This problem originated from a salesman determining his trip that minimizes costs (less mileage) as he visits the cities in a sales territory, starting and ending the trip in the same city.Many applications today:Lobster Fisherman needs to pick up netsTelephone company needs to pick up coins form payphonesElectric Company needs to set routes for the meter readerBus picking up campers and then returning themPicking up records from ATM machinesDriving service dropping people from the airportYou running your errands…thank you Jared Mackie!
22Chapter 2: Business Efficiency Traveling Salesman Problem How can the TSP be solved?Computer program can find optimal route (not always practical).Heuristic methods can be used to find a “fast” answer, but does not guarantee that it is always the optimal answer.Nearest-Neighbor algorithmSorted-Edges algorithm
23Chapter 2: Business Efficiency Traveling Salesman Problem — Nearest Neighbor Nearest Neighbor Algorithm Starting from the “home” city (or vertex), first visit the nearest city (one with the least mileage from “home”).As you travel from city to city, always choose the next city (vertex) that can be reached quickest (i.e., nearest with the least miles), that has not already been visited.When all other vertices have been visited, the tour returns home.Hamiltonian Circuit: A-B-C-E-D-AHamiltonian Circuit: B-C-A-D-E-BNearest neighbor starting at vertex ANearest neighbor starting at vertex B
24Chapter 2: Business Efficiency Use the Nearest Neighbor Algorithm to finish finding a Hamiltonian circuit for this graph. When you have finished, calculate the total.Starting at vertex C, proceed to D, and then to BCDBAC - 120
25Chapter 2: Business Efficiency Use the Nearest Neighbor Algorithm to find a Hamiltonian circuit for this graph starting at C. What is the total weight?CDAEBC - 112
26Chapter 2: Business Efficiency Traveling Salesman Problem — Sorted Edges Sorted Edges Algorithm Start by sorting, or arranging, the edges in order of increasing cost (sort smallest to largest mileage between cities).At each stage, select that edge of least cost until all the edges are connected at the end while following these rules:If an edge is added that results in three edges meeting at a vertex, eliminate the longest edge.Always include all vertices in the finished circuit.
27Chapter 2: Business Efficiency Traveling Salesman Problem — Sorted Edges
28Chapter 2: Business Efficiency Traveling Salesman Problem — Sorted Edges Example using sorted edges Edges selected are DE at 400, BC at 500, AD at 550, and AB at 600 (AC and AE are not chosen because they result in three edges meeting at A). Lastly, CE at 750 is chosen to complete the circuit of miles.
29Chapter 2: Business Efficiency For this graph, what are the first three edges chosen according to the sorted edges algorithm? Complete the circuit and calculate the total cost.AB, CD, and BC are the cheapest and they do not close a loop or meet at a single vertex – forces us to use DA. Tour adds up to 130
30Chapter 2: Business Efficiency Use the Sorted-Edges algorithm to find a Hamiltonian circuit for this graph. What is the total weight?Edges selected are AB at 10,CD at 10, AC at 15, and DE at 20, and BE at 300 is chosen to complete the circuit of 80
31Chapter 2: Business Efficiency Minimum-Cost Spanning Trees Example: What is the cost to construct a Pictaphone service (telephone service with video image of the callers) among five cities?The diagram shows the cost to build the connection from each vertex to all other vertices (connected graph).Cities are linked in order of increasing costs to make the connection.The cost of redirecting the signal may be small compared to adding another link.Costs (in millions of dollars) of installing Pictaphone service among five cities
32Chapter 2: Business Efficiency Minimum-Cost Spanning Trees Another graph theory optimization problem that links all the vertices together, in order of increasing costs, to form a “tree.”The cost of the tree is the sum of the weights on the edges.A tree will consist of one piece and contains no circuits. A spanning tree is a tree that connects all vertices of a graph with each other with no redundancy.
33Chapter 2: Business Efficiency With A as the original graph, which of the graphs shown in bold represent trees and/or spanning trees?
34Chapter 2: Business Efficiency Spanning Trees Two spanning trees for graph A are shown in b and c.
35Chapter 2: Business Efficiency Minimum-Cost Spanning Trees Kruskal’s Algorithm — Developed by Joseph Kruskal (AT&T research).Goal of minimum-cost spanning tree: Create a tree that links all the vertices together and achieves the lowest cost to create.Add links in order of cheapest cost according to the rules:No circuit is created (no loops).If a circuit (or loop) is created by adding the next largest link, eliminate this largest (most expensive link)—it is not needed.Every vertex must be included in the final tree.
36Chapter 2: Business Efficiency Using this graph again, apply Kruskal’s Algorithm
37Chapter 2: Business Efficiency Using this graph again, apply Kruskal’s Algorithm
38Chapter 2: Business Efficiency Using this graph again, apply Kruskal’s Algorithm
39Chapter 2: Business Efficiency Critical Path Analysis Most often, scheduling jobs consists of complicated tasks that cannot be done in a random order.Due to a pre-defined order of tasks, the entire job may not be done any sooner than the longest path of dependent tasks.
40Chapter 2: Business Efficiency Critical Path Analysis Order-Requirement DigraphA directed graph (digraph) that shows which tasks precede other tasks among the collection of tasks making up a job.
41Chapter 2: Business Efficiency Order Requirement Graph True or False T1 must be done before T2T2 must be done before T4T1 must be done before T7T2 need not be done before T5T3 need not be done before T5
42Chapter 2: Business Efficiency Critical Path Analysis The longest path in an order-requirement digraph.The length is measured in terms of summing the task times of the tasks making up the path.An order-requirement digraph, tasks A – E with task times in the circlesCritical Path is BE = = 52 min.
43Chapter 2: Business Efficiency Find the Critical Path for this order-requirement digraph
44Chapter 2: Business Efficiency What is the length of the earliest completion time for this order-requirement digraph?