How do I override the hashCode() of the Graphstream Node object?
I am inserting the Nodes into a HashSet.
HashSet<Node> set = new HashSet<Node>();
You may inherit from Node to extend the objects hash in this class using Objects.hash(Object...). Just throw into this method whatever you want to have hashed together ...
class MyNode extends Node {
// whatever floats you boat here
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), other);
}
@Override
public boolean equals(Object o) {
// hashCode() and equals() overrides should always appear together
}
}
Maybe have a look here
EDIT: Dont' forget the equals() override!