Consider an undirected graph G = (V,E), in which each node u 2 V may be coloredwith some color between 1 and C. Your task is to write a program that determine the colors for the uncolored nodes in the

STUCK with your assignment? When is it due? Hire our professional essay experts who are available online 24/7 for an essay paper written to a high standard at a reasonable price.


Order a Similar Paper Order a Different Paper

Consider an undirected graph G = (V,E), in which each node u 2 V may be coloredwith some color between 1 and C. Your task is to write a program that determine the colorsfor the uncolored nodes in the graph such that• For all edges (u, v) 2 E, u and v have different colors.• The number of additional colors needed is minimum.Input (Standard input): Includes multiples lines. The first line contains two integers1 n 1000, 1 m 100000 that correspond to the number of nodes and edges,respectively.Each of the following m lines contain two integers u and v, separated by one space,to denote an edge from u to v. Nodes are numbered from 1 to n.The last line contains n integers that are the colors of the nodes. Uncolored nodesare indicated with color 0.Output (Standard output): The first line contains an integer 0 D n that is thenumber of additional colors needed to color all the uncolored nodes in the graph.The next line contains n positive integers that are colors of the nodes.Sample input/output:Input — Output9 18 — 11 2 — 1 2 3 2 3 1 3 1 21 31 41 72 32 52 83 63 94 54 64 75 65 86 97 87 98 90 2 0 2 0 1 0 1 0Explain of the input/output: The nodes in the graph are equivalent to 9 squares asshown in the above figure. There is an edge between two squares if and only if they are ona same row or column. The initial coloring of the nodes in the graph is shown in the middlefigure. We can use one additional color (color 3) to color all the remaining nodes.I. Your program in Java/C++ that solves the above problem following the above input/output format. A makefile and/or compiling instruction should be included ifyou have multiple source files. Your program should not take more than 2 minutes toterminate on any graph within the limits described in the Input section.II. A report outline the numbers of colors used by your program on random graphsassuming no nodes have any color at the beginning. The report should have at least two parts. Run your program for graphs of sizes 50, 100,…, 500 and report both thenumber of used colors and the maximum degree.

Writerbay.net

Everyone needs a little help with academic work from time to time. Hire the best essay writing professionals working for us today!

Get a 15% discount for your first order


Order a Similar Paper Order a Different Paper