@Test public void testGraphTransformer1() throws Exception { GraphWalker<VocabWord> walker = new RandomWalker.Builder<>(graph) .setNoEdgeHandling(NoEdgeHandling.CUTOFF_ON_DISCONNECTED).build(); GraphTransformer<VocabWord> transformer = new GraphTransformer.Builder<>(graph).setGraphWalker(walker).build(); Iterator<Sequence<VocabWord>> iterator = transformer.iterator(); int cnt = 0; while (iterator.hasNext()) { Sequence<VocabWord> sequence = iterator.next(); System.out.println(sequence); cnt++; } assertEquals(10, cnt); }
@Override public Iterator<Sequence<T>> iterator() { this.counter.set(0); this.walker.reset(shuffle); return new Iterator<Sequence<T>>() { private GraphWalker<T> walker = GraphTransformer.this.walker; @Override public void remove() { throw new UnsupportedOperationException("This is not supported on read-only iterator"); } @Override public boolean hasNext() { return walker.hasNext(); } @Override public Sequence<T> next() { Sequence<T> sequence = walker.next(); sequence.setSequenceId(counter.getAndIncrement()); if (walker.isLabelEnabled() && sequence.getSequenceLabels() == null) if (labelsProvider != null) { sequence.setSequenceLabel(labelsProvider.getLabel(sequence.getSequenceId())); } return sequence; } }; }
GraphTransformer implements Iterable<Sequence<T>> { @Override public Iterator<Sequence<T>> iterator() { this.counter.set(0); this.walker.reset(shuffle); return new Iterator<Sequence<T>>() { private GraphWalker<T> walker = GraphTransformer.this.walker; @Override public void remove() { throw new UnsupportedOperationException("This is not supported on read-only iterator"); } @Override public boolean hasNext() { return walker.hasNext(); } @Override public Sequence<T> next() { Sequence<T> sequence = walker.next(); sequence.setSequenceId(counter.getAndIncrement()); if (walker.isLabelEnabled() && sequence.getSequenceLabels() == null) if (labelsProvider != null) { sequence.setSequenceLabel(labelsProvider.getLabel(sequence.getSequenceId())); } return sequence; } }; } }
GraphTransformer implements Iterable<Sequence<T>> { @Override public Iterator<Sequence<T>> iterator() { this.counter.set(0); this.walker.reset(shuffle); return new Iterator<Sequence<T>>() { private GraphWalker<T> walker = GraphTransformer.this.walker; @Override public void remove() { throw new UnsupportedOperationException("This is not supported on read-only iterator"); } @Override public boolean hasNext() { return walker.hasNext(); } @Override public Sequence<T> next() { Sequence<T> sequence = walker.next(); sequence.setSequenceId(counter.getAndIncrement()); if (walker.isLabelEnabled() && sequence.getSequenceLabels() == null) if (labelsProvider != null) { sequence.setSequenceLabel(labelsProvider.getLabel(sequence.getSequenceId())); } return sequence; } }; } protected  GraphTransformer(); }
GraphTransformer implements Iterable<Sequence<T>> { @Override public Iterator<Sequence<T>> iterator() { this.counter.set(0); this.walker.reset(shuffle); return new Iterator<Sequence<T>>() { private GraphWalker<T> walker = GraphTransformer.this.walker; @Override public void remove() { throw new UnsupportedOperationException("This is not supported on read-only iterator"); } @Override public boolean hasNext() { return walker.hasNext(); } @Override public Sequence<T> next() { Sequence<T> sequence = walker.next(); sequence.setSequenceId(counter.getAndIncrement()); if (walker.isLabelEnabled() && sequence.getSequenceLabels() == null) if (labelsProvider != null) { sequence.setSequenceLabel(labelsProvider.getLabel(sequence.getSequenceId())); } return sequence; } }; } protected  GraphTransformer(); @Override Iterator<Sequence<T>> iterator(); }
GraphTransformer implements Iterable<Sequence<T>> { @Override public Iterator<Sequence<T>> iterator() { this.counter.set(0); this.walker.reset(shuffle); return new Iterator<Sequence<T>>() { private GraphWalker<T> walker = GraphTransformer.this.walker; @Override public void remove() { throw new UnsupportedOperationException("This is not supported on read-only iterator"); } @Override public boolean hasNext() { return walker.hasNext(); } @Override public Sequence<T> next() { Sequence<T> sequence = walker.next(); sequence.setSequenceId(counter.getAndIncrement()); if (walker.isLabelEnabled() && sequence.getSequenceLabels() == null) if (labelsProvider != null) { sequence.setSequenceLabel(labelsProvider.getLabel(sequence.getSequenceId())); } return sequence; } }; } protected  GraphTransformer(); @Override Iterator<Sequence<T>> iterator();  }