Must answer output screenshot, editable code Code this in java.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Must answer output screenshot, editable code

Code this in java.

 

 

public static int [] graphColoring(int n, int [][] W)

The method returns an array with cells 1 through n giving an k-coloring of the graph, where k is the minimum number of colors needed to color the graph. Cell 0 of the array will contain the value −k.
It does this by calling a method that implements a backtracking algorithm with k=1,2,3, etc, until a valid k-coloring is found.
The method that implements the backtracking algorithm must return a boolean value: true if it finds a solution, and false if it doesn’t. If it does find a solution, it must stop looking for other solutions.
You will need to write the promising method in addition to the boolean graph coloring method.
You have also been given 4 test cases. The arrays that should be returned for these test cases are as follows:

[][] W1 = {
        {},
        {-1, 0, 1, 1},
        {-1, 1, 0, 1},
        {-1, 1, 1, 0}
    };
Should return for W1: {-3, 1, 2, 3}

[][] W2 = {
{},
{-1, 0, 0, 1, 0},
{-1, 0, 0, 0, 1},
{-1, 1, 0, 0, 1},
{-1, 0, 1, 1, 0}
};

Should return for W2: {-2, 1, 2, 2, 1}

[][] W3 = {
        {},
        {-1, 0, 0, 1, 1, 1},
        {-1, 0, 0, 1, 0, 0},
        {-1, 1, 1, 0, 1, 1},
        {-1, 1, 0, 1, 0, 1},
        {-1, 1, 0, 1, 1, 0}
    };

Should return for W3: {-4, 1, 1, 2, 3, 4}

[][] W4 = {
        {},
        {-1, 0, 1, 0, 1, 0, 1},
        {-1, 1, 0, 1, 0, 1, 0},
        {-1, 0, 1, 0, 0, 0, 1},
        {-1, 1, 0, 0, 0, 1, 1},
        {-1, 0, 1, 0, 1, 0, 0},
        {-1, 1, 0, 1, 1, 0, 0}
    };

Should return for W4: {-3, 1, 2, 1, 2, 1, 3}

public class GraphColoring {

public static void main(String [] args) {


}
  
  
public static int [] graphColor(int n, int [][] W) {


}
  

public static int [][] W1 = {
{},
{-1, 0, 1, 1},
{-1, 1, 0, 1},
{-1, 1, 1, 0}
};

public static int [][] W2 = {
{},
{-1, 0, 0, 1, 0},
{-1, 0, 0, 0, 1},
{-1, 1, 0, 0, 1},
{-1, 0, 1, 1, 0}
};
  
public static int [][] W3 = {
{},
{-1, 0, 0, 1, 1, 1},
{-1, 0, 0, 1, 0, 0},
{-1, 1, 1, 0, 1, 1},
{-1, 1, 0, 1, 0, 1},
{-1, 1, 0, 1, 1, 0}
};
  
public static int [][] W4 = {
{},
{-1, 0, 1, 0, 1, 0, 1},
{-1, 1, 0, 1, 0, 1, 0},
{-1, 0, 1, 0, 0, 0, 1},
{-1, 1, 0, 0, 0, 1, 1},
{-1, 0, 1, 0, 1, 0, 0},
{-1, 1, 0, 1, 1, 0, 0}
};

}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY