class Graph {

    public Graph addEdge(Node<?> node, Node<?> adj) {
        Objects.requireNonNull(node, "Cannot attach an edge to a null node");
        if (Objects.equals(node, adj)) {
            throw new IllegalArgumentException("Cannot connect a node to itself");
        }
        register(node);
        register(adj);
        checkCircularDependency(node, adj);
        this.adj.get(node).add(adj);
        return this;
    }

}