Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graph Colouring & Tress in Graph Theory

Similar presentations


Presentation on theme: "Graph Colouring & Tress in Graph Theory"— Presentation transcript:

1 Graph Colouring & Tress in Graph Theory

2 Chromatic numbers Graph colouring Problem
Colouring vertices of a graph such that no adjacent vertices have same colour.(Proper colouring). If n colours are required.. We say that graph is n-colourable. Minimum number of colours required such that no adjacent vertices have same colour is called Chromatic number of a graph. If k is minimum number of colours then the graph is k-chromatic.

3 The chromatic number of a isolated vertex is one.
The chromatic number of path graph Pn is 2 for n>=2. The chromatic number of a cycle graph Cnis 2 when n is even and 3 when n is odd. Chromatic number of a complete bipartite graph Km,nis 2. Every Bipartite graph is 2-colourable. Chromatic number of a complete graph Kn is n.

4 Welsh-powell Algorithm for graph colouring.

5

6

7 Find the Chromatic number for Petersen graph

8 Grpah coloring references

9 Graph colouring Applications
Register Allocation: A compiler is a computer program that translates one computer language into another. To improve the execution time of the resulting code, one of the techniques of compiler optimization is register allocation, where the most frequently used values of the compiled program are kept in the fast processor registers. Ideally, values are assigned to registers so that they can all reside in the registers when they are used. The approach to this problem is to model it as a graph coloring problem. The compiler constructs an interference graph, where vertices are variables and an edge connects two vertices if they are needed at the same time. If the graph can be colored with k colors then any set of variables needed at the same time can be stored in at most k registers.

10 The problem of coloring a graph arises in many practical areas such as pattern matching, sports scheduling, designing seating plans, exam timetabling, the scheduling of taxis, and solving Sudoku puzzles.

11 Aircraft Scheduling: Assuming that there are k Aircrafts and they have to be assigned n flights.
The ith flight should be during the time interval (ai,bi). If two flights overlap, then the same aircraft cannot be assigned to both the flights. The vertices of the graph correspond to the flights. Two vertices will be connected .If the corresponding time intervals overlap. Therefore, the graph is an interval graph that can be colored optimally in polynomial time.

12 GSM Mobile Phone Networks: GSM (Groups special Mobile) is a mobile phone Network where the geographical area of this network is divided in to hexagonal regions or cells. Each cell has a communication tower which connects with mobilephones within the cells. All mobile phones connect to the GSM network by searching for cells in the neighbors. Since GSM operate only in four different frequency ranges, it is clear by the concept of graph theory that only four colors can be usedto color the cellular regions. These four diffrent colors are used for proper coloring of the regions. Therefore, the vertex coloring algorithm may be used to assign at most four different frequencies for any GSM mobile phone net work.

13 Four color theorem In mathematics, the four color theorem, or the four color map theorem, states that, given any separation of a plane into contiguousregions, producing a figure called a map, no more than four colors are required to color the regions of the map so that no two adjacent regions have the same color.

14

15

16 Trees A graph G is called a Tree if it is connected and has no cycles.(Connected Acyclic) That means, a tree has to be a simple graph, because loops and parallel edges forms cycles.

17 Examples Each of the above trees contains at least two pendant vertices, called leafs.

18 Below graphs are not trees
Each component of the second graph is a tree. Such a graph is called Forest.

19 Properties of Trees In a tree there is one and only one path between every pair if vertices. Proof: Let T be a tree. Then T is a Connected Simple Graph. Since T is connected, there must be at least one path between every two vertices. If there are two path between every pair of vertices of T, then union of the paths will become a cycle, and T cannot be a tree.Thus, between every pair of vertices in a tree there must exist one and only one path.

20 Properties of Trees If in graph G there is one and only one path between every pair of vertices, then G is a tree. A tree with n vertices has n-1 edges. Any connected graph with n vertices and n-1 edges is a Tree. A graph with n vertices and n-1 edges need not be a tree. A graph with n vertices is a tree, iff it is connected and has n-1 edges.

21 Properties of Trees Cayley's formula :In mathematics, Cayley's formula is a result in graph theory named after Arthur Cayley. It states that for every positive integer n, the number of trees on n labeled vertices is  nn-2.

22 Number of tree with 2,3,4 labelled vertices

23 Minimally connected Graphs
A Connected graph is said to be minimally connected if the removal of any one edge from it, disconnects the graph. Following graphs are minimally connected. A Connected Graph is a tree if and only if it is minimally connected.

24 Properties of Trees Complete graph Kn is not a tree when n>2
Complete bipartite graph Kr,s is not a tree when r>=2.

25 Properties of Trees Let F be a forest with k components(trees). If n is the number of vertices and m is the number of edges in F, prove that n=m+k. Proof: Let H1,H2,H3…..HK be the components of F. Since each component is a tree, if ni is the number of vertices in Hi and mi is the number of edges in Hi then we have mi= ni-1 for i=1,2,3,…..k That is m1+m2+m3+……mk= (n1-1)+(n2-1)+….(nk-k) = n1+n2+……+nk-k m1+m2+m3+….mk=m and n1+n2+……+nk-k=n Therefore m=n-k or n=m+k.

26 Properties of Trees In a tree with two or more vertices, there are at least two leaves(pendant vertices). If a tree has exactly two pendant vertices, the degree of every other vertex is two. In a tree, if the degree of every non-pendant vertex is 3, the number of vertices in the tree is even.

