Planer graph, graph coloring, tree and their application

AKHILESHKUMAR348286 7 views 33 slides Sep 09, 2024
Slide 1
Slide 1 of 33
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33

About This Presentation

planer graph


Slide Content

Module 9 planar graphs graph coloring trees and tree applications tree traversal minimum spanning trees

Module 9 planar graphs

definition and examples A graph is called planar if it can be drawn in the plane without edges crossing. Such a drawing is called a planar representation of the graph. Graph of   Planar representation of   Graph of   Planar representation of  

euler’s formula Let be a connected planar simple graph with edges and vertices. Let be number of regions in a planar representation of , then .   Graph of   has edges and vertices. According to Euler’s formula: .   Planar representation of           Graph of   has edges and vertices. According to Euler’s formula:   Planar representation of              

corollaries to euler’s formula Corollary 1: If is a connected planar simple graph with edges and vertices, where , then .   Corollary 2: If is a connected planar simple graph, then has a vertex of degree not exceeding .   Corollary 3: If a connected planar simple graph has edges and vertices with and no circuits of length three, then .   Graph of   Graph of   has vertices and edges. However, from Corollary 1 is not satisfied since . Therefore, is nonplanar.   has no circuits of length three so Corollary 3 can be used. has vertices and edges. However, . Therefore, is nonplanar.   In general, is nonplanar for .  

Module 9 graph coloring

definitions A coloring of a simple graph is the assignment of a color to each vertex of the graph so that no two adjacent vertices are assigned the same color. Map 1 of regions Dual graph of Map 1 A dual graph is a graph formed from a map where each region is represented by a vertex. Edges connect two vertices if the regions represented by those vertices have a common border. Two regions that touch at only one point are not considered adjacent. Note: Any map in the plane has a planar dual graph. Map 2 of regions Dual graph of Map 2 A graph can be colored by assigning a different color to each of its vertices. However, most colorings can be found in a way that uses fewer colors than the number of vertices. The chromatic number of a graph is the least number of colors needed for a coloring of the graph. The chromatic number of a graph is denoted by .  

four color theorem The chromatic number of a planar graph is no great than four. What is the chromatic number of this graph? Notice the chromatic number must be at least three because and must be different colors.   Since is blue and is green, must be red.   Since is blue and is red, must be green.   By a similar argument, must be blue and must be red.   What happens to the chromatic number if we add an edge between and ?   Everything remains the same except that can no longer be red. Since it also can’t be green or blue, we need a fourth color.  

Examples             What are the chromatic numbers of these special types of graphs?     for is nonplanar so the Four Color Theorem does not apply.   In general, .       Recall, is bipartite so by definition, .       In general, if is an even positive integer with and if is an odd positive integer with .  

Module 9 trees and tree applications

trees A tree is a connected undirected graph with no simple circuits Note: This implies a tree cannot contain multiple edges or loops. So any tree must be a simple graph Which of these graphs are trees? and are trees because both are connected with no simple circuits   is not a tree because is a simple circuit   is not a tree because it is not connected   Your turn : Which of these graphs are trees? Answer : and   Recall: A simple circuit does not contain the same edge more than once

rooted trees A rooted tree is a tree in which one vertex has been designated as the root and every edge is directed away from the root. Any tree can be changed to a rooted tree by choosing one vertex as the root. Suppose is a rooted tree. If is a vertex in other than the root, the parent of is the unique vertex such that there is a directed edge from to and is called a child of .   is the parent of and is a child of   Vertices with the same parent are called siblings. and are siblings   The ancestors of a vertex other than the root are the vertices in the path from the root to this vertex, excluding the vertex itself and including the root. The ancestors of are and in the 1 st rooted tree and , , and in the 2 nd rooted tree.   The descendants of a vertex are those vertices that have as an ancestor.   The descendants of in the 1 st rooted tree are and . The descendants of in the 2 nd rooted tree are and .  

