org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy Java Examples

The following examples show how to use org.apache.tinkerpop.gremlin.process.traversal.TraversalStrategy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TraversalExplanationSerializer.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a Map containing "original", "intermediate" and "final" keys.
 */
@Override
public Object transform(final TraversalExplanation value) {
    final Map<String, Object> result = new HashMap<>();
    result.put(ORIGINAL, getTraversalSteps(value.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = value.getStrategyTraversals();

    result.put(INTERMEDIATE,
            strategyTraversals.stream().map(pair -> {
                final Map<String, Object> item = new HashMap<>();
                item.put(STRATEGY, pair.getValue0().toString());
                item.put(CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
                item.put(TRAVERSAL, getTraversalSteps(pair.getValue1()));
                return item;
            }).collect(Collectors.toList()));

    result.put(FINAL, getTraversalSteps(strategyTraversals.isEmpty()
            ? value.getOriginalTraversal() : strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));
    return result;
}
 
Example #2
Source File: GraphSONSerializersV2d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final TraversalExplanation traversalExplanation, final JsonGenerator jsonGenerator,
                      final SerializerProvider serializerProvider) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = traversalExplanation.getStrategyTraversals();

    final List<Map<String, Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String, Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
Example #3
Source File: TinkerGraphCountStrategyTest.java    From tinkergraph-gremlin with Apache License 2.0 6 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphCountStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    if (this.optimized == null) {
        this.optimized = this.original.asAdmin().clone();
        this.optimized.asAdmin().setStrategies(strategies);
        this.optimized.asAdmin().applyStrategies();
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #4
Source File: TraversalVertexProgramStep.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public TraversalVertexProgram generateProgram(final Graph graph, final Memory memory) {
    final Traversal.Admin<?, ?> computerSpecificTraversal = this.computerTraversal.getPure();
    final TraversalStrategies computerSpecificStrategies = this.getTraversal().getStrategies().clone();

    IteratorUtils.filter(TraversalStrategies.GlobalCache.getStrategies(graph.getClass()),
            s -> s instanceof TraversalStrategy.ProviderOptimizationStrategy).forEach(computerSpecificStrategies::addStrategies);

    computerSpecificTraversal.setStrategies(computerSpecificStrategies);
    computerSpecificTraversal.setSideEffects(new MemoryTraversalSideEffects(this.getTraversal().getSideEffects()));
    computerSpecificTraversal.setParent(this);
    final TraversalVertexProgram.Builder builder = TraversalVertexProgram.build().traversal(computerSpecificTraversal);
    if (memory.exists(TraversalVertexProgram.HALTED_TRAVERSERS))
        builder.haltedTraversers(memory.get(TraversalVertexProgram.HALTED_TRAVERSERS));
    return builder.create(graph);
}
 
Example #5
Source File: TinkerGraphCountStrategyTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphCountStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    if (this.optimized == null) {
        this.optimized = this.original.asAdmin().clone();
        this.optimized.asAdmin().setStrategies(strategies);
        this.optimized.asAdmin().applyStrategies();
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #6
Source File: GraphSONSerializersV1d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
public void ser(final TraversalExplanation te, final JsonGenerator jsonGenerator) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(te.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?,?>>> strategyTraversals = te.getStrategyTraversals();

    final List<Map<String,Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String,Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(te.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
Example #7
Source File: EarlyLimitStrategyTest.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(EarlyLimitStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
        if (strategy instanceof ProfileStrategy) {
            final TraversalStrategies os = new DefaultTraversalStrategies();
            os.addStrategies(ProfileStrategy.instance());
            this.optimized.asAdmin().setStrategies(os);
            this.optimized.asAdmin().applyStrategies();
        }
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #8
Source File: GraphSONSerializersV3d0.java    From tinkerpop with Apache License 2.0 6 votes vote down vote up
@Override
public void serialize(final TraversalExplanation traversalExplanation, final JsonGenerator jsonGenerator,
                      final SerializerProvider serializerProvider) throws IOException {
    final Map<String, Object> m = new HashMap<>();
    m.put(GraphSONTokens.ORIGINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));

    final List<Pair<TraversalStrategy, Traversal.Admin<?, ?>>> strategyTraversals = traversalExplanation.getStrategyTraversals();

    final List<Map<String, Object>> intermediates = new ArrayList<>();
    for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : strategyTraversals) {
        final Map<String, Object> intermediate = new HashMap<>();
        intermediate.put(GraphSONTokens.STRATEGY, pair.getValue0().toString());
        intermediate.put(GraphSONTokens.CATEGORY, pair.getValue0().getTraversalCategory().getSimpleName());
        intermediate.put(GraphSONTokens.TRAVERSAL, getStepsAsList(pair.getValue1()));
        intermediates.add(intermediate);
    }
    m.put(GraphSONTokens.INTERMEDIATE, intermediates);

    if (strategyTraversals.isEmpty())
        m.put(GraphSONTokens.FINAL, getStepsAsList(traversalExplanation.getOriginalTraversal()));
    else
        m.put(GraphSONTokens.FINAL, getStepsAsList(strategyTraversals.get(strategyTraversals.size() - 1).getValue1()));

    jsonGenerator.writeObject(m);
}
 
Example #9
Source File: DefaultTraversalStrategies.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked", "varargs"})
public TraversalStrategies removeStrategies(final Class<? extends TraversalStrategy>... strategyClasses) {
    boolean removed = false;
    for (final Class<? extends TraversalStrategy> strategyClass : strategyClasses) {
        final Optional<TraversalStrategy<?>> strategy = this.traversalStrategies.stream().filter(s -> s.getClass().equals(strategyClass)).findAny();
        if (strategy.isPresent()) {
            this.traversalStrategies.remove(strategy.get());
            removed = true;
        }
    }
    if (removed)
        this.traversalStrategies = TraversalStrategies.sortStrategies(this.traversalStrategies);
    return this;
}
 
Example #10
Source File: BytecodeUtil.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
/**
 * Parses {@link Bytecode} to find {@link TraversalStrategy} objects in the source instructions.
 */
public static <A extends TraversalStrategy> Iterator<A> findStrategies(final Bytecode bytecode, final Class<A> clazz) {
    return IteratorUtils.map(
            IteratorUtils.filter(bytecode.getSourceInstructions().iterator(),
                    s -> s.getOperator().equals(TraversalSource.Symbols.withStrategies) && clazz.isAssignableFrom(s.getArguments()[0].getClass())),
            os -> (A) os.getArguments()[0]);
}
 
Example #11
Source File: TraversalHelper.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public static void applySingleLevelStrategies(final Traversal.Admin<?, ?> parentTraversal, final Traversal.Admin<?, ?> childTraversal, final Class<? extends TraversalStrategy> stopAfterStrategy) {
    childTraversal.setStrategies(parentTraversal.getStrategies());
    childTraversal.setSideEffects(parentTraversal.getSideEffects());
    parentTraversal.getGraph().ifPresent(childTraversal::setGraph);
    for (final TraversalStrategy<?> strategy : parentTraversal.getStrategies()) {
        strategy.apply(childTraversal);
        if (null != stopAfterStrategy && stopAfterStrategy.isInstance(strategy))
            break;
    }
}
 
Example #12
Source File: RepeatUnrollStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(RepeatUnrollStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #13
Source File: DefaultTraversalStrategies.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings({"unchecked", "varargs"})
public TraversalStrategies addStrategies(final TraversalStrategy<?>... strategies) {
    for (final TraversalStrategy<?> addStrategy : strategies) {
        this.traversalStrategies.remove(addStrategy);
    }
    Collections.addAll(this.traversalStrategies, strategies);
    this.traversalStrategies = TraversalStrategies.sortStrategies(this.traversalStrategies);
    return this;
}
 
Example #14
Source File: TraversalExplanation.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public TraversalExplanation(final Traversal.Admin<?, ?> traversal) {
    this.traversal = traversal.clone();
    final TraversalStrategies mutatingStrategies = new DefaultTraversalStrategies();
    for (final TraversalStrategy strategy : this.traversal.getStrategies()) {
        final Traversal.Admin<?, ?> mutatingTraversal = this.traversal.clone();
        mutatingStrategies.addStrategies(strategy);
        mutatingTraversal.setStrategies(mutatingStrategies);
        mutatingTraversal.applyStrategies();
        this.strategyTraversals.add(Pair.with(strategy, mutatingTraversal));
    }
}
 
Example #15
Source File: TinkerGraphNoStrategyProvider.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()]));
}
 
Example #16
Source File: TinkerGraphStepStrategyTest.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #17
Source File: TraversalSerializersV2d0.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public void serialize(final TraversalStrategy traversalStrategy, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException {
    jsonGenerator.writeStartObject();
    for (final Map.Entry<Object, Object> entry : ConfigurationConverter.getMap(traversalStrategy.getConfiguration()).entrySet()) {
        jsonGenerator.writeObjectField((String) entry.getKey(), entry.getValue());
    }
    jsonGenerator.writeEndObject();
}
 
Example #18
Source File: TinkerGraphNoStrategyComputerProvider.java    From tinkergraph-gremlin with Apache License 2.0 5 votes vote down vote up
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()])).withComputer();
}
 