27 Suppose that a Tree has two vertices of degree 2, four vertices of degree 3 and three vertices of degree 4. find the number of pendant vertices in T. Let F1=(V1,E1) be a forest of seven trees where |E1|=40. what is |V1|? Let F2=(V2,E2) is a forest with |V2|=62 and |E2|=51. How many tress determine F2?

28 Rooted Trees A Directed tree is a directed graph whose underlying graph is a tree. A directed Tree T is called a Rooted Tree if it contains a unique vertex called the Root, whose in-degree is equal to zero and in-degree of all other vertices of T are equal to 1.

29 Examples Both are directed trees. But (a) is not rooted tree and (b) is a rooted Tree. In a Rooted tree , From the root we draw the tree downward from upper level to lower level ,so that arrows can be dropped.

30 A vertex v of a rooted tree is said to be at the k-th level or has level number k if the path form root to v is of length k.

31 V1 and v2 at Level 1 V3 and v4 at Level 2 V5 ,v6 and v7 at Level 3 V8 and v9 at Level 4 Except Leaf nodes all other vertices are called Internal vertices.

32 Binary tree A rooted Tree T is called Binary Tree if every internal vertex of T is of out-degree 1 or 2.that is every internal vertex has at most two children. A rooted tree T is called Complete Binary tree if every internal vertex of T is of our-degree 2.that every internal vertex has two children.

33 Below tree is a binary tree, but not complete Binary tree.

34 Below tree is Complete Binary Tree

35 Balanced Tree If T is rooted tree and h is the largest level number achieved by a leaf of T, then T is said to have height h. A rooted tree of height h is said to be balanced if the level number of every leaf is h or h-1.

36 The tree shown below is of height 4 and balanced too.

37 Below tree is of height 4 but not balanced

38 Full Binary Tree Let T be a complete Binary Tree of height h. then T is called a full binary tree if all the leaves in T are at level h. Below tree is not a full binary tree.

39 Below tree is a full binary tree.

40 m-ary Tree A rooted tree is called an m-ary tree if every internal vertex of T is of out-degree<=m. that is if every vertex if T has at most m children. A rooted tree is called a complete m-ary tree if every internal vertex of T has exactly m children.

41 First Theorem of the Diagraph theory
In every Digraph D, the sum of out-degrees of all vertices is equal to the sum of in-degrees of all vertices, each sum being equal to the number of edges in D.

42 Procedure to solve Total number of vertices= leaf+internal
Find sum of out-degrees(Every leaf has out degree 0) Find sum of indegrees(indegree of root is zero and in degree of remaining vertices is 1) Use First Theorem of the Diagraph theory

43 Problems Find the number of vertices and the number of leaves in a complete binary tree having 10 internal vertices. The Computer lab of school has 10 computers that are to be connected to a wall socket that has 2 outlets. Connections are made by using extension cords that have 2 outlets each. Find the least number of cords needed to get these computers set up for use.

44 Consider the complete binary tree having the wall socket as the root, computers as the leaves, and the internal vertices, other than the root as extension cords.

45 A complete binary tree has 20 leaves. Find the number of vertices? (39)
Find the number of vertices in a complete binary tree if it has 29 vertices.(15)

46 Spanning Trees Let G be a connected graph
A subgraph T of G is called a Spanning tree of G if T is a tree T contains all vertices of G In other words, a spanning tree is a spanning subgraph that is also tree. Also called Maximal tree since it contains all the vertices of G. The edges of spanning tree are called branches.

47 If T is spanning tree of a graph G,then the edges of G that are not in T are called Chords of G w.r.t. T. The set of all chords of G is the Compleimient of T in G. This set is called Chord-set or cotree.

48

49 Spanning tree is defined only for connected graph.
In a disconnected graph of n vertices we cannot find a spanning tree with n vertices. But each component of disconnected graph can have spanning tree. These spanning trees together form a spanning forest. Every tree is a spanning tree to itself.

50 A connected graph can have more than one spanning tree
A connected graph can have more than one spanning tree. The following are the spanning trees of K3.

51 Find all spanning tress of below graph

52

53 Algorithms for Finding a Spanning Tree
Depth-First search(DFS) Breadth-First Search(BFS)

54 Difference between DFS and BFS
When we apply these algorithms on a Graph, we can see following types of nodes. Non-Visited nodes: These nodes not yet visited. Visited nodes: These nodes are visited. Explored nodes: A node is said to be explored when it was visited and all nodes which are connected (adjacent) to that node also visited.

55 BFS DFS BFS visit nodes level by level in Graph. DFS visit nodes of graph depth wise A node is fully explored before any other can begin. Exploration of a node is suspended as soon as another unexplored is found. Uses Queue data structure to store Un-explored nodes. Uses stack data structure to store Un-explored nodes. BFS is slower and require more memory. DFS is faster and require less memory. Finding all connected components in a graph. Finding the shortest path between two nodes. Finding all nodes within one connected component. Testing a graph for bipartiteness. Finding connected components. Solving puzzles such as maze. Finding strongly connected components. Finding articulation points (cut vertices) of the graph.

56

57

58

59 Find DFS and BFS spanning tress for the following fraphs
If the order of the vertices is given as 1) a,b,c,d,e,f,g,h 2)h,g,f,e,d,c,b,a.

60 Find DFS and BFS spanning tress for the following fraphs

61 Find DFS and BFS spanning tress for the following graphs


Download ppt "Graph Colouring & Tress in Graph Theory"

Similar presentations


Ads by Google