More terminology A vertex of a rooted tree is called a leaf if it has no children. The leaves are and   Vertices that have children are called internal vertices. The internal vertices are and   If is a vertex in a tree, the subtree with as its root is the subgraph of the tree consisting of and its descendants and all edges incident to these descendants.   The subtree of rooted at  

binary Trees A rooted tree is called an ary tree if every internal vertex has no more than children. The tree is called a full ary tree if every internal vertex has exactly children. Any ary tree with is called a binary tree.   is a full binary tree since each internal vertex has two children   is a full ary tree since each internal vertex has three children   is a full ary tree since each internal vertex has five children   is not a full ary tree because some of its internal vertices have two children and others have three. would simply be a ary tree  

ordered rooted trees An ordered rooted tree is a rooted tree where the children of each internal vertex are ordered. Ordered rooted trees are drawn so that the children of each internal vertex are shown in order from left to right. Note: A representation of a rooted tree in the conventional way naturally determines an ordering for its edges. Such orderings of edges will be used without explicitly mentioning an ordered tree is being considered. In a(n) (ordered) binary tree, if an internal vertex has two children, the 1 st child is called the left child and the 2 nd child is called the right child. The left child of is and the right child of is   The tree rooted at the left child of a vertex is called the left subtree of this vertex and the tree rooted at the right child of a vertex is called the right subtree of the vertex. The left subtree of   The right subtree of  

properties of trees A tree with vertices has edges.   Recall: An internal vertex is a vertex that has children, and a leaf is a vertex with no children. A full ary tree with vertices has internal vertices and leaves.   A full ary tree with internal vertices has vertices and leaves.   A full ary tree with leaves has vertices and internal vertices.   How many edges does a full binary tree with internal vertices have?   With and , there are vertices. Thus, there are edges.  

binary search trees A binary search tree is a binary tree in which each child of a vertex is designated as a right or left child. No vertex has more than one right child or left child and each vertex is labeled with a key, which is one of the items from a list. Vertices are assigned keys so that the key of a vertex is both larger than the keys of all vertices in its left subtree and smaller than the keys of all vertices in its right subtree. Suppose we wish to implement a searching algorithm that finds items efficiently when the items are totally ordered. This can be done through the use of a binary search tree. Step 1: Start with a tree containing one vertex – the root. The first item in the list is assigned as the key of the root. Step 2: Compare the 2 nd item in the list with the key of the root. If the item is less than the key of the root, create a left child. Otherwise, create a right child. Step 3: Compare the next item in the list with the keys of vertices already in the tree starting at the root and moving left if the item is less than the key of the respective vertex, or right if the item is greater than the key of the respective vertex. Add the vertex and the key. Step 4: Repeat Step 3 until the list of items is exhausted.

Example Form a binary search tree for the list using alphabetical order.   Step 1: Create the root with the key   Step 2: Since create a right child.   Step 3: Since create a left child   Step 4: so move to the right and compare to   Step 5: and   Step 6: and   Step 7: , , and   Step 8: and  

the game of nim Game trees can be used to model certain games. The vertices of these trees represent the positions that a game can be in as it progresses. The game of nim begins with piles of stones. Two players take turns removing one or more stones from one of the piles without removing all of the stones left. A player without a legal move loses. Suppose the game begins with 3 piles of stones 2, 2, and 1. Player 1 has 3 options: (a) remove 1 stone from pile 3, (b) remove 1 stone from pile 2 (or pile 1), or (c) remove 2 stones from pile 1 or pile 2. Suppose player 1 goes with option (b). Then player 2 has 3 options: (a) remove 1 stone from pile 2 or pile 3, (b) remove 2 stones from pile 1, or (c) remove 1 stone from pile 1. Suppose player 2 removes 1 stone from pile 3. Then player 1 has 3 options: (a) remove one stone from pile 2, (b) remove 1 stone from pile 1, or (c) remove 2 stones from pile 1. If player 1 chooses options (a) or (b), player 2 will win by removing the appropriate stone. If player 1 chooses option (c), then player 1 will win. Challenge: Create a game tree for the game of nim with 3 piles of stones. There is pile 1 has 2 stones and piles 2 and 3 have 3 stones.

