public class Node { public String name; public int value; public boolean visited; public Node(String name, int value, boolean visited) { this.name = name; this.value = value; this.visited = visited; } @Override public String toString() { return name + " " + value + " " + visited; } public boolean equals(Object other) { return other instanceof Node && this.value == ((Node) other).value; } public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((name == null) ? 0 : name.hashCode()); return result; } }