boolean (Graph<Node> graph, Node source, Node target) { Iterator<Node> successors = graph.getOut(source); while (successors.hasNext()) { Node successor = successors.next(); if (successor.equals(target)) { return true; } } return false; }