formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -7,8 +7,7 @@ void printSolution(int color[]);
/* A utility function to check if the current color assignment
is safe for vertex v */
bool isSafe(int v, bool graph[V][V], int color[], int c)
{
bool isSafe(int v, bool graph[V][V], int color[], int c) {
for (int i = 0; i < V; i++)
if (graph[v][i] && c == color[i])
return false;
@@ -16,22 +15,18 @@ bool isSafe(int v, bool graph[V][V], int color[], int c)
}
/* A recursive utility function to solve m coloring problem */
void graphColoring(bool graph[V][V], int m, int color[], int v)
{
void graphColoring(bool graph[V][V], int m, int color[], int v) {
/* base case: If all vertices are assigned a color then
return true */
if (v == V)
{
if (v == V) {
printSolution(color);
return;
}
/* Consider this vertex v and try different colors */
for (int c = 1; c <= m; c++)
{
for (int c = 1; c <= m; c++) {
/* Check if assignment of color c to v is fine*/
if (isSafe(v, graph, color, c))
{
if (isSafe(v, graph, color, c)) {
color[v] = c;
/* recur to assign colors to rest of the vertices */
@@ -45,16 +40,14 @@ void graphColoring(bool graph[V][V], int m, int color[], int v)
}
/* A utility function to print solution */
void printSolution(int color[])
{
void printSolution(int color[]) {
printf(" Following are the assigned colors \n");
for (int i = 0; i < V; i++) printf(" %d ", color[i]);
printf("\n");
}
// driver program to test above function
int main()
{
int main() {
/* Create following graph and test whether it is 3 colorable
(3)---(2)
| / |