A mathematical view of our world
Download
1 / 148

A Mathematical View of Our World - PowerPoint PPT Presentation


  • 109 Views
  • Uploaded on

A Mathematical View of Our World. 1 st ed. Parks, Musser, Trimpe, Maurer, and Maurer. Chapter 6. Routes and Networks. Section 6.1 Routing Problems. Goals Study graphs, vertices, and edges Study paths and circuits Study connected graphs Use Euler’s Theorem Use Fleury’s Algorithm.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'A Mathematical View of Our World' - thom


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
A mathematical view of our world

A Mathematical View of Our World

1st ed.

Parks, Musser, Trimpe, Maurer, and Maurer


Chapter 6

Chapter 6

Routes and Networks


Section 6 1 routing problems
Section 6.1Routing Problems

  • Goals

    • Study graphs, vertices, and edges

    • Study paths and circuits

    • Study connected graphs

      • Use Euler’s Theorem

      • Use Fleury’s Algorithm


6 1 initial problem
6.1 Initial Problem

  • Can the people of Konigsberg, pictured here, take a walk crossing each bridge exactly one time?

    • The solution will be given at the end of the section.


Graphs
Graphs

  • A graph is a collection of one or more points, called vertices, and the paths connecting them, called edges.

    • The singular of vertices is vertex.


Graphs cont d
Graphs, cont’d

  • The vertices are drawn as dots.

  • The edges are drawn as straight or curved lines.

    • Each edge has two ends with a vertex at each end, or else it is a loop connecting a vertex to itself.


Equivalent graphs
Equivalent Graphs

  • Two graphs are considered the same if they have the same number of vertices connected in the same way, even if they look different.


Example 1
Example 1

  • The three graphs shown are equivalent.


Vertices and edges
Vertices and Edges

  • Two edges may appear to cross, but they do not actually intersect unless there is a vertex.

  • Example: Graph (a) shows two edges crossing where there is no vertex.


Example 2
Example 2

  • Graphs can be drawn to represent real-life connections, such as roads between cities.

  • Example: Draw a graph to represent the roadmap.


Example 2 cont d
Example 2, cont’d

  • Solution: The vertices represent the cities, and the edges represent the roads.


Adjacent vertices
Adjacent Vertices

  • Two vertices are called adjacent vertices if there is an edge connecting them.


Example 3
Example 3

  • List the pairs of adjacent vertices in the graph.


Example 3 cont d
Example 3, cont’d

  • Solution: The pairs of adjacent vertices are:

    • A and B, A and C, A and D, A and E

    • B and D

    • C and E

    • E and E, since there is a loop at E


Question
Question:

List all the vertices that are adjacent to the vertex labeled Portland.

a. Salem, Boise, Olympia

b. Salem, Spokane

c. Salem, Olympia, Seattle, Spokane

d. Boise


Example 4
Example 4

  • Draw two different graphs with the following properties:

    • Vertices: A, B, C, and D

    • Adjacent vertices are:

      A and C, B and C, B and D, C and D.


Example 4 cont d
Example 4, cont’d

  • Solution: Two possible graphs are shown below.


Degree of a vertex
Degree of a Vertex

  • The degree of a vertex is the total number of edges at the vertex.

    • Find the degree of a vertex by counting the number of edges leaving or arriving at the vertex.

    • A loop contributes 2 to the degree of a vertex.


Example 5
Example 5

  • Find the degree of each vertex in the graph.

  • Solution:

    • A has degree 5,

    • B has degree 3,

    • C has degree 2,

    • D has degree 2,

    • E has degree 4.


Theorem
Theorem

  • If d is the sum of all the degrees of the vertices in a graph and e is the number of edges in the graph, then d = 2e.

    • Note: This theorem is true because each edge adds 2 to the degree total.


Example 6
Example 6

  • Verify that the theorem is true for the following graph.

  • Solution: The sum of the degrees is 16. The number of edges is 8. Check that 16 = 2(8).


Paths
Paths

  • A path is a route in a graph.

    • Each vertex used is adjacent to the next vertex used.

    • Each edge in the graph is used at most one time.

  • A path is written as a list of vertices.