Module 9 tree traversal

preorder traversal Let be an ordered rooted tree with root . If consists only of , then is the preorder traversal of . Otherwise, suppose that are the subtrees at from left to right in . The preorder traversal begins by visiting . It continues traversing in preorder, then in preorder, and so on, until is traversed in preorder.   In which order does a preorder traversal visit the vertices in this ordered rooted tree? In the first step we visit the root then the subtree with root , then , then the subtree with root .   Next focusing on the subtree with root and the subtree with root , we repeat the approach. This results in a subtree with root and a subtree with root .   Focusing on the subtree with root and the subtree with root , we are now left with only one more subtree.   This last step results in a preorder traversal of the original tree.

inorder traversal Let be an ordered rooted tree with root . If consists only of , then is the inorder traversal of . Otherwise, suppose that are the subtrees at from left to right. The inorder traversal begins by traversing in inorder, then visiting . It continues by traversing in inorder , then in inorder ,…, and finally in inorder .   In which order does an inorder traversal visit the vertices in this ordered rooted tree? Begin by visiting the leftmost subtree, then visit , then visit other subtrees from left to right.   Next we repeat the process starting with the leftmost subtree and working left to right. Begin with then the root , then we’re left with one more subtree rooted at . The subtree rooted at from the previous step becomes .   This last step results in the inorder transversal of the original tree.

postorder traversal Let be an ordered rooted tree with root . If consists only of , then is the postorder traversal of . Otherwise, suppose that are the subtrees at from left to right. The postorder traversal begins by traversing in postorder , then in postorder ,…, then in postorder , and ends by visiting .   In which order does a postorder traversal visit the vertices in this ordered rooted tree? Begin by visiting subtrees left to right, then visit the root .   Next visit each subtree from the previous step, then visit the root of each of those subtrees as you traverse. Continue the process visiting the subtrees from the previous step from left to right, then visit the root of each of those subtrees as you traverse. This last step results in the postorder traversal of the original tree.

comparison Preorder traversal Inorder traversal Postorder transversal

Module 9 minimum spanning trees

spanning trees Let be a simple tree. A spanning tree of is a subgraph of that is a tree containing every vertex of .   Road system in Maine Spanning tree of roads to plow The highway department wants to plow the fewest roads so that there is always a cleared road between any two towns.

example Find a spanning tree of the graph shown This graph is not a tree because it contains simple circuits Remove edge to eliminate one of the simple circuits   Remove edge to eliminate another simple circuit   Remove edge to produce a simple graph with no simple circuits   Other spanning trees of the original graph

depth-first search Arbitrarily start at a vertex, say .   Build a path by successively adding edges incident with vertices not already in the path, as long as this is possible. This creates a path .   Use a depth-first search to find a spanning tree for the graph shown. Backtrack to . There is not path beginning at containing vertices not already visited, so backtrack to and form the path .   Backtrack to and then to . From build the path .   Backtrack to and form the path .  

breadth-first search Use a breadth-first search to find a spanning tree for the graph shown. Arbitrarily start at a vertex, say .   Add edges incident with all vertices adjacent to , so edges from to and are added. These edges are at level .   Next add the edges from these vertices to adjacent vertices not already in the tree. These edges are at level .   Next add edges from these vertices to adjacent vertices not already in the tree.

minimum cost spanning trees A minimum (cost) spanning tree in a connected weighted graph is a spanning tree that has the smallest possible sum of weights of its edges Weighted graph showing monthly lease costs for lines in a computer network

Kruskal’s algorithm 1. Order the edges in ascending order based on their weights 2. Repeatedly select unused edges provided the edge will not create a circuit 3. Repeat until a spanning tree is formed   Adding creates a circuit   All vertices have been used                       total  

prim’s algorithm 1. Select an edge with minimal weight 2. Select an edge of minimum weight incident to a vertex in the tree that does not create a simple circuit. 3. Repeat step 2 until a spanning tree is found                       total   Compare to Kruskal’s algorithm                       total  

Questions?
Tags