CassovaryOutIndexedDirectedGraph implements OutIndexedDirectedGraph { @Override public EdgeIterator getOutEdges(long node) { Option<Node> opt = graph.getNodeById((int) node); if (opt.isEmpty()) { return new EmptyEdgeIterator(); } return new CSeqEdgeIteratorWrapper(opt.get().outboundNodes()); } CassovaryOutIndexedDirectedGraph(DirectedGraph<Node> graph); @Override int getOutDegree(long node); @Override EdgeIterator getOutEdges(long node); @Override EdgeIterator getRandomOutEdges(long node, int numSamples, Random random);  }
@Test public void testSkipping() throws Exception { CassovaryOutIndexedDirectedGraph g = new CassovaryOutIndexedDirectedGraph(TestGraphs.g6_onlyout()); EdgeIterator iter = g.getOutEdges(10); assertEquals(true, iter.hasNext()); assertEquals(11, iter.nextLong()); assertEquals(true, iter.hasNext()); assertEquals(1, iter.skip(1)); assertEquals(true, iter.hasNext()); assertEquals(13, iter.nextLong()); assertEquals(false, iter.hasNext()); iter = g.getOutEdges(10); assertEquals(true, iter.hasNext()); assertEquals(1, iter.skip(1)); assertEquals(true, iter.hasNext()); assertEquals(12, iter.nextLong()); assertEquals(1, iter.skip(1)); assertEquals(false, iter.hasNext()); iter = g.getOutEdges(10); assertEquals(true, iter.hasNext()); assertEquals(3, iter.skip(10)); assertEquals(false, iter.hasNext()); iter = g.getOutEdges(10); assertEquals(true, iter.hasNext()); assertEquals(11, iter.nextLong()); assertEquals(true, iter.hasNext()); assertEquals(2, iter.skip(10)); assertEquals(false, iter.hasNext()); iter = g.getOutEdges(10); assertEquals(true, iter.hasNext()); assertEquals(2, iter.skip(2)); assertEquals(true, iter.hasNext()); assertEquals(13, iter.nextLong()); assertEquals(false, iter.hasNext()); }