m Coloring Problem using c or c++ Given an undirected graph and a number m, determine if the graph can be colored with at most m colors such that no two adjacent vertices of the graph are colored with the same color. Here coloring of a graph means the assignment of colors to all vertices. Input: 1) A 2D array graph[V][V] where V is the number of vertices in graph and graph[V][V] is adjacency matrix representation of the graph. A value graph[i][j] is 1 if there is a direct edge from i to j, otherwise graph[i][j] is 0. 2) An integer m which is a maximum number of colors that can be used. Output: An array color[V] that should have numbers from 1 to m. color[i] should represent the color assigned to the ith vertex. The code should also return false if the graph cannot be colored with m colors. Program: #include <stdio.h> #include <conio.h> #include <math.h> int m,n,x[10]={0},g[10][10]={0}; void main() { ...
Comments
Post a Comment