Professional Documents
Culture Documents
Graph Coloring:
#include <stdio.h>
int V;
return 0;
return 1;
if (v == V)
return 1;
if (isSafe(
color[v] = c;
return 1;
color[v] = 0; }
return 0;
int color[V];
color[i] = 0;
if (colour(graph, m, color, 0)== 0) {
return 1;
int main() {
int e;
scanf("%d %d",&V,&e);
int graph[V][V];
for(int i=0;i<V;i++){
for(int j=0;j<V;j++)
graph[i][j]=0;
while(e--){
int u,v;
scanf("%d %d",&u,&v);
graph[u][v]=1;
graph[v][u]=1;
int m;
printf("Number of colors\n");
scanf("%d",&m);
graphColoring(graph, m);
return 0;
}
Output: