Graph Colouring & Tress in Graph Theory

Slides:



Advertisements
Similar presentations
CS 336 March 19, 2012 Tandy Warnow.
Advertisements

Great Theoretical Ideas in Computer Science for Some.
Trees Chapter 11.
Chapter 9 Graphs.
22C:19 Discrete Math Graphs Fall 2014 Sukumar Ghosh.
Review Binary Search Trees Operations on Binary Search Tree
22C:19 Discrete Structures Trees Spring 2014 Sukumar Ghosh.
CompSci 102 Discrete Math for Computer Science April 19, 2012 Prof. Rodger Lecture adapted from Bruce Maggs/Lecture developed at Carnegie Mellon, primarily.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 21: Graphs.
Last time: terminology reminder w Simple graph Vertex = node Edge Degree Weight Neighbours Complete Dual Bipartite Planar Cycle Tree Path Circuit Components.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Lists A list is a finite, ordered sequence of data items. Two Implementations –Arrays –Linked Lists.
Graph Colouring Lecture 20: Nov 25.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
K-Coloring k-coloring: A k-coloring of a graph G is a labeling f: V(G)  S, where |S|=k. The labels are colors; the vertices of one color form a color.
Discrete Mathematics Lecture 9 Alexander Bukharovich New York University.
Let G be a pseudograph with vertex set V, edge set E, and incidence mapping f. Let n be a positive integer. A path of length n between vertex v and vertex.
Graph Theory Topics to be covered:
GRAPHS CSE, POSTECH. Chapter 16 covers the following topics Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component,
Foundations of Discrete Mathematics
Trees and Distance. 2.1 Basic properties Acyclic : a graph with no cycle Forest : acyclic graph Tree : connected acyclic graph Leaf : a vertex of degree.
Tree A connected graph that contains no simple circuits is called a tree. Because a tree cannot have a simple circuit, a tree cannot contain multiple.
1 CS104 : Discrete Structures Chapter V Graph Theory.
 Rooted tree and binary tree  Theorem 5.19: A full binary tree with t leaves contains i=t-1 internal vertices.
5.5.3 Rooted tree and binary tree  Definition 25: A directed graph is a directed tree if the graph is a tree in the underlying undirected graph.  Definition.
Data Structures & Algorithms Graphs
Graph Colouring L09: Oct 10. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including the famous.
Agenda Review: –Planar Graphs Lecture Content:  Concepts of Trees  Spanning Trees  Binary Trees Exercise.
Unit – V Graph theory. Representation of Graphs Graph G (V, E,  ) V Set of vertices ESet of edges  Function that assigns vertices {v, w} to each edge.
Graph Colouring Lecture 20: Nov 25. This Lecture Graph coloring is another important problem in graph theory. It also has many applications, including.
Graph Theory and Applications
GRAPHS. Graph Graph terminology: vertex, edge, adjacent, incident, degree, cycle, path, connected component, spanning tree Types of graphs: undirected,
Graph Theory Unit: 4.
Great Theoretical Ideas in Computer Science for Some.
Chapter 20: Graphs. Objectives In this chapter, you will: – Learn about graphs – Become familiar with the basic terminology of graph theory – Discover.
COMPSCI 102 Introduction to Discrete Mathematics.
Chapter 11. Chapter Summary  Introduction to trees (11.1)  Application of trees (11.2)  Tree traversal (11.3)  Spanning trees (11.4)
Trees.
Graphs. Representations of graphs : undirected graph An undirected graph G have five vertices and seven edges An adjacency-list representation of G The.
Graph Graphs and graph theory can be used to model:
Chapter 5 : Trees.
Great Theoretical Ideas In Computer Science
Graph theory Definitions Trees, cycles, directed graphs.
12. Graphs and Trees 2 Summary
Graph Theory and Algorithm 01
Great Theoretical Ideas in Computer Science
Advanced Algorithms Analysis and Design
CS120 Graphs.
Spanning Trees Longin Jan Latecki Temple University based on slides by
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 10 Trees Slides are adopted from “Discrete.
CSE 421: Introduction to Algorithms
Graphs Chapter 13.
Graphs.
Discrete Math II Howon Kim
Trees L Al-zaid Math1101.
CSE 421: Introduction to Algorithms
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Great Theoretical Ideas In Computer Science
Trees 11.1 Introduction to Trees Dr. Halimah Alshehri.
Graph Algorithms "A charlatan makes obscure what is clear; a thinker makes clear what is obscure. " - Hugh Kingsmill CLRS, Sections 22.2 – 22.4.
Chapter 15 Graph Theory © 2008 Pearson Addison-Wesley.
Text Book: Introduction to algorithms By C L R S
Miniconference on the Mathematics of Computation
Spanning Trees Longin Jan Latecki Temple University based on slides by
Discrete Mathematics for Computer Science
Graphs.
Elementary Graph Algorithms
Concepts of Computation
Presentation transcript:

Graph Colouring & Tress in Graph Theory

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.

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.

Welsh-powell Algorithm for graph colouring.

Find the Chromatic number for Petersen graph

Grpah coloring references https://youtu.be/VuqeI6TMqNk https://youtu.be/G35_wHqyHzM https://youtu.be/3JLEsIGOD68 https://youtu.be/Woz2XewiF_4 https://youtu.be/TvuVnnJQF-A https://youtu.be/CHfljIZYrBg

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.

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. https://www.youtube.com/watch?v=y4RAYQjKb5Y

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.

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.

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.

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.

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

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

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.

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.

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.

Number of tree with 2,3,4 labelled vertices

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.

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.

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.

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.

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?

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.

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.

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.

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.

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.

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

Below tree is Complete Binary Tree

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.

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

Below tree is of height 4 but not balanced

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.

Below tree is a full binary tree.

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.

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.

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

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.

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.

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)

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.

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.

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.

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.

Find all spanning tress of below graph

Algorithms for Finding a Spanning Tree Depth-First search(DFS) https://www.hackerearth.com/practice/algorithms/graphs/depth-first-search/tutorial/ Breadth-First Search(BFS) https://www.hackerearth.com/practice/algorithms/graphs/breadth-first-search/tutorial/

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.

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.

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.

Find DFS and BFS spanning tress for the following fraphs

Find DFS and BFS spanning tress for the following graphs