Example 7
Example 7

  • Find three different paths in the graph.

  • Solution:

    • One possible path is A,B,D,A,E.

    • A second path is B,A,B,D.

    • A third path is C,E,E,A

      • There are many other paths.


Circuits
Circuits

  • A circuit is a path that begins and ends at the same vertex.

  • Example: One circuit in the graph is A,B,D,A.


Euler paths
Euler Paths

  • A path that uses every edge of a graph exactly once is called an Euler path.

    • Note: Euler is pronounced “oiler.”

    • Example: The edges are numbered in the order used.


Euler circuits
Euler Circuits

  • A circuit that uses every edge of a graph exactly once is called an Euler circuit.

    • Example: The edges are numbered in the order used.


Connected graphs
Connected Graphs

  • A graph is said to be connected if, for every pair of vertices, there is a path that contains them.

  • If a graph is not connected, it is said to be disconnected.

    • An edge is called a bridge if its removal from the graph would change the graph from connected to disconnected.


Example 8
Example 8

  • Explain whether or not the graphs are connected.

    • Solution: The graph is connected because there is a path, using one edge or more, between every pair of vertices.


Example 8 cont d
Example 8, cont’d

  • Solution 2: The graph is disconnected because, for example, there is no path between vertex A and vertex G.


Example 9
Example 9

  • Identify any bridges in the (connected) graph.

  • Solution: There are three bridges: the edge between D and E, the edge between D and F, and the edge between F and G.


Components
Components

  • A component of a graph is a maximal connected piece of the graph.

    • A component is connected.

    • If any more edges are added to the component (if there are any more in the graph) it would become disconnected.

    • Every graph has one or more components.


Components cont d
Components, cont’d

  • Any connected graph has one component.

    • For the connected graph in the previous example, the entire graph is the only component.

  • A disconnected graph has two or more components.

    • For the disconnected graph in the previous example, there are two components.


Components cont d1
Components, cont’d

  • To find the components of a graph, use the following algorithm.

  • Pick any vertex of the graph and highlight it.

  • Highlight all edges connecting to the highlighted vertex and all vertices at the end of those edges.

  • Repeat step 2 as many times as possible.

  • When no more vertices can be highlighted, you have a component.


Example 10
Example 10

  • Find all components of the graph.

  • Solution: We use the algorithm from the preceding slide. There are three components: the piece containing A, E, F, and G; the piece containing B and C; and the piece containing D.


Degree theorem
Degree Theorem

  • Any graph must have an even number of vertices with odd degree.

    • We saw earlier that the sum of all the degrees in a graph is always an even number, so:

      • Vertices with even degrees do not have to come in pairs.

      • Vertices with odd degrees come in pairs.


Euler s theorem
Euler’s Theorem

  • For a connected graph:

    • If the graph has zero vertices of odd degree, then it has at least one Euler circuit.

    • If a graph has an Euler circuit, then it has no vertices of odd degree.


Euler s theorem cont d
Euler’s Theorem cont’d

  • For a connected graph:

    • If the graph has exactly two vertices of odd degree, then

      • It does not have an Euler circuit.

      • It has at least one Euler path.

      • Any Euler path starts at one of the two vertices of odd degree and ends at the other.


Euler s theorem cont d1
Euler’s Theorem cont’d

  • For a connected graph:

    • If the graph has more than two vertices of odd degree, then

      • It does not have an Euler circuit.

      • It does not have an Euler path.


Question1
Question:

Does the graph have an Euler circuit, an Euler path, or neither?

a. Euler circuit

b. Euler path only

c. neither


Example 11
Example 11

  • Does the graph have an Euler circuit, Euler path, or neither?

  • Solution: Every vertex is of degree 2 or degree 4, so by Euler’s theorem the graph has an Euler circuit.


Example 11 cont d
Example 11, cont’d

  • Solution: There are two vertices of odd degree, E and G, so by Euler’s theorem the graph has only an Euler path.


