/** * Map the {@link Vertex} to its adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> both(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.both, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.BOTH, edgeLabels)); }
/** * Map the {@link Vertex} to its outgoing adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> out(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.out, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.OUT, edgeLabels)); }
/** * Map the {@link Vertex} to its incoming adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> in(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.in, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.IN, edgeLabels)); }
/** * Map the {@link Vertex} to its outgoing incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> outE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.outE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.OUT, edgeLabels)); }
/** * Map the {@link Vertex} to its incoming incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> inE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.inE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.IN, edgeLabels)); }
/** * Map the {@link Vertex} to its incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> bothE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.bothE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.BOTH, edgeLabels)); }
/** * Map the {@link Vertex} to its adjacent vertices given a direction and edge labels. * * @param direction the direction to traverse from the current vertex * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.to, direction, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, direction, edgeLabels)); }
/** * Map the {@link Vertex} to its incident edges given the direction and edge labels. * * @param direction the direction to traverse from the current vertex * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.toE, direction, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, direction, edgeLabels)); }
/** * Optimizes the given step if possible. Basically this method converts <code>.out()</code> to <code>.outE()</code> * and <code>.values()</code> to <code>.properties()</code>. * * @param traversal the traversal that holds the given step * @param step the step to replace */ private static void optimizeStep(final Traversal.Admin traversal, final Step step) { final Step newStep; if (step instanceof VertexStep) { final VertexStep vs = (VertexStep) step; newStep = new VertexStep<>(traversal, Edge.class, vs.getDirection(), vs.getEdgeLabels()); } else if (step instanceof PropertiesStep) { final PropertiesStep ps = (PropertiesStep) step; newStep = new PropertiesStep(traversal, PropertyType.PROPERTY, ps.getPropertyKeys()); } else { return; } TraversalHelper.replaceStep(step, newStep, traversal); }
/** * Optimizes the given edge-emitting step and the vertex-emitting step by replacing them with a single * vertex-emitting step. * * @param traversal the traversal that holds the given steps * @param step1 the edge-emitting step to replace * @param step2 the vertex-emitting step to replace */ private static void optimizeSteps(final Traversal.Admin traversal, final VertexStep step1, final Step step2) { final Step newStep = new VertexStep(traversal, Vertex.class, step1.getDirection(), step1.getEdgeLabels()); for (final String label : (Iterable<String>) step2.getLabels()) { newStep.addLabel(label); } TraversalHelper.replaceStep(step1, newStep, traversal); traversal.removeStep(step2); }
final VertexStep<Edge> newVertexStep = new VertexStep<>(traversal, Edge.class, previousStep.getDirection(), edgeLabels.toArray(new String[edgeLabels.size()])); TraversalHelper.replaceStep(previousStep, newVertexStep, traversal); TraversalHelper.copyLabels(previousStep, newVertexStep, false);
TraversalHelper.insertAfterStep(new TraversalFilterStep<>(traversal, (Traversal) this.vertexCriterion.clone()), step, traversal); } else { final VertexStep<Edge> someEStep = new VertexStep<>(traversal, Edge.class, step.getDirection(), step.getEdgeLabels()); final boolean addsPathRequirement; final Step<Edge, Vertex> someVStep = (addsPathRequirement = step.getDirection() == Direction.BOTH) ?
/** * Map the {@link Vertex} to its incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> bothE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.bothE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.BOTH, edgeLabels)); }
/** * Map the {@link Vertex} to its incoming adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> in(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.in, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.IN, edgeLabels)); }
/** * Map the {@link Vertex} to its outgoing incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> outE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.outE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.OUT, edgeLabels)); }
/** * Map the {@link Vertex} to its incoming incident edges given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> inE(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.inE, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, Direction.IN, edgeLabels)); }
/** * Map the {@link Vertex} to its outgoing adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> out(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.out, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.OUT, edgeLabels)); }
/** * Map the {@link Vertex} to its adjacent vertices given the edge labels. * * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> both(final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.both, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, Direction.BOTH, edgeLabels)); }
/** * Map the {@link Vertex} to its adjacent vertices given a direction and edge labels. * * @param direction the direction to traverse from the current vertex * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Vertex> to(final Direction direction, final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.to, direction, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Vertex.class, direction, edgeLabels)); }
/** * Map the {@link Vertex} to its incident edges given the direction and edge labels. * * @param direction the direction to traverse from the current vertex * @param edgeLabels the edge labels to traverse * @return the traversal with an appended {@link VertexStep}. * @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#vertex-steps" target="_blank">Reference Documentation - Vertex Step</a> * @since 3.0.0-incubating */ public default GraphTraversal<S, Edge> toE(final Direction direction, final String... edgeLabels) { this.asAdmin().getBytecode().addStep(Symbols.toE, direction, edgeLabels); return this.asAdmin().addStep(new VertexStep<>(this.asAdmin(), Edge.class, direction, edgeLabels)); }