Example #19
Source File: VertexProgramStrategy.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
public void addGraphComputerStrategies(final TraversalSource traversalSource) {
    Class<? extends GraphComputer> graphComputerClass;
    if (this.computer.getGraphComputerClass().equals(GraphComputer.class)) {
        try {
            graphComputerClass = this.computer.apply(traversalSource.getGraph()).getClass();
        } catch (final Exception e) {
            graphComputerClass = GraphComputer.class;
        }
    } else
        graphComputerClass = this.computer.getGraphComputerClass();
    final List<TraversalStrategy<?>> graphComputerStrategies = TraversalStrategies.GlobalCache.getStrategies(graphComputerClass).toList();
    traversalSource.getStrategies().addStrategies(graphComputerStrategies.toArray(new TraversalStrategy[graphComputerStrategies.size()]));
}
 
Example #20
Source File: LazyBarrierStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(LazyBarrierStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #21
Source File: DefaultTraversalStrategies.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends TraversalStrategy> Optional<T> getStrategy(final Class<T> traversalStrategyClass) {
    for (final TraversalStrategy<?> traversalStrategy : this.traversalStrategies) {
        if (traversalStrategyClass.isAssignableFrom(traversalStrategy.getClass()))
            return (Optional) Optional.of(traversalStrategy);
    }
    return Optional.empty();
}
 
Example #22
Source File: PathProcessorStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final Traversal.Admin<?, ?> rootTraversal = new DefaultGraphTraversal<>();
    final TraversalParent parent = new TraversalVertexProgramStep(rootTraversal, this.original.asAdmin());
    rootTraversal.addStep(parent.asStep());
    this.original.asAdmin().setParent(parent); // trick it into OLAP
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(PathProcessorStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #23
Source File: MatchPredicateStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(MatchPredicateStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #24
Source File: FilterRankingStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(FilterRankingStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #25
Source File: MessagePassingReductionStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final Traversal.Admin<?, ?> rootTraversal = new DefaultGraphTraversal<>();
    final TraversalVertexProgramStep parent = new TraversalVertexProgramStep(rootTraversal, this.original.asAdmin());
    rootTraversal.addStep(parent.asStep());
    parent.setComputerTraversal(this.original.asAdmin());
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(MessagePassingReductionStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    rootTraversal.setStrategies(strategies);
    rootTraversal.asAdmin().applyStrategies();
    assertEquals(this.optimized, parent.computerTraversal.get());
}
 
Example #26
Source File: ExplainTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
@LoadGraphWith(MODERN)
@IgnoreEngine(TraversalEngine.Type.COMPUTER)
public void g_V_outE_identity_inV_explain() {
    final TraversalExplanation explanation = get_g_V_outE_identity_inV_explain();
    if (explanation.getStrategyTraversals().stream().map(Pair::getValue0).filter(s -> s instanceof IdentityRemovalStrategy || s instanceof IncidentToAdjacentStrategy).count() == 2) {
        printTraversalForm(explanation.getOriginalTraversal());
        boolean beforeIncident = true;
        boolean beforeIdentity = true;
        for (final Pair<TraversalStrategy, Traversal.Admin<?, ?>> pair : explanation.getStrategyTraversals()) {
            if (pair.getValue0().getClass().equals(IncidentToAdjacentStrategy.class))
                beforeIncident = false;
            if (pair.getValue0().getClass().equals(IdentityRemovalStrategy.class))
                beforeIdentity = false;

            if (beforeIdentity)
                assertEquals(1, TraversalHelper.getStepsOfClass(IdentityStep.class, pair.getValue1()).size());

            if (beforeIncident)
                assertEquals(1, TraversalHelper.getStepsOfClass(EdgeVertexStep.class, pair.getValue1()).size());

            if (!beforeIdentity)
                assertEquals(0, TraversalHelper.getStepsOfClass(IdentityStep.class, pair.getValue1()).size());

            if (!beforeIncident)
                assertEquals(0, TraversalHelper.getStepsOfClass(EdgeVertexStep.class, pair.getValue1()).size());
        }
        assertFalse(beforeIncident);
    }
}
 
Example #27
Source File: TinkerGraphStepStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(TinkerGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}
 
Example #28
Source File: TinkerGraphNoStrategyProvider.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()]));
}
 
Example #29
Source File: TinkerGraphNoStrategyComputerProvider.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Override
public GraphTraversalSource traversal(final Graph graph) {
    final List<Class> toRemove = TraversalStrategies.GlobalCache.getStrategies(TinkerGraph.class).toList().stream()
            .map(TraversalStrategy::getClass)
            .filter(clazz -> !REQUIRED_STRATEGIES.contains(clazz))
            .collect(Collectors.toList());
    return graph.traversal().withoutStrategies(toRemove.toArray(new Class[toRemove.size()])).withComputer();
}
 
Example #30
Source File: Neo4jGraphStepStrategyTest.java    From tinkerpop with Apache License 2.0 5 votes vote down vote up
@Test
public void doTest() {
    final TraversalStrategies strategies = new DefaultTraversalStrategies();
    strategies.addStrategies(Neo4jGraphStepStrategy.instance());
    for (final TraversalStrategy strategy : this.otherStrategies) {
        strategies.addStrategies(strategy);
    }
    this.original.asAdmin().setStrategies(strategies);
    this.original.asAdmin().applyStrategies();
    assertEquals(this.optimized, this.original);
}