Fleury s algorithm
Fleury’s Algorithm

  • If Euler’s Theorem indicates that there is an Euler circuit, Fleury’s Algorithm can be used to find the circuit.

  • The step-by-step procedure is as follows:

    • Copy all the vertices, but not the edges, of the original graph.

    • Select any vertex on the original graph and mark it as the present position.


Fleury s algorithm cont d
Fleury’s Algorithm, cont’d

  • Choose one edge at the marked vertex and transfer it to the new graph.

    • Do not choose a bridge, unless it is the only edge available.

    • Number the edges in the order they are transferred.


Fleury s algorithm cont d1
Fleury’s Algorithm, cont’d

  • Use the vertex on the other end of the edge as the new present position. Repeat step 3.

  • When you transfer the last edge you are done.


Example 12
Example 12

  • Use Fleury’s Algorithm to find an Euler circuit for the graph.

  • Possible Final Solution:


6 1 initial problem solution
6.1 Initial Problem Solution

  • The idea of Euler circuits can be used to solve the question of whether the people of Konigsberg can take a walk crossing each bridge exactly one time.


Initial problem solution cont d
Initial Problem Solution, cont’d

  • The vertices represent the land and the edges the bridges. The described walk would be an Euler path.

  • We use Euler’s Theorem to show that there is no such path for their walk because there are four vertices of odd degree.


Section 6 2 network problems
Section 6.2Network Problems

  • Goals

    • Study weighted graphs

    • Study spanning trees

      • Study minimal spanning trees

      • Use Kruskal’s algorithm


6 2 initial problem
6.2 Initial Problem

  • Walkways need to be built between the buildings on the campus pictured at right.


6 2 initial problem cont d
6.2 Initial Problem, cont’d

  • How can the walkways be constructed so that:

    • Students can go from any building on campus to any other building without needing to walk outside.

    • The total length of the walkways is minimized.

      • The solution will be given at the end of the section.


Weighted graphs
Weighted Graphs

  • A graph in which each edge has a number associated with it is called a weighted graph.

    • The number corresponding to an edge is called the weight of the edge.


Weighted graphs cont d
Weighted Graphs, cont’d

  • Typically the weights of the edges in a graph are assigned in a way that represents some physical situation or practical problem.

  • The lengths of the edges in a graph do not have to be proportional to the stated weights.


Weighted graphs cont d1
Weighted Graphs, cont’d

  • An example of a weighted graph is shown below.


Example 13
Example 1

  • Suppose Ed has:

    • A 35-minute drive from his home to his workplace

    • A 15-minute drive from his workplace to his health club

    • A 25 minute drive from his health club to his home

  • Draw a weighted graph to represent this situation.


Example 1 cont d
Example 1, cont’d

  • Solution:

    • The vertices of the graph will represent Ed’s home (H), his workplace (W), and his health club (C).

    • The weight of each edge will represent the driving time between the two places.

    • For simplicity, we can draw all the edges as straight lines and with the same length.


Example 1 cont d1
Example 1, cont’d

  • Solution, cont’d: One possible weighted graph is shown below.


Redundant edges
Redundant Edges

  • Redundant edges are edges that can be removed while still leaving a path between the two vertices.

  • Example: If edge CH is removed from the previous graph, Ed can still get from home to his club by driving to work and then to the club.

    • The edge CH is a redundant edge.


Question2
Question:

Are there any redundant edges in the graph?

a. yes

b. no


Subgraphs
Subgraphs

  • A subgraph of a given graph is a set of vertices and edges chosen from among those of the original graph.

  • Example: Removing edge CH creates the subgraph shown at right.


Subgraphs cont d
Subgraphs, cont’d

  • Example: Another subgraph could be created by removing vertex C and its two incident edges.


Example 21
Example 2

  • A bus line goes between the cities shown in the table.

    • Draw a weighted graph to represent the situation.

    • Find two different routes from Selma to Anniston.


Example 2 cont d1
Example 2, cont’d

  • Solution: A weighted graph is shown below.


Example 2 cont d2
Example 2, cont’d

  • Solution: One possible route from Selma to Anniston is SMGA, with a total weight (length) of 49 + 127 + 27 = 203 miles.


