Presentation is loading. Please wait.

Presentation is loading. Please wait.

Graph Coloring Solution in a Deterministic Machine The deterministic solution to coloring problem uses these steps to assign colors to vertices: 1- Given.

Similar presentations


Presentation on theme: "Graph Coloring Solution in a Deterministic Machine The deterministic solution to coloring problem uses these steps to assign colors to vertices: 1- Given."— Presentation transcript:

1 Graph Coloring Solution in a Deterministic Machine The deterministic solution to coloring problem uses these steps to assign colors to vertices: 1- Given a Graph G=(V, E) and Set of Colors C = { C 1,C 2,C 3,C 4...C n }. Sort the vertices in non-decreasing order of their Node degree. 2- Make a List of Available Colors to each Vertex. Initially all colors are available to all vertices. 3- From the list of sorted vertices, choose the first unassigned vertex and assign it the first available Color and remove that color from list of available colors to all its neighbors. 4- Repeat Step 3 till no vertex remains unassigned. Hamid Bahravan

2 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4 VertexNeighbor Vertices 12, 3 21, 3, 5 31, 2, 4, 5 4 3, 5 52, 3, 4 Adjacency Matrix of the Graph Example: Consider the Graph with its adjacency matrix given below. Available Colors C = { Red, Green, Blue, Yellow }

3 Graph Coloring Solution in a Deterministic Machine Step 1: Sorting Vertices based on their Node Degree. The vertices after sorting in non-decreasing order of their node degree are : { V 3,V 2,V 5,V 1,V 4 } Step 2: So we start with V 3 and assign the first color Red to it, then all V 2,V 5,V 1 and V 4 can not use Red. We construct a table to reflect this. VertexRedGreenBlueYellow 3* 2- 5- 1- 4- * Indicates – vertex is assigned that color. - Indicates – vertex can’t use that color. Empty Cell Indicates that color is available.

4 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4

5 Step 3: Doing the same process with other vertices. Now, it is the turn of V 2 and from the above table it is clear that V 2 can not use Red so it takes the first available color Green, making the table look like below. VertexRedGreenBlueYellow 3*- 2-* 5-- 1-- 4- Since V 1,V 3 and V 5 are adjacent to V2 they can not use Green so we mark them with - sign.

6 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4

7 Now, when it comes to V 5 it has - marks in Red and Green, so it has to take Blue. After assigning Blue to V 5 the table would be as shown below. VertexRedGreenBlueYellow 3*-- 2-*- 5--* 1-- 4-- Since V 3 is connected to V 1,V 2,V 4 and V 5 all are marked with - for Blue correspondingly.

8 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4

9 In the next step, the Vertex V 1 has got two available colors (Blue, Yellow) and one not yet assigned neighbor (vertex V 4 ) which can not take Blue. Its other adjacent vertices V 2 and V 3 have already been assigned some colors and need not be cared. So the vertex V 1 from its available colors Blue and Yellow, gets the color Blue. Graph Coloring Solution in a Deterministic Machine VertexRedGreenBlueYellow 3*-- 2-*- 5--* 1--* 4-- Tip: We are always looking for the less number of colors. So Blue wins Yellow here!

10 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4

11 For the last vertex V 4, it can take neither Red nor Blue, but it can take Green or Yellow. Since it has no not-yet assigned neighbors it takes the first available color, that is Green. And its adjacent V 3 and V 5 have already been marked with - for Green. Graph Coloring Solution in a Deterministic Machine VertexRedGreenBlueYellow 3*-- 2-*- 5--* 1--* 4-*- Tip: We are always looking for the less number of colors. So Green wins Yellow here!

12 Graph Coloring Solution in a Deterministic Machine 1 2 5 3 4

13 Time Complexity Analysis: 1- Sorting the vertices based on their node degree takes time in O( n log(n)). 2- Assigning a Color to a vertex takes time in O( n*k ), where k is the number of colors. 3- there are ' n ' vertices to be colored, choosing all the ' n ' vertices takes time in O( n 2 ). Because each node has to check (n-1) remaining nodes whether they are its neighbor. So for n nodes, we have n(n-1)= O( n 2 ) So the final time complexity will be: T( n ) = O( n log(n)) + O( n*k ) + O( n 2 ) = O( n 2 )


Download ppt "Graph Coloring Solution in a Deterministic Machine The deterministic solution to coloring problem uses these steps to assign colors to vertices: 1- Given."

Similar presentations


Ads by Google