@Override public Traversal<Vertex, Edge> get_g_VX4X_bothE(final Object v4Id) { return g.V(v4Id).bothE(); }
/** * @see GraphTraversal#bothE(String...) */ public static GraphTraversal<Vertex, Edge> bothE(final String... edgeLabels) { return __.<Vertex>start().bothE(edgeLabels); }
@Override public Traversal<Vertex, Edge> get_g_VX4X_bothEXcreatedX(final Object v4Id) { return g.V(v4Id).bothE("created"); }
@Override public Traversal<Vertex, Vertex> get_g_VX4X_bothE_otherV(final Object v4Id) { return g.V(v4Id).bothE().otherV(); }
@Override public Traversal<Vertex, Edge> get_g_V_hasLabelXloopsX_bothEXselfX() { return g.V().hasLabel("loops").bothE("self"); }
@Override public Traversal<Vertex, Vertex> get_g_VX4X_bothE_hasXweight_lt_1X_otherV(Object v4Id) { return g.V(v4Id).bothE().has("weight", P.lt(1d)).otherV(); }
private Edge getEdge(final Object id1, final Object id2) { return g.V(id1) .bothE().filter(__.otherV().hasId(id2)) .next(); } }
@Test public void testQueryBothEdgesOfVertex() { HugeGraph graph = graph(); init18Edges(); // Query edges of a vertex Vertex james = vertex("author", "id", 1); List<Edge> edges = graph.traversal().V(james.id()).bothE().toList(); Assert.assertEquals(6, edges.size()); edges = ImmutableList.copyOf(james.edges(Direction.BOTH)); Assert.assertEquals(6, edges.size()); }
.bothE("created") .has("weight", P.lt(1.0)) .otherV()
assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.inV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.otherV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).bothE("knows").filter(__.otherV().is(vs[50])), TitanVertexStep.class); assertNumStep(1, 2, gts.V(sv[0]).bothE("knows").filter(__.inV().is(vs[50])), TitanVertexStep.class, TraversalFilterStep.class);
james.addEdge("look", book6, "timestamp", "2017-5-3 12:00:08.0"); graph.tx().commit(); assert graph.traversal().V(book6.id()).bothE().hasNext(); System.out.println(">>>> removing vertex: " + james); james.remove(); graph.tx().commit(); assert !graph.traversal().V(james.id()).hasNext(); assert !graph.traversal().V(book6.id()).bothE().hasNext();
/** * @see GraphTraversal#bothE(String...) */ public static GraphTraversal<Vertex, Edge> bothE(final String... edgeLabels) { return __.<Vertex>start().bothE(edgeLabels); }
assertEquals(1, g.V(convertToVertexId("josh")).in().count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).in().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).both("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).both("knows").count().next().longValue());
assertEquals(0, sg.V(convertToVertexId("josh")).in().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).both("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).both("knows").count().next().longValue());
assertEquals(0, sg.V(convertToVertexId("josh")).in().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).both("knows").count().next().longValue()); assertEquals(0, sg.V(convertToVertexId("josh")).both("knows").count().next().longValue());
assertEquals(1, sg.V(convertToVertexId("josh")).in().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).bothE().count().next().longValue()); assertEquals(3, g.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, sg.V(convertToVertexId("josh")).both().count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).out("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).bothE("created").count().next().longValue()); assertEquals(2, g.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).both("created").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).in("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).bothE("knows").count().next().longValue()); assertEquals(1, g.V(convertToVertexId("josh")).both("knows").count().next().longValue()); assertEquals(1, sg.V(convertToVertexId("josh")).both("knows").count().next().longValue());
@Test @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_VERTICES) @FeatureRequirement(featureClass = Graph.Features.VertexFeatures.class, feature = Graph.Features.VertexFeatures.FEATURE_ADD_PROPERTY) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_EDGES) @FeatureRequirement(featureClass = Graph.Features.EdgeFeatures.class, feature = Graph.Features.EdgeFeatures.FEATURE_ADD_PROPERTY) public void shouldHandleBothEdgesGraphFilterOnSelfLoop() { assertEquals(0l, IteratorUtils.count(graph.vertices())); assertEquals(0l, IteratorUtils.count(graph.edges())); // these vertex label, edge label, and property names/values were copied from existing tests StarGraph starGraph = StarGraph.open(); Vertex vertex = starGraph.addVertex(T.label, "person", "name", "furnace"); Edge edge = vertex.addEdge("self", vertex); edge.property("acl", "private"); // traversing a self-loop should yield the edge once for inE/outE // and the edge twice for bothE (one edge emitted two times, not two edges) assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE())); assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE())); assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE())); // Try a filter that retains BOTH GraphFilter graphFilter = new GraphFilter(); graphFilter.setEdgeFilter(__.bothE("self")); starGraph = starGraph.applyGraphFilter(graphFilter).get(); // Retest traversal counts after filtering assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().inE())); assertEquals(1L, IteratorUtils.count(starGraph.traversal().V().outE())); assertEquals(2L, IteratorUtils.count(starGraph.traversal().V().bothE())); }
assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.inV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).outE("knows").filter(__.otherV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 1, gts.V(sv[0]).bothE("knows").filter(__.otherV().is(vs[50])), JanusGraphVertexStep.class); assertNumStep(1, 2, gts.V(sv[0]).bothE("knows").filter(__.inV().is(vs[50])), JanusGraphVertexStep.class, TraversalFilterStep.class);
assertTrue(traversal.getTraverserGenerator() instanceof B_O_TraverserGenerator); traversal = sg.V().bothE().iterate().asAdmin(); assertTrue(traversal.getTraverserGenerator() instanceof B_O_TraverserGenerator); traversal = sg.V().bothE().otherV().iterate().asAdmin(); assertTrue(traversal.getTraverserGenerator() instanceof B_LP_O_P_S_SE_SL_TraverserGenerator); traversal = sg.V().both().iterate().asAdmin();
assertTrue(traversal.getTraverserGenerator() instanceof B_O_TraverserGenerator); traversal = itag.V().bothE().iterate().asAdmin(); assertTrue(traversal.getTraverserGenerator() instanceof B_O_TraverserGenerator); traversal = itag.V().bothE().otherV().iterate().asAdmin(); assertTrue(traversal.getTraverserGenerator() instanceof B_O_TraverserGenerator); traversal = itag.V().both().iterate().asAdmin();