Example 2 cont d3
Example 2, cont’d

  • Solution, cont’d: Another possible route from Selma to Anniston is SBA, with a total weight (length) of 160 + 62 = 222 miles.


Trees
Trees

  • One way to recognize that a graph contains redundant edges is to find a circuit in the graph.

    • Recall that a circuit is a path that begins at a vertex and returns to that vertex without using any edges twice.

  • A connected graph that has no circuits is called a tree.


Question3
Question:

Choose the graph that is a tree.

a. b.

c. d.


Trees cont d
Trees, cont’d

  • The following figure gives examples of graphs that are trees and a graph that is not a tree.


Example 31
Example 3

  • This graph is not a tree because it contains several circuits.

  • Find a subgraph that is a tree.


Example 3 cont d1
Example 3, cont’d

  • Solution: Circuits are highlighted and edges are removed until the remaining subgraph has no circuits left.


Spanning trees
Spanning Trees

  • A spanning tree is a subgraph that:

    • Contains all the original vertices of the graph.

    • Is connected.

    • Contains no circuits.


Spanning trees cont d
Spanning Trees, cont’d

  • Every connected graph has at least one spanning tree.

  • An example of a spanning tree is shown below.


Minimal spanning trees
Minimal Spanning Trees

  • A spanning tree with the smallest possible total weight is called a minimal spanning tree.

    • Since a connected, weighted graph can have multiple spanning trees, there may be one or more than one of those spanning trees with the smallest total weight.


Minimal spanning trees cont d
Minimal Spanning Trees, cont’d

  • For the connected, weighted graph shown below:

    • Subgraph (b) is not a minimal spanning tree.

    • Subgraph (c) is a minimal spanning tree.


Kruskal s algorithm
Kruskal’s Algorithm

  • A method known as Kruskal’s algorithm can be used to find a minimal spanning tree of a connected, weighted graph.

  • Kruskal’s algorithm begins with all the vertices of a graph and adds edges one by one, using the idea of acceptable and unacceptable edges.


Kruskal s algorithm cont d
Kruskal’s Algorithm, cont’d

  • Acceptable edges are

    • Edges that do not share a vertex with any edges already chosen.


Kruskal s algorithm cont d1
Kruskal’s Algorithm, cont’d

  • Acceptable edges are

    • Edges that connect two components of the subgraph.


Kruskal s algorithm cont d2
Kruskal’s Algorithm, cont’d

  • Acceptable edges are

    • Edges that connect a component of the subgraph to a new vertex.


Kruskal s algorithm cont d3
Kruskal’s Algorithm, cont’d

  • Unacceptable edges are

    • Edges that add to a component of the subgraph, but do not add a new vertex.


Kruskal s algorithm cont d4
Kruskal’s Algorithm, cont’d

  • Consider only the vertices of the graph.

  • Add the edge with the smallest weight.

  • Add the acceptable edge with the smallest weight.

  • Determine whether all vertices are connected by a path.

    • If so, you have a minimal spanning tree.

    • If not, repeat Step 3.


Example 41
Example 4

  • Construct a minimal spanning tree for the weighted graph.


Example 4 cont d1
Example 4, cont’d

  • Solution:

    • Start with the 4 vertices.

    • Add the edge with the smallest weight.


Example 4 cont d2
Example 4, cont’d

  • Solution, cont’d:

    • All unused edges are acceptable, so we simply choose the edge with the smallest weight.

      • Select the edge with weight 2.6.


Example 4 cont d3
Example 4, cont’d

  • Solution, cont’d:

    • The acceptable edges at this step were the ones with weights 4.8 and 3.7.

      • Select the edge with weight 3.7.


Example 4 cont d4
Example 4, cont’d

  • Solution, cont’d:

    • The subgraph is now connected, so this is a minimal spanning tree.

      • The weight of the tree is 1.5 + 2.6 + 3.7 = 7.8.


6 2 initial problem solution
6.2 Initial Problem Solution

  • How can a college build walkways of the minimum length possible so that students can go from any building on campus to any other building without needing to walk outside?


Initial problem solution cont d1
Initial Problem Solution, cont’d

  • Create a weighted graph to represent the buildings and existing sidewalks on the campus.

    • The weight of each edge is the distance between the two buildings.


