package nl.camilstaps.cs.graphs; import java.util.ArrayList; import java.util.List; /** * A Node is a simple point in a graph, with references to its neighbours. It holds an integer 'content' which can act * as an identifier. * * @author Camil Staps */ public class Node { private final int content; private final List neighbours = new ArrayList<>(); public Node(int content) { this.content = content; } /** * Create a copy of another Node * @param copy */ public Node(Node copy) { this.content = copy.content; this.neighbours.addAll(copy.neighbours); } public List getNeighbours() { return neighbours; } public String toString() { return "<" + content + ">"; } /** * Nodes are equal if their identifiers are equal * @param another * @return */ public boolean equals(Object another) { return !(another == null || another.getClass() != this.getClass()) && content == (((Node) another).content); } }