Transcript Slide 1

Chapter 2: Business Efficiency
Lesson Plan
 Business Efficiency
For All Practical
Purposes
 Visiting Vertices-Graph Theory Problem
 Hamiltonian Circuits
Mathematical Literacy in
Today’s World, 7th ed.
 Vacation Planning Problem
 Minimum Cost-Hamiltonian Circuit
 Method of Trees
 Fundamental Principle of Counting
 Traveling Salesman Problem
 Helping Traveling Salesman
 Nearest Neighbor and Sorted Edges Algorithms
 Minimum-Cost Spanning Trees
 Kruskal’s Algorithm
 Critical-Path Analysis
© 2006, W.H. Freeman and Company
Chapter 2: Business Efficiency
Business Efficiency
 Visiting Vertices
 In 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 cities
 Inspecting traffic
signals
 Delivering mail to
drop-off boxes
 Pharmaceutical
representative
visiting doctors
Chapter 2: Business Efficiency
Hamiltonian Circuit
 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).
Chapter 2: Business Efficiency
Hamiltonian Circuit vs. Euler Circuits
Hamiltonian vs. Euler Circuits
Hamiltonian circuit –
 Similarities
A tour (showed by
 Both forbid re-use.
 Hamiltonian do not reuse vertices.
 Euler do not reuse edges.
 Differences
wiggly edges) that
starts at a vertex of a
graph and visits each
vertex once and only
once, returning to
where it started.
 Hamiltonian is a circuit of vertices.
 Euler is a circuit of edges.
 Euler graphs are easy to spot
Euler circuit – A circuit
(connectedness and even valence).
that traverses each
 Hamiltonian circuits are NOT as easy
edge of a graph
to determine upon inspection.
exactly once and starts
 Some certain family of graphs can be
known to have or not have Hamiltonian
and stops at the same
circuits. (Km,n , m>n, is an infinite family of
point.
graphs that have no Hamiltonian circuits.)
Chapter 2: Business Efficiency
Hamiltonian Circuits
 Vacation–Planning Problem
 Hamiltonian circuit concept is used to find the best route that
minimizes the total distance traveled to visit friends in different
cities.
(less mileage  less gas  minimizes costs)
This is a complete graph
on 4 vertices (K4).
Road mileage between four cities
Hamiltonian circuit with weighted edges
 Edges 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.
Chapter 2: Business Efficiency
Hamiltonian Circuit
 Minimum-Cost Hamiltonian Circuit
 A Hamiltonian circuit with the lowest
possible sum of the weights of its edges.
 Algorithm (step-by-step process)
for Solving This Problem
1. Generate all possible
Hamiltonian tours
(starting with Chicago).
2. Add up the distances
on the edges of each
tour.
3. Choose the tour of
minimum distance.
Algorithm – A step-by-step description
of how to solve a problem.
Chapter 2: Business Efficiency
Hamiltonian Circuits
 Method of Trees
 For 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 treediagram 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
Chapter 2: Business Efficiency
Hamiltonian Circuits
 Minimum-Cost Hamiltonian
Circuit: Vacation-Planning
Example
1. Method of trees used to find
all tours (for four cities:
three unique paths). On the
graph, the unique paths are
drawn with wiggly lines.
2. Add up distance on edges
of each unique tour. The
smallest sum would give us
the minimal distance, which
is the minimum cost.
3. 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
Chapter 2: Business Efficiency
Hamiltonian Circuit
 Principle of Counting
for Hamiltonian Circuits
 For 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
Complete graph –
A graph in
which every
pair of vertices
is joined by an
edge.
 Fundamental Principle of Counting
If 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.
Read Example 2 on p. 42.
Chapter 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). See p. 43.
 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: bus schedules, mail drop-offs,
telephone booth coin pick-up routes, etc.
 How can the TSP be solved?
 Brute force method as we did in the Vacation Planning
example. This is not practical if n is large.
 Heuristic methods can be used to find a “fast” answer, but does
