Question: Produce a Python code from the above steps with comments explaining each steps for graph coloring algorithm using adjacency matrix. 5 EXAMPLE Algorithm proposed here

 Produce a Python code from the above steps with comments explaining

each steps for graph coloring algorithm using adjacency matrix. 5 EXAMPLE Algorithm

Produce a Python code from the above steps with comments explaining each steps for graph coloring algorithm using adjacency matrix.

5 EXAMPLE Algorithm proposed here is applied on the graph shown in figure 3. Figure 3. Graph with seven vertices. Graph is undirected and it has seven vertices. So its adja- cency matrix will be of order 7 x 7. M = 01101 1 0 10 011 0 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 Given a Graph G(V,E): 1. Calculate total vertices n in G 2. Make an adjacency matrix of nxn matrix 3. Calculate the degree of each node using matrix obtained in step 2. 4. Select the maximum degree node suppose X. Color X and its NN suppose Y with same color. 5. If X and Y has common vertices then color it with color different then X 6. If common vertices of step 5 are not adjacent then color these vertices with same color. else color these vertices with different color. 7. If X has other new neighbor then go to step 8 else take new NN as the NN of Y and go to step 8. 8. If new NN and previous NN are adjacent then color new NN with different color other then X. else color new NN with color of X. 9. If new NN is adjacent to any colored vertices or to any previous NN then color it with different color. 10. Until non-colored vertices > 1, go to step 5. 11. return G 5 EXAMPLE Algorithm proposed here is applied on the graph shown in figure 3. Figure 3. Graph with seven vertices. Graph is undirected and it has seven vertices. So its adja- cency matrix will be of order 7 x 7. M = 01101 1 0 10 011 0 1 1 0 0 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 1 0 1 0 0 0 1 1 0 1 0 1 0 1 0 Given a Graph G(V,E): 1. Calculate total vertices n in G 2. Make an adjacency matrix of nxn matrix 3. Calculate the degree of each node using matrix obtained in step 2. 4. Select the maximum degree node suppose X. Color X and its NN suppose Y with same color. 5. If X and Y has common vertices then color it with color different then X 6. If common vertices of step 5 are not adjacent then color these vertices with same color. else color these vertices with different color. 7. If X has other new neighbor then go to step 8 else take new NN as the NN of Y and go to step 8. 8. If new NN and previous NN are adjacent then color new NN with different color other then X. else color new NN with color of X. 9. If new NN is adjacent to any colored vertices or to any previous NN then color it with different color. 10. Until non-colored vertices > 1, go to step 5. 11. return G

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!