/** * @see GraphTraversal#inE(String...) */ public static GraphTraversal<Vertex, Edge> inE(final String... edgeLabels) { return __.<Vertex>start().inE(edgeLabels); }
@Override public Traversal<Vertex, Edge> get_g_VX2X_inE(final Object v2Id) { return g.V(v2Id).inE(); }
@Override public Traversal<Vertex, Vertex> get_g_VX2X_inE_outV(final Object v2Id) { return g.V(v2Id).inE().outV(); }
@Override public Traversal<Vertex, Vertex> get_g_VX1X_outXcreatedX_inEXcreatedX_rangeX1_3X_outV(final Object v1Id) { return g.V(v1Id).out("created").inE("created").range(1, 3).outV(); }
@Test public void testQueryInEdgesOfVertexByLabel() { HugeGraph graph = graph(); init18Edges(); Vertex java3 = vertex("book", "name", "java-3"); List<Edge> edges = graph.traversal().V(java3.id()).inE().toList(); Assert.assertEquals(5, edges.size()); edges = graph.traversal().V(java3.id()).inE("look").toList(); Assert.assertEquals(4, edges.size()); }
@Override public Traversal<Vertex, Path> get_g_VX1X_outEXcreatedX_inV_inE_outV_path(final Object v1Id) { return g.V(v1Id).outE("created").inV().inE().outV().path(); }
@Test public void testQueryInEdgesOfVertexBySortkey() { HugeGraph graph = graph(); init18Edges(); Vertex java3 = vertex("book", "name", "java-3"); List<Edge> edges = graph.traversal().V(java3.id()) .inE("look").toList(); Assert.assertEquals(4, edges.size()); edges = graph.traversal().V(java3.id()) .inE("look").has("time", "2017-5-27").toList(); Assert.assertEquals(3, edges.size()); }
@Test public void testQueryInEdgesOfVertexByLabelAndFilter() { HugeGraph graph = graph(); init18Edges(); Vertex java3 = vertex("book", "name", "java-3"); List<Edge> edges = graph.traversal().V(java3.id()) .inE().has("score", 3).toList(); Assert.assertEquals(3, edges.size()); edges = graph.traversal().V(java3.id()) .inE("look").has("score", 3).toList(); Assert.assertEquals(2, edges.size()); edges = graph.traversal().V(java3.id()) .inE("look").has("score", 4).toList(); Assert.assertEquals(1, edges.size()); edges = graph.traversal().V(java3.id()) .inE("look").has("score", 0).toList(); Assert.assertEquals(1, edges.size()); }
@Test public void testQueryInEdgesOfVertexWithResult1() { HugeGraph graph = graph(); init18Edges(); Vertex java = vertex("language", "name", "java"); List<Edge> edges = graph.traversal().V(java.id()).inE().toList(); Assert.assertEquals(1, edges.size()); }
@Test public void testQueryInEdgesOfVertexWithResultN() { HugeGraph graph = graph(); init18Edges(); // Query IN edges of a vertex Vertex james = vertex("author", "id", 1); List<Edge> edges = graph.traversal().V(james.id()).inE().toList(); Assert.assertEquals(2, edges.size()); }
@Test public void testQueryInEdgesOfVertexWithResult0() { HugeGraph graph = graph(); init18Edges(); Vertex guido = vertex("author", "id", 2); List<Edge> edges = graph.traversal().V(guido.id()).inE().toList(); Assert.assertEquals(0, edges.size()); }
@Override public Traversal<Vertex, String> get_g_V_out_outE_inV_inE_inV_both_name() { return g.V().out().outE().inV().inE().inV().both().values("name"); }
@Benchmark public List<Edge> g_E_hasLabelXwrittenByX_whereXinV_inEXsungByX_count_isX0XX_subgraphXsgX() throws Exception { return g.E().hasLabel("writtenBy").where(__.inV().inE("sungBy").count().is(0)).subgraph("sg").toList(); } }
@Override public Traversal<Vertex, Map<String, Object>> get_g_V_hasXname_gremlinX_inEXusesX_order_byXskill_ascX_asXaX_outV_asXbX_selectXa_bX_byXskillX_byXnameX() { return g.V().has("name", "gremlin").inE("uses").order().by("skill", Order.asc).as("a").outV().as("b").select("a", "b").by("skill").by("name"); }
"time", "2017-6-7"); edges = graph.traversal().V(java1.id()).inE().toList(); Assert.assertEquals(1, edges.size()); edges = graph.traversal().V(java2.id()).inE().toList(); Assert.assertEquals(0, edges.size()); edges = graph.traversal().V(java3.id()).inE().toList(); Assert.assertEquals(0, edges.size());
@Parameterized.Parameters(name = "expectInterruption({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"g_V", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V()}, {"g_V_out", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().out()}, {"g_V_outE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().outE()}, {"g_V_in", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().in()}, {"g_V_inE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().inE()}, {"g_V_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V().properties()}, {"g_E", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E()}, {"g_E_outV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().outV()}, {"g_E_inV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().inV()}, {"g_E_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E().properties()}, }); }
@Parameterized.Parameters(name = "expectInterruption({0})") public static Iterable<Object[]> data() { return Arrays.asList(new Object[][]{ {"g_V", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_V_out", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.out()}, {"g_V_outE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outE()}, {"g_V_in", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.in()}, {"g_V_inE", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inE()}, {"g_V_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.V(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, {"g_E", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t}, {"g_E_outV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.outV()}, {"g_E_inV", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.inV()}, {"g_E_properties", (Function<GraphTraversalSource, GraphTraversal<?,?>>) g -> g.E(), (UnaryOperator<GraphTraversal<?,?>>) t -> t.properties()}, }); }
@Override public Traversal<Vertex, String> get_g_V_matchXa_hasXsong_name_sunshineX__a_mapX0followedBy_weight_meanX_b__a_0followedBy_c__c_filterXweight_whereXgteXbXXX_outV_dX_selectXdX_byXnameX() { return g.V().match( as("a").has("song", "name", "HERE COMES SUNSHINE"), as("a").map(inE("followedBy").values("weight").mean()).as("b"), as("a").inE("followedBy").as("c"), as("c").filter(values("weight").where(P.gte("b"))).outV().as("d")). <String>select("d").by("name"); }
@Benchmark public GraphTraversal.Admin<Vertex,Vertex> testTranslationLong() { return translator.translate(g.V().match( as("a").has("song", "name", "HERE COMES SUNSHINE"), as("a").map(inE("followedBy").values("weight").mean()).as("b"), as("a").inE("followedBy").as("c"), as("c").filter(values("weight").where(P.gte("b"))).outV().as("d")). <String>select("d").by("name").asAdmin().getBytecode()); }
@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())); }