1.48k likes | 1.66k Views
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.
E N D
A Mathematical View of Our World 1st ed. Parks, Musser, Trimpe, Maurer, and Maurer
Chapter 6 Routes and Networks
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 • 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 • 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 • 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 • 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 • The three graphs shown are equivalent.
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 • 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 • Solution: The vertices represent the cities, and the edges represent the roads.
Adjacent Vertices • Two vertices are called adjacent vertices if there is an edge connecting them.
Example 3 • List the pairs of adjacent vertices in the graph.
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: 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 • 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 • Solution: Two possible graphs are shown below.
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 • 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 • 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 • 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 • 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 • 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 • 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 • 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 • 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 • 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 • 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 • Solution 2: The graph is disconnected because, for example, there is no path between vertex A and vertex G.
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 • 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 • 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’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 • 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 • 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 • 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 • 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’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.
Question: Does the graph have an Euler circuit, an Euler path, or neither? a. Euler circuit b. Euler path only c. neither
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 • 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 • 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 • 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’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 • Use Fleury’s Algorithm to find an Euler circuit for the graph. • Possible Final 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 • 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.2Network Problems • Goals • Study weighted graphs • Study spanning trees • Study minimal spanning trees • Use Kruskal’s algorithm
6.2 Initial Problem • Walkways need to be built between the buildings on the campus pictured at right.
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.