Initial problem solution cont d2
Initial Problem Solution, cont’d

  • Use Kruskal’s algorithm to find a minimal spanning tree.

    • The edges included in the minimal spanning tree represent the sidewalks that should be converted into covered walkways.


Initial problem solution cont d3
Initial Problem Solution, cont’d

  • Under this plan, students can get from any building to any other building without going outside, although they may have to walk farther inside.

  • The length of the walkways was minimized to a total of 210 + 220 + 120 + 200 = 750 feet.


Section 6 3 traveling salesperson problem
Section 6.3Traveling-Salesperson Problem

  • Goals

    • Study Hamiltonian circuits

    • Study the Traveling-Salesperson Problem

      • Use the Brute-Force Algorithm

      • Use the Nearest-Neighbor Algorithm

      • Use the Cheapest-Link Algorithm


6 3 initial problem
6.3 Initial Problem

  • An author needs to find a route that will minimize the total distance she must drive between the cities.

    • The solution will be given at the end of the section.


Hamiltonian circuits
Hamiltonian Circuits

  • A path that visits each vertex in a graph exactly once is called a Hamiltonian path.

  • If a Hamiltonian path begins and ends at the same vertex, it is called a Hamiltonian circuit.


Example 14
Example 1

  • The highlighted edges in the graph represent a Hamiltonian path.

    • The path can be written AGFEDBC or CBDEFGA.


Example 22
Example 2

  • The highlighted edges in the graph represent a Hamiltonian circuit.

    • The circuit, starting at A, can be written AGFEDCBA


Hamiltonian circuits cont d
Hamiltonian Circuits, cont’d

  • Note: A Hamiltonian path or circuit must pass through every vertex of the graph, but it does not have to use every edge.

  • A Hamiltonian path can be used, for example, to model a delivery truck stopping at every house in a neighborhood but not using every street.


Example 32
Example 3

  • Find a Hamiltonian path in each graph or explain why you cannot.


Example 3 cont d2
Example 3, cont’d

  • Solution: The path ABCD is a Hamiltonian path.

    • Adding an edge to the path forms the Hamiltonian circuit ABCDA.

    • Other Hamiltonian paths and circuits are possible.


Example 3 cont d3
Example 3, cont’d

  • Solution: The path ABCD is a Hamiltonian path.

    • There is no Hamiltonian circuit.


Example 3 cont d4
Example 3, cont’d

  • There is no Hamiltonian path.

    • Any Hamiltonian path must start at either A or F.

    • Any path that starts at A will leave out either C, D, or F.

    • Any path that starts at F will leave out either C, D, or A.


Complete graphs
Complete Graphs

  • A complete graph is a graph in which every pair of vertices is connected by exactly one edge.


Example 42
Example 4

  • For each graph, determine whether or not it is complete.


Example 4 cont d5
Example 4, cont’d

  • Solution: Check each pair of vertices.

    • There is exactly one edge between each pair of vertices, so the graph is complete.


Example 4 cont d6
Example 4, cont’d

  • Solution: Check each pair of vertices.

    • There is no edge from A to C, for example. The graph is not complete.


Example 4 cont d7
Example 4, cont’d

  • Solution: Check each pair of vertices.

    • There are two edges from A to F, for example. The graph is not complete.


Example 51
Example 5

  • Draw an example of a complete graph with five vertices.

  • Count the number of edges in the graph.


Example 5 cont d
Example 5, cont’d

  • Solution: Two possible representations of such a graph are shown below.

  • A complete graph with 5 vertices has 10 edges.


Theorem on complete graphs
Theorem on Complete Graphs

  • The number of edges in a complete graph always follows a certain pattern.

  • A complete graph with n vertices

    always has edges.


Question4
Question:

A graph has 20 vertices and 195 edges. Is the graph complete?

a. yes

b. no


Complete graphs cont d
Complete Graphs, cont’d

  • In general, a graph may or may not have a Hamiltonian path or circuit.

  • A complete graph, however, always has a Hamiltonian circuit.

    • Any list of all the vertices in the graph will be a Hamiltonian path.

    • Adding the starting vertex to the end of the list describing the path will create a Hamiltonian circuit.