not guarantee that it is always the optimal answer.


Nearest neighbor algorithm
Sorted edges algorithm
Chapter 2: Business Efficiency
Traveling Salesman Problem — Nearest Neighbor
 Nearest Neighbor Algorithm (to solve TSP)
 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.
Read p. 46
Hamiltonian Circuit:
A-B-C-E-D-A
Nearest neighbor starting at vertex A
Hamiltonian Circuit:
B-C-A-D-E-B
Nearest neighbor starting at vertex B
Now use this algorithm to solve the Vacation Planning Problem.
Chapter 2: Business Efficiency
Traveling Salesman Problem — Sorted Edges
 Sorted Edges Algorithm (to solve TSP)
 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.
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 2800 miles.
Now use this algorithm to solve the Vacation Planning Problem.
Chapter 2: Business Efficiency
Traveling Salesman Problem
 Many methods for solving the TSP have been suggested. However,
none of these methods guarantees an optimal solution.
 A Heuristic algorithm is a method of solving an optimization problem
that is fast but does not guarantee an optimal answer to the problem
 A Greedy algorithm is an approach for solving an optimization
problem, where at each stage of the algorithm the best or cheapest
action is taken. Greedy algorithms do no always lead to optimal
solutions.
 The Nearest-Neighbor algorithm and the Sorted-Edges algorithm are
examples of Heuristic algorithms and Greedy algorithms.
Chapter 2: Business Efficiency
Minimum-Cost Spanning Trees
 Minimum-Cost Spanning Trees
Discuss meaning of trees and
spanning trees. See
figures on p. 51.
 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.
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
Chapter 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.
A Spanning Tree Example
 Kruskal’s Algorithm is an
example of a greedy algorithm.
 It is reliable and always yields
the minimum answer, unlike the
Nearest-Neighbor Algorithm
described for TSP.
 Graph (a) on the right shows the
costs of putting roads (edges) to
connect new homes (vertices) in
a suburban land-development
project. Find a minimum-cost
spanning tree.
 Read Spotlight 2.2.
Chapter 2: Business Efficiency
Critical Path Analysis
 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.
 Order-Requirement Digraph
 A directed graph (digraph) that shows which tasks precede other
tasks among the collection of tasks making up a job.
 Critical Path
 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.
Chapter 2: Business Efficiency
Critical Path Analysis
 Sometimes, we are interested in finding the longest path.
 Scheduling machines and people is difficult since the tasks cannot
be done in a random order.
 Example: Thanksgiving Dinner.
 If the tasks cannot be performed in a random order, we can specify
the order in an order-requirement digraph.
 A digraph can be used to illustrate that traffic on a street must go in
one direction or that certain tasks in a job must be completed prior to
other tasks.
Order-Requirement Digraph
 This is an example of an
order-requirement digraph.
 Note that there is a vertex
for each task.
 If one task must be
completed before another,
we draw a directed edge or
an arrow from the
prerequisite task to the
subsequent task.
 The number inside each
circle is the time it takes to
complete each task.
Turning a Plane Around Example
 Suppose that the job of
“turning the plane around”
requires the completion of
the following five tasks:
 The order-requirement
digraph is shown on the
right.
Task A
Unload
13
passengers mins
Task B
Unload
cargo
25
mins
Task C
Clean
cabin
15
mins
Task D
Load new
cargo
22
mins
Task E
Load new
27
passengers mins
Turning a Plane Around Example continued…
 We want to find the earliest completion time. However, finding the shortest path
in this digraph does not solve the problem.
 Consider the path BD with length 25+22=47. Since task B must be done before
D, the two tasks cannot be completed before time 47 minutes.
 Hence, even if work on the other tasks A, C and E proceeds during this period,
all tasks cannot be finished before the tasks on path BD are finished.
 So the earliest completion time is the length of the longest path.
 The earliest completion time is 13+15+27=55 minutes corresponding to ACE.
We call ACE the critical path. Note that completion of the tasks in less than 55
minutes is not possible.