Question: write a comparator method for this node class in java that arranges the node from greatest to least indegree , and If two or more

write a comparator method for this node class in java that arranges the node from greatest to least indegree , and If two or more nodes have the same indegree, order them from greatest to least outdegree. If two or more nodes have both the same indegree and outdegree, order them alphabetically by abbreviation
import java.util.*;
// A node of a graph for the Spring 2018 ICS 340 program
public class Node {
private String name;
private String value; // The value of the Node which was stored in the value column
private String abbrev; // The abbreviation for the Node
private ArrayList outgoingEdges;
private ArrayList incomingEdges;
public Node(String abbreviation){
abbrev = abbreviation;
value = null;
name = null;
outgoingEdges = new ArrayList();
incomingEdges = new ArrayList();
}
public String getAbbrev(){
return abbrev;
}
public String getName(){
return name;
}
public String getValue(){
return value;
}
public ArrayList getOutgoingEdges(){
return outgoingEdges;
}
public ArrayList getIncomingEdges(){
return incomingEdges;
}
public void setAbbrev(String abbreviation){
abbrev = abbreviation;
}
public void setName(String name){
this.name = name;
}
public void setValue(String value){
this.value = value;
}
public void addOutgoingEdge(Edge e){
outgoingEdges.add(e);
}
public void addIncomingEdge(Edge e){
incomingEdges.add(e);
}
public String toString(){
return "Node "+ abbrev +" has "+ incomingEdges + value;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!