Example 61
Example 6

  • List all the Hamiltonian paths and all the Hamiltonian circuits in the graph.



Example 6 cont d1
Example 6, cont’d

  • Note that the complete graph in the previous example had 3 vertices and 6 different Hamiltonian circuits.

  • This is the case because each circuit can begin at one of the 3 vertices, travel to one of 2 vertices second, and travel to the 1 remaining vertex last.

    • There are 3(2)(1) = 6 Hamiltonian circuits.


Theorem on complete graphs1
Theorem on Complete Graphs

  • The number of Hamiltonian paths in a complete graph with n vertices is

    n! = n(n – 1)(n – 2)(n – 3)…(1).

    • The symbol n! is read “n factorial”.


Question5
Question:

How many possible Hamiltonian circuits exist in a complete graph with 9 vertices?

a. 81

b. 40,320

c. 362,880

d. 3,265,920


Traveling salesperson problem
Traveling-Salesperson Problem

  • A salesperson who must visit various cities and then return home wants to minimize the cost (measured in distance, time, or money) of his or her trip.

  • Because Hamiltonian circuits can be applied to find this type of least-cost trip, the problem of finding a least-cost Hamiltonian circuit is called the Traveling-Salesperson Problem.


Complete weighted graphs
Complete Weighted Graphs

  • The cost of a path in a weighted graph is the sum of the weights assigned to the edges in the path.

  • When costs are assigned to each edge in a complete graph, the graph is called a complete weighted graph.


Question6
Question:

What is the cost of the path ABD in the graph below?

a. 26

b. 14

c. 24

d. 41


Example 71
Example 7

  • List all possible Hamiltonian paths, and their costs, in the complete weighted graph.

  • Find the path of least cost.


Example 7 cont d
Example 7, cont’d

  • Solution: The graph has 4 vertices, so there are 4! = 24 different Hamiltonian paths.

  • These paths and their costs are listed on the next slide.



Example 7 cont d2
Example 7, cont’d

  • Solution, cont’d: There are 2 Hamiltonian paths with the lowest cost of 37.

    • CDAB

    • BADC


Example 7 cont d3
Example 7, cont’d

  • List all possible Hamiltonian circuits that start and end at vertex A.

  • Find the circuit at A of least cost.



Example 7 cont d5
Example 7, cont’d

  • Solution, cont’d: There are 2 least-cost Hamiltonian circuits with a cost of 74.

    • ABCDEA

    • AEDCBA

      • These 2 circuits are mirror images of each other.


Traveling salesperson cont d
Traveling-Salesperson, cont’d

  • The method used to solve the previous example is called the Brute-Force Algorithm.

    • List all possible Hamiltonian circuits.

    • Calculate the cost of each circuit.

    • Find the 2 mirror image circuits of least cost.

  • This method is very time-consuming.


Traveling salesperson cont d1
Traveling-Salesperson, cont’d

  • Instead of the Brute-Force Algorithm, faster approximation algorithms are typically used.

  • An approximation algorithm finds a Hamiltonian circuit that is either the least-cost circuit or is one that is not much more costly than the least-cost circuit.


Traveling salesperson cont d2
Traveling-Salesperson, cont’d

  • Two approximation algorithms will be studied:

    • The Nearest-Neighbor Algorithm

    • The Cheapest-Link Algorithm


Nearest neighbor algorithm
Nearest-Neighbor Algorithm

  • Specify a starting vertex.

  • If unvisited vertices remain, go from the current vertex to the unused vertex with the lowest-cost connecting edge.

  • If no unvisited vertices remain, return to the starting vertex to finish forming the circuit.


Example 81
Example 8

  • Apply the algorithm to approximate the lowest-cost Hamiltonian circuit.


Example 8 cont d1
Example 8, cont’d

  • Solution:

    • Let the starting vertex be A.

    • The unvisited vertices are B, C, D, and E.

      • The choice of edges are AB: 13, AC: 11, AD: 17, or AE: 15.

      • Choose edge AC and move to vertex C, the new current vertex.


