void () { TestNode nodeA = new TestNode("A"); TestNode nodeB = new TestNode("B"); TestNode[] nodes = {nodeA, nodeB}; TestNode[] inA = {nodeB}; TestNode[] inB = {nodeA}; Graph<TestNode> graph = GraphGenerator.generate(new InboundSemiGraph<>() { @NotNull @Override public Collection<TestNode> getNodes() { return Arrays.asList(nodes); } @NotNull @Override public Iterator<TestNode> getIn(TestNode n) { if (n == nodeA) return Arrays.asList(inA).iterator(); if (n == nodeB) return Arrays.asList(inB).iterator(); throw new NoSuchElementException(); } }); GraphTestUtil.assertIteratorsEqual(Arrays.asList(inA).iterator(), graph.getOut(nodeA)); GraphTestUtil.assertIteratorsEqual(Arrays.asList(inB).iterator(), graph.getOut(nodeB)); }