1 / 51

SEVENTH EDITION and EXPANDED SEVENTH EDITION

SEVENTH EDITION and EXPANDED SEVENTH EDITION. Chapter 14. Graph Theory. 14.1. Graphs, Paths and Circuits. Loop. A. B. Not a vertex. Edge. C. D. Vertex. Definitions.

dobson
Download Presentation

SEVENTH EDITION and EXPANDED SEVENTH EDITION

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SEVENTH EDITION and EXPANDED SEVENTH EDITION

  2. Chapter 14 Graph Theory

  3. 14.1 Graphs, Paths and Circuits

  4. Loop A B Not a vertex Edge C D Vertex Definitions • A graph is a finite set of points called vertices (singular form is vertex) connected by line segments (not necessarily straight) called edges. • Loop is an edge that connects a vertex to itself.

  5. The map shows the states that make up part of the Midwest states from Weather Underground, Inc. Construct a graph to show the states that share a common border. Michigan Ohio Indiana West Virginia Kentucky Example: Map

  6. Solution • Each vertex will represent one of the states. • If two states share a common border, connect the respective vertices with an edge.

  7. MI Michigan IN OH Ohio Indiana WV KY West Virginia Kentucky Solution continued

  8. The degree of a vertex is the number of edges that connect to that vertex. A vertex with an even number of edges connected to it is an even vertex. A vertex with an odd number of edges connected to it is an odd vertex. MI, OH, and WV are even vertices IN, KY are odd vertices MI IN OH WV KY Definitions

  9. A path is a sequence of adjacent vertices and edges connecting them. C, D, A, B is an example of a path. A circuit is a path that begins and ends at the same vertex. A, C, B, D, A forms a circuit. B A E D C Definitions

  10. H B C G A D K J Definitions • A graph is connected if, for any two vertices in the graph, there is a path that connects them. • Examples of disconnected graphs.

  11. bridge bridge H B C G A D K J Definitions continued • A bridge is an edge that if removed from a connected graph would create a disconnected graph.

  12. 14.2 Euler Paths and Euler Circuits

  13. Definitions • An Euler path is a path that passes through each edge of a graph exactly one time. • An Euler circuit is a circuit that passes through each edge of a graph exactly one time. • The difference between an Euler path and an Euler circuit is that an Euler circuit must start and end at the same vertex.

  14. Euler path Euler circuit Examples

  15. B A C B C A D D E Example: Euler Path and Circuits • For the graphs shown, determine if an Euler path, an Euler circuit, neither, or both exist. The graph has an Euler path but it does not have an Euler circuit. One Euler path is E, C, B, E, D, B, A, D. Each path must begin or end at vertex D or E. The graph has many Euler circuits, each of which is also an Euler path. This graph has no odd vertices. One example is A, D, B, C, D, B, A.

  16. Euler’s Theorem • For a connected graph, the following statements are true: • 1. A graph with no odd vertices (all even vertices) has at least one Euler path, which is also an Euler circuit. An Euler circuit can be started at any vertex and it will end at the same vertex. • 2. A graph with exactly two odd vertices has at least one Euler path but not Euler circuits. Each Euler path must begin at one of the two odd vertices, and it will end at the other odd vertex. • 3. A graph with more than two odd vertices has neither an Euler path nor an Euler circuit.

  17. Example: Using Euler’s Theorem • Use Euler’s theorem to determine whether an Euler path or an Euler circuit exists in the figures shown from the previous example.

  18. B A C D Example: Using Euler’s Theorem continued • The graph has no odd vertices (all vertices are even). According to item 1, at least one Euler circuit exists. An Euler circuit can be determined by starting at any vertex. The Euler circuit will end at the vertex from which is started. Remember that each Euler circuit is also an Euler path.

  19. B C A D E Example: Using Euler’s Theorem continued • There are 3 even vertices (A, B, C) and two odd vertices (D, E). Based on item 2, we conclude that since there are exactly two odd vertices, at least one Euler path exists but no Euler circuits exists. Each Euler path must begin at one of the odd vertices and end at the other odd vertex.

  20. Example • In section 14.1, example 1, we discussed some of the states that make up the Midwest region of the weather map from Weather Underground. We drew a graph that showed the states that share a common border. One of the researchers wants to visit each state within the mapped region. To plan the most efficient trip, the researcher wishes to travel between these states and cross each common state border exactly one time. • a) Is it possible to travel among the states and cross each common state border exactly one time? • b) If it is possible, can he start and end in the same state?

  21. MI IN OH WV KY Solution • We are looking for an Euler path, you must use each edge exactly one time. According to item 2, the graph has at least one Euler path but no Euler circuits. Therefore, yes, it is possible to travel among these states and cross each common border exactly one time. • There is not an Euler circuit, so the researcher cannot start and end in the same state.

  22. Fleury’s Algorithm • To determine an Euler path or an Euler circuit: • 1. Use Euler’s theorem to determine whether an Euler path or an Euler circuit exists. If one exists, proceed with steps 2-5. • 2. If the graph has no odd vertices (therefore has an Euler circuit, which is also an Euler path), choose any vertex as the starting point. If the graph has exactly two odd vertices (therefore has only an Euler path), choose one of the two odd vertices as the starting point.

  23. Fleury’s Algorithm continued • 3. Begin to trace the edges as you move through the graph. Number the edges as you trace them. Since you can’t trace any edges twice in Euler paths and Euler circuits, once an edge is traced consider it “invisible.” • 4. When faced with a choice of edges to trace, if possible, choose an edge that is not a bridge (i.e., don’t create a disconnected graph with your choice of edges). • 5. Continue until each edge of the entire graph has been traced once.

  24. B A C F D G E Example • Use Fluery’s algorithm to determine an Euler circuit. • There is at least one Euler circuit since there are no odd vertices. • Start at any vertex to determine an Euler circuit.

  25. Start at C. Choose either CB or CD. Continue to trace from vertex to vertex around the outside of the graph. start here 10 6 9 1 5 7 B 4 A C 8 2 3 F D G E Example continued

  26. 14.3 Hamilton Paths and Hamilton Circuits

  27. Definitions • A Hamilton path is a path that contains each vertex of a graph exactly once. • A Hamilton circuit is a path that begins and ends at the same vertex and passes through all other vertices of the graph exactly one time.

  28. Graph (a) shown has Hamilton path A, B, C, E, D. The graph also has Hamilton path C, B, A, D, E. Can you find some others? Graph (b) shown has Hamilton path A, B, C, F, H, E, G, D. The graph also has Hamilton path G, D, E, H, F, C, B, A. Can you find some others? Example: Hamilton Path

  29. Graph (a) shown has Hamilton circuit A, B, D, G, E, H, F, C, A. A Hamilton circuit starts and ends at the same vertex. Graph (b) shown has Hamilton circuit A, B, C, E, D,A. Can you find another? Example: Hamilton Circuit

  30. Definition • A complete graph is a graph that has an edge between each pair of its vertices.

  31. B C A D G E F Example: Finding Hamilton Circuits • Determine a Hamilton circuit for the complete graph shown. • One solution is A, G, F, E, C, D, B, A

  32. Number of Unique Hamilton Circuits in a Complete Graph • The number of unique Hamilton circuits in a complete graph with n vertices is (n 1)! where (n  1)! = (n  1)(n  2)(n  3)…(3)(2)(1)

  33. Example: Number of Hamilton Circuits • How many unique Hamilton circuits are there in a complete graph with the following number of vertices? • a) 4 b) 9 • a) 4 = (4  1)! = 4•3•2•1 = 24 • b) 9 = (9  1)! = 8•7•6•5•4•3•2•1 = 40,320

  34. The Brute Force Method of Solving Traveling Salesman Problems • To determine the optimal solution: • 1. Represent the problem with a complete, weighted graph. • 2. List all possible Hamilton circuits for this graph. • 3. Determine the cost (or distance) associated with each of these Hamilton circuits. • 4. The Hamilton circuit with the lowest (or shortest distance) is the optimal solution.

  35. Find a minimum Hamilton circuit for the complete, weighted graph shown. List all the Hamilton circuits. Since there are 4 vertices there are (4  1)! = 3! = 6 possible circuits. 6 B A 2 8 2 12 D C 6 Example: Brute Force Method

  36. Circuit First Leg Second Leg Third Leg Fourth Leg Total A, B, C, D, A 6 12 6 2 26 A, B, D, C, A 6 8 6 2 22 A, C, B, D, A 2 12 8 2 24 6 B A A, C, D, B, A 2 6 8 6 22 2 8 A, D, B, C, A 2 8 12 2 24 2 12 A, D, C, B, A 2 6 12 6 26 D C 6 Example: Brute Force Method continued The minimum amount for the graph would be 22.

  37. Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem • To approximate a optimal solution: • 1. Represent the problem with a complete, weighted graph. • 2. Identify the starting vertex. • 3. Of all the edges attached to the starting vertex, choose the edge that has the smallest weight. This edge is generally either the shortest distance or the lowest cost. Travel along this edge to the second vertex.

  38. Nearest Neighbor Method of Determining an Approximate Solution to a Traveling Salesman Problem continued • 4. At the second vertex, choose the edge that has the smallest weight that does not lead to a vertex already visited. Travel along this edge to the third vertex. • 5. Continue this process, each time moving along the edge with the smallest weight until all vertices are visited. • 6. Travel back to the original vertex.

  39. Example: Nearest Neighbor • An appliance repair man must repair four appliances at the locations shown in the graph. The estimated travel time (in minutes) is shown between the four locations. The repair man wants to visit the four locations in an order that takes the least amount of time. Use the nearest neighbor algorithm to find an approximate solution to the problem.

  40. Choose a starting vertex. Let’s choose vertex A. Choose the edge that has the smallest weight. Either AD or AB, lets choose AD (9). At D choose the edge that has the smallest weight DE (5). start here A 8 18 8 13 3 B E 7 7 9 4 2nd vertex D C 6 Example: Nearest Neighbor continued

  41. Continue moving along the edge with the smallest weight. Circuit would be: A, D, E, B, C, A 8 + 4 + 3 + 9 + 13 = 37 This route would take about 37 minutes. start here A 8 18 8 13 3 B E 7 7 9 4 2nd vertex D C 6 Example: Nearest Neighbor continued

  42. Starting Vertex Circuit Total Weight B B, E, D, C, A, B 3 + 4 + 6 + 13 + 8 = 34 C C, D, E, B, A, C 6 + 4 + 3 + 8 + 13 = 34 D D, E, B, A, C, D 4 + 3 + 8 + 13 + 6 = 34 E E, B, D, C, A, E 3 + 9 + 6 + 13 + 18 = 49 Example: Nearest Neighbor continued • Other circuits and weights.

  43. 14.4 Trees

  44. Definitions • A tree is a connected graph in which each edge is a bridge. • A spanning tree is a tree that is created from another graph by removing edges while still maintaining a path to each vertex.

  45. Graphs that are trees. Graph that are not trees. Examples

  46. F H E B A G C D F H F H E E B B A A G C D G C D Example: Determining Spanning Trees • Determine two different spanning trees for the graph shown.

  47. Minimum-cost spanning tree • A minimum cost spanning tree is the least expensive spanning tree of all spanning trees under consideration.

  48. Kruskal’s Algorithm • To construct the minimum-cost spanning tree from a weighted graph: • 1. Select the lowest-cost edge on the graph. • 2. Select the next lowest-cost edge that does not form a circuit with the first edge. • 3. Select the next lowest-cost edge that does not form a circuit with the previously selected edges. • 4. Continue selecting the lowest-cost edges that doe not form circuits with the previously selected edges. • 5. When a spanning tree is complete, you have the minimum-cost spanning tree.

  49. A C D 4 22 12 10 17 E B 5 14 11 18 G 22 F Example: Kruskal’s Algorithm • Use Kruskal’s algorithm to determine the minimum spanning tree for the weighted graph shown. The numbers along the edges represent dollars.

  50. Pick the lowest-cost edge of the graph, edge CD which is $4. Next we select the next lowest-cost edge that does not form a circuit, we select edge CG which is $5. A C D 4 22 12 10 17 E B 5 14 11 18 G 22 F Solution

More Related