# How to find Chromatic Number | Graph coloring Algorithm

To understand this example, we have to know about the previous article, i.e., Chromatic Number of Graph in Discrete mathematics.

In the section of Chromatic Numbers, we have learned the following things:

• Graph coloring can be described as a process of assigning colors to the vertices of a graph.
• In graph coloring, the same color should not be used to fill the two adjacent vertices.
• Chromatic number can be described as a minimum number of colors required to properly color any graph.

### Graph Coloring Algorithm

• If we want to color a graph with the help of a minimum number of colors, for this, there is no efficient algorithm.
• Graph coloring is also known as the NP-complete algorithm.

However, we can find the chromatic number of the graph with the help of following greedy algorithm.

### Greedy Algorithm

There are various steps to solve the greedy algorithm, which are described as follows:

Step 1: In the first step, we will color the first vertex with first color.

Step 2: Now, we will one by one consider all the remaining vertices (V -1) and do the following:

• We will color the currently picked vertex with the help of lowest number color if and only if the same color is not used to color any of its adjacent vertices.
• If its adjacent vertices are using it, then we will select the next least numbered color.
• If we have already used all the previous colors, then a new color will be used to fill or assign to the currently picked vertex.

Disadvantages of Greedy Algorithm

The greedy algorithm contains a lot of drawbacks, which are described as follows:

• In the greedy algorithm, the minimum number of colors is not always used.
• Sometimes, the number of colors is based on the order in which the vertices are processed.

### Examples of finding Chromatic number of a Graph

There are a lot of examples to find out the chromatic number in a graph. Some of them are described as follows:

Example 1: In this example, we have a graph, and we have to determine the chromatic number of this graph. Solution:

When we apply the greedy algorithm, we will have the following:

 Vertex a b c d e f Color C1 C2 C1 C2 C1 C2

From the above table,

• In the above graph, we are required minimum 2 numbers of colors to color the graph.
• Therefore, we can say that the Chromatic number of above graph = 2

So with the help of 2 colors, the above graph can be properly colored like this: Example 2: In this example, we have a graph, and we have to determine the chromatic number of this graph. Solution:

When we apply the greedy algorithm, we will have the following:

 Vertex a b c d e f Color C1 C2 C2 C3 C3 C1

From the above table,

• In the above graph, we are required minimum 3 numbers of colors to color the graph.
• Therefore, we can say that the Chromatic number of above graph = 3

So with the help of 3 colors, the above graph can be properly colored like this: Example 3: In this example, we have a graph, and we have to determine the chromatic number of this graph. Solution:

When we apply the greedy algorithm, we will have the following:

 Vertex a b c d e f g Color C1 C2 C1 C3 C2 C3 C4

From the above table,

• In the above graph, we are required minimum 4 numbers of colors to color the graph.
• Therefore, we can say that the Chromatic number of above graph = 4

So with the help of 4 colors, the above graph can be properly colored like this: Example 4: In this example, we have a graph, and we have to determine the chromatic number of this graph. Solution:

When we apply the greedy algorithm, we will have the following:

 Vertex a b c d e f Color C1 C2 C3 C1 C2 C3

From the above table,

• In the above graph, we are required minimum 3 numbers of colors to color the graph.
• Therefore, we can say that the Chromatic number of above graph = 3

So with the help of 3 colors, the above graph can be properly colored like this: Example 5: In this example, we have a graph, and we have to determine the chromatic number of this graph. Solution:

When we apply the greedy algorithm, we will have the following:

• In the above graph, we are required minimum 3 numbers of colors to color the graph.
• Therefore, we can say that the Chromatic number of above graph = 3

So with the help of 3 colors, the above graph can be properly colored like this: ## Help Others, Please Share   