Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please answer on jsfiddle.net Please make sure code works on jsfiddle Please inc

ID: 3576862 • Letter: P

Question

Please answer on jsfiddle.net Please make sure code works on jsfiddle Please include both HTML and Java sections Assignment 14 Graphs Objective Demonstrate the ability to implement and traverse a graph Supports learning objectives 1,2 and 3 3 1. Describe both complex and simple data structures. 2. Select the correct data structure and algorithm to solve specific problems. 3. Implement data structures and algorithms in computer code. Introduction Graphs are possibly the most complex of the basic data structures you will deal with. They are covered in Topic-Graph Data Structures Assignment This is your toughest assignment. Given the Graph shown (ignore pointers this is an undirected graph) Allow the user to select 2 nodes. Then calculate and display the cost of each path between the 2 nodes. F to C F, D, C: 2 F, D, E, C: 4 F, D, B, A, C: 5 F, D, G, B, A, C: 7

Explanation / Answer

#include<stdio.h>

// variety of vertices within the graph
#define V four

void printSolution(int color[]);

/* A utility perform to envision if this color assignment
is safe for vertex v */
bool isSafe (int v, bool graph[V][V], int color[], int c)
come back false;
come back true;
}

/* A algorithmic utility perform to resolve m coloring drawback */
bool graphColoringUtil(bool graph[V][V], int m, int color[], int v)
ar assigned a color then
come back true */
if (v == V)
come back true;

/* take into account this vertex v and take a look at completely different colours */
for (int c = 1; c <= m; c++)
{
/* Check if assignment of color c to v is fine*/
if (isSafe(v, graph, color, c))
{
color[v] = c;

/* recur to assign colours to remainder of the vertices */
if (graphColoringUtil (graph, m, color, v+1) == true)
come back true;

/* If distribution color c does not result in an answer
then take away it */
color[v] = 0;
}
}

/* If no color will be assigned to the current vertex then come back false */
come back false;
}

/* This perform solves the m Coloring drawback exploitation Backtracking.
It principally uses graphColoringUtil() to resolve the matter. It returns
false if the m colours can not be assigned , otherwise come back true and
prints assignments of colours to any or all vertices. Please note that there
could also be quite one solutions, this perform prints one in every of the
possible solutions.*/
bool graphColoring(bool graph[V][V], int m)
zero. This low-level formatting is required
// correct functioning of isSafe()
int *color = new int[V];
for (int i = 0; i < V; i++)
color[i] = 0;

// decision graphColoringUtil() for vertex zero
if (graphColoringUtil(graph, m, color, 0) == false)