Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Learning Objectives: Know how to use graphs as models and how to determine efficient paths. Modeling with graphs Euler circuits Degrees of vertices and Euler’s Theorem 1 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Graph properties 1. An edge cannot start and end at the same vertex. (See Figure 7.2) 2 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Graph properties (cont.) 2. The graphs are connected if each pair of vertices can be joined by a sequential collection of edges, a path. 3. The graph in Figure 7.3 is connected. 4. The one in Figure 7.4 is not connected. 3 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Graph properties (cont.) 5. Graphs can be used to represent many situations. (See Figures 7.5 and 7.6) 4 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. A circuit or cycle in a graph is a path that begins and ends at the same vertex. An Euler circuit of Euler cycle is a circuit that traverses each edge of the graph exactly once. 5 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. The degree of a vertex is the number of edges that touch that vertex. Some texts use valence instead of degree. The numbers in Figure 7.11 indicate the degree of each vertex. 6 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Example: The graph in Figure 7.12 shows a simplified air route map. It shows connections that are available between various cities. In the context of this graph, what is the meaning of the degree of a vertex? Find the degree of each of the vertices. 7 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Solution: Because each edge indicates a direct connection between cities, the degree of each vertex is the number of direct flights available from the given city. The degrees of the vertices are: Atlanta: degree 4 Chicago: degree 2 Los Angeles: degree 2 Miami: degree 2 New York: degree 4 8 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Example: Does the air route map in Figure 7.12 allow for a scenic trip that starts and ends at New York and flies along each route exactly once? Is there an Euler circuit for the graph in Figure 7.12? If an Euler circuit exists, use trial and error to find one. Solution: Referring back to the previous example, we see that the degree of each vertex is even. So Euler’s Theorem guarantees the existence of an Euler circuit. Proceeding by trial and error, we find one such route: New York – Miami – Atlanta—N ew Yo r k –Chicago–Atlanta— Los Angeles—New York This route is shown in Figure 7.15. We note that this is not the only correct answer. 9 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Example: Königsberg is an old city that is now part of Russia and has been renamed Kaliningrad. It covers both banks of the Pregel River as well as two islands in the river. The banks and islands were connected by seven bridges, as shown in Figure 7.16. Tradition has it that the people of Königsberg enjoyed walking, and they wanted to figure out how to start at home, go for a walk that crossed each bridge exactly once, and arrive back home. Nobody could figure how to do it. It was Leonhard Euler’s solution of this problem that began the modern theory of graphs. 1. Make a graph that models Königsberg and its seven bridges. 2. Determine whether the desired walking path is possible. 10 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Example (cont.): 11 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Solution: 1. We place a vertex on each bank of the river and on both islands. We connect these vertices by paths across the seven bridges. (see Figure 7.17) We then obtain the graph shown in Figure 7.18 by showing only the vertices and edges we have drawn. 2. The desired walking path would be an Euler circuit for the graph in Figure 7.18. But because this graph has a vertex of odd degree, it has no Euler circuit. 12 Chapter 7 Graph Theory 7.1 Modeling with graphs and finding Euler circuits. Graphs and Euler circuits 1. A graph is a collection of vertices, some (or all) of which are joined by edges. Generally, we consider only connected graphs, and we do not allow edges to start and end at the same vertex. 2. A circuit in a graph is a path (a sequential collection of edges) that begins and ends at the same vertex. An Euler circuit is a circuit that uses each edge exactly once. 3. The degree of a vertex is the number of edges touching it. 4. A connected graph has an Euler circuit precisely when each vertex has even degree. 13 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Learning Objectives: Know how to determine circuits that traverse the vertices efficiently. Making Hamilton circuits The traveling salesman problem The complexity of the traveling salesman problem Nearest-neighbor algorithm The cheapest link algorithm 14 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. A Hamilton circuit in a graph is a circuit that visits each vertex exactly once. 15 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. 16 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Vertices of Degree 2 and Hamilton Circuits If a graph has a vertex of degree 2, then each edge meeting that vertex must be part of any Hamilton circuit. 17 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Example: Figure 7.69 shows hiking trails and points of interest in Yellowstone National Park. We want to find a path that starts and ends at Shoshone Lake and visits each point of interest exactly once. (We want to find a Hamilton circuit.) Either find a Hamilton circuit or explain why no such circuit exists. 18 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Solution: The vertices Grizzly Lake, Mammoth, Norris, and Lewis all have degree 2. Thus in any Hamilton circuit, we must use the hiking paths that touch these vertices. Such a circuit cannot be part of any larger Hamilton circuit, and we conclude that it is not possible to take the desired walking path. 19 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Hamilton Circuits 1. A Hamilton circuit is a circuit that visits each vertex exactly once. 2. There is no set procedure for determining whether Hamilton circuits exist. Here is one helpful observation: If a graph has a vertex of degree 2, then each edge meeting that vertex must be part of any Hamilton circuit. 3. A Hamilton circuit cannot contain a smaller circuit. 20 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Example: The graph in Figure 7.73 shows a delivery map for a trucking firm based in Kansas City. The firm needs a shortest route that will start and end in Kansas City and make stops in Houston, Phoenix, and Portland. That is, the trucking firm needs a solution of the traveling salesman problem for this map. Calculate the mileage for each possible route to find the solution. 21 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Solution: There are six possible routes altogether, but we need to list only three because we gain no new information by looking at the reverse of a route: Kansas City–Houston–Phoenix–Portland–Kansas City: Distance 5179 miles Kansas City–Phoenix–Houston–Portland–Kansas City: Distance 6722 miles Kansas City–Phoenix–Portland–Houston–Kansas City: Distance 5641miles The shortest route of 5179 miles is the first one listed. 22 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. In a complete graph, each vertex is connected to every other vertex by an edge. The traveling salesman problem applies to complete graphs for which a distance is assigned to each edge. The problem is to find a shortest Hamilton circuit. 23 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. The nearest-neighbor algorithm constructs a Hamilton circuit in a complete graph by starting at a vertex. At each step, it travels to the nearest vertex not already visited (except at the final step, where it returns to the starting point). If there are two or more vertices equally nearby, any one of them may be selected. 24 Chapter 7 Graph Theory 7.2 Hamilton circuits and traveling salesmen: Efficient routes. Example: The local school board needs to visit the high school, middle school, primary school, and kindergarten each day. A map illustrating the office and schools, along with distances in miles, is shown in Figure 7.80. 1. Find a shortest path by listing all possible routes starting and ending at the office. 2. Use the nearest-neighbor algorithm starting at the office to approximate a shortest Hamilton Circuit.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages33 Page
-
File Size-