Example 8 cont d2
Example 8, cont’d

  • Solution, cont’d:

    • The unvisited vertices are B, D, and E.

      • The choice of edges are CB: 20, CD: 12, or CE: 14.

      • Choose edge CD.


Example 8 cont d3
Example 8, cont’d

  • Solution, cont’d:

    • The current vertex is now D.

    • The unvisited vertices are B and E.

      • The choice of edges are DB: 19 or DE: 16.

      • Choose edge DE.


Example 8 cont d4
Example 8, cont’d

  • Solution, cont’d:

    • The current vertex is now E.

    • The unvisited vertex is B.

      • Choose edge EB.


Example 8 cont d5
Example 8, cont’d

  • Solution, cont’d:

    • The current vertex is now B.

    • There are no unvisited vertices.

      • Return to vertex A using edge BA.


Example 8 cont d6
Example 8, cont’d

  • Solution, cont’d:

    • The Hamiltonian circuit is ACDEBA.

    • Its cost is 70.

      • This is at or near the lowest possible cost.


Cheapest link algorithm
Cheapest-Link Algorithm

  • All edges are acceptable and no edges have been selected.

  • Choose an acceptable edge of smallest weight.


Cheapest link algorithm cont d
Cheapest-Link Algorithm, cont’d

  • If a Hamiltonian circuit is not formed, determine the set of acceptable edges and repeat Step 2.

    • Unacceptable edges are those that either share a vertex with two selected edges or that will close a circuit that is not Hamiltonian.

  • If the selected edges form a Hamiltonian circuit, this is the low-cost Hamiltonian circuit.


Example 91
Example 9

  • Apply the algorithm to approximate the lowest-cost Hamiltonian circuit.


Example 9 cont d
Example 9, cont’d

  • Solution:

    • All edges are acceptable.

    • Select the edge of lowest cost: AC.


Example 9 cont d1
Example 9, cont’d

  • Solution, cont’d:

    • All edges are still acceptable.

    • Select the edge of lowest cost: CD.


Example 9 cont d2
Example 9, cont’d

  • Solution, cont’d:

    • Edges BC,CE, and AD are unacceptable.

    • Select the acceptable edge of lowest cost: AB.


Example 9 cont d3
Example 9, cont’d

  • Solution, cont’d:

    • Edges BC,CE, BD, and AD are unacceptable.

    • Select the acceptable edge of lowest cost: DE.


Example 9 cont d4
Example 9, cont’d

  • Solution, cont’d:

    • The only remaining acceptable edge is BE.

    • The low-cost circuit is complete, with a weight of 70.


6 3 initial problem solution
6.3 Initial Problem Solution

  • An author needs to find a route that will minimize the total distance she must drive between the cities shown below.


Initial problem solution cont d4
Initial Problem Solution, cont’d

  • Imagine a graph in which the vertices represent the cities and the weighted edges represent the distances.

  • This is a Traveling-Salesperson problem, and there are 9! = 362,880 possible Hamiltonian circuits.

    • Of these, 8! = 40,320 circuits start at New Orleans.


Initial problem solution cont d5
Initial Problem Solution, cont’d

  • With such a large number of circuits, it is foolish to try to solve this by hand using the Brute-Force Algorithm.

  • The Cheapest-Link Algorithm will be used to find a low-cost Hamiltonian circuit representing a low-cost trip for the author.

    • Rather than drawing the large graph, view the costs (distances) in the table.


Initial problem solution cont d6
Initial Problem Solution, cont’d

  • Using the algorithm, add acceptable edges one at a time.

    • The first 7 edges added are shown below.


Initial problem solution cont d7
Initial Problem Solution, cont’d

  • The cheapest acceptable edge at this point is the route between Charlotte and Orlando.

  • After that, the route from New Orleans to Orlando must be added to complete the circuit.


Initial problem solution cont d8
Initial Problem Solution, cont’d

  • The approximate least-cost Hamiltonian circuit is shown below.

  • The total cost of the circuit is 2462, so the author will drive 2462 miles if she takes this route on her trip.