/** * @see GraphTraversal#dedup(String...) */ public static <A> GraphTraversal<A, A> dedup(final String... dedupLabels) { return __.<A>start().dedup(dedupLabels); }
/** * @see GraphTraversal#dedup(Scope, String...) */ public static <A> GraphTraversal<A, A> dedup(final Scope scope, final String... dedupLabels) { return __.<A>start().dedup(scope, dedupLabels); }
@Override public Traversal<Vertex, Vertex> get_g_V_both_both_dedup() { return g.V().both().both().dedup(); }
@Override public Traversal<Vertex, Vertex> get_g_V_dedup_connectedComponent_hasXcomponentX() { return g.V().dedup().connectedComponent().has(ConnectedComponent.component); }
@Override public Traversal<Vertex, Integer> get_g_V_both_properties_dedup_hasKeyXageX_value() { return g.V().both().properties().dedup().hasKey("age").value(); }
@Override public Traversal<Vertex, String> get_g_V_both_hasXlabel_softwareX_dedup_byXlangX_name() { return g.V().both().has(T.label, "software").dedup().by("lang").values("name"); }
@Override public Traversal<Vertex, String> get_g_V_both_name_order_byXa_bX_dedup_value() { return g.V().both().<String>properties("name").order().by((a, b) -> a.value().compareTo(b.value())).dedup().value(); }
@Test @LoadGraphWith public void shouldNeverPropagateANoBulkTraverser() { try { assertFalse(g.V().dedup().sideEffect(t -> t.asAdmin().setBulk(0)).hasNext()); assertEquals(0, g.V().dedup().sideEffect(t -> t.asAdmin().setBulk(0)).toList().size()); g.V().dedup().sideEffect(t -> t.asAdmin().setBulk(0)).sideEffect(t -> fail("this should not have happened")).iterate(); } catch (VerificationException e) { // its okay if lambdas can't be serialized by the test suite } }
@Override public Traversal<Vertex, Path> get_g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path() { return g.V().as("a").out("created").as("b").in("created").as("c").dedup("a", "b").path(); }
@Override public Traversal<Vertex, Map<String, List<Double>>> get_g_V_group_byXlabelX_byXbothE_weight_dedup_foldX() { return g.V().<String, List<Double>>group().by(T.label).by(bothE().values("weight").dedup().fold()); }
@Test @LoadGraphWith(MODERN) public void shouldFilterVertexCriterionAndKeepLabels() throws Exception { // this will exclude "peter" final Traversal<Vertex, ?> vertexCriterion = has("name", P.within("ripple", "josh", "marko")); final GraphTraversalSource sg = g.withStrategies(SubgraphStrategy.build().vertices(vertexCriterion).create()); assertEquals(9, g.V().as("a").out().in().as("b").dedup("a", "b").count().next().intValue()); assertEquals(2, sg.V().as("a").out().in().as("b").dedup("a", "b").count().next().intValue()); final List<Object> list = sg.V().as("a").out().in().as("b").dedup("a", "b").values("name").toList(); assertThat(list, hasItems("marko", "josh")); }
@Override public Traversal<Vertex, Map<String, Vertex>> get_g_V_matchXa__a_both_b__b_both_cX_dedupXa_bX() { return g.V().<Vertex>match( as("a").both().as("b"), as("b").both().as("c")).dedup("a", "b"); }
@Override public Traversal<Vertex, Map<String, Vertex>> get_g_V_matchXa_both_b__b_both_cX_dedupXa_bX_byXlabelX() { return g.V().<Vertex>match( as("a").both().as("b"), as("b").both().as("c")).dedup("a", "b").by(T.label); }
@Override public Traversal<Vertex, Map<String, String>> get_g_V_out_asXxX_in_asXyX_selectXx_yX_byXnameX_fold_dedupXlocal_x_yX_unfold() { return g.V().out().as("x").in().as("y").select("x", "y").by("name").fold().dedup(Scope.local, "x", "y").unfold(); }
@Override public Traversal<Vertex, String> get_g_V_outE_asXeX_inV_asXvX_selectXeX_order_byXweight_ascX_selectXvX_valuesXnameX_dedup() { return g.V().outE().as("e").inV().as("v").select("e").order().by("weight", Order.asc).select("v").<String>values("name").dedup(); }
@Override public Traversal<Vertex, String> get_g_V_matchXa_knows_b__b_created_c__a_created_cX_dedupXa_b_cX_selectXaX_byXnameX() { return g.V().match( as("a").out("knows").as("b"), as("b").out("created").as("c"), as("a").out("created").as("c")).dedup("a", "b", "c").<String>select("a").by("name"); }
@Override public Traversal<Vertex, Map<Object, List<Object>>> get_g_V_hasXname_rippleX_inXcreatedX_peerPressure_withXedges_outEX_withXpropertyName_clusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX() { return g.V().has("name", "ripple").in("created").peerPressure().with(PeerPressure.edges,__.outE()).with(PeerPressure.propertyName, "cluster").repeat(__.union(__.identity(), __.both())).times(2).dedup().valueMap("name", "cluster"); } }
@Override public Traversal<Vertex, String> get_g_VX3X_repeatXbothX_createdXX_untilXloops_is_40XXemit_repeatXin_knowsXX_emit_loopsXisX1Xdedup_values(final Object v3Id) { return g.V(v3Id).repeat(__.both("created")).until(loops().is(40)).emit(__.repeat(__.in("knows")).emit(loops().is(1))).dedup().values("name"); }
@Override public Traversal<Vertex, String> get_g_VX6X_repeatXa_bothXcreatedX_simplePathX_emitXrepeatXb_bothXknowsXX_untilXloopsXbX_asXb_whereXloopsXaX_asXbX_hasXname_vadasXX_dedup_name(final Object v6Id) { return g.V(v6Id).repeat("a", both("created").simplePath()).emit(__.repeat("b", __.both("knows")).until(loops("b").as("b").where(loops("a").as("b"))).has("name", "vadas")).dedup().values("name"); }
@Test @LoadGraphWith(MODERN) public void shouldFailWithImproperTraverserRequirements() throws Exception { final VertexProgramQ vp = VertexProgramQ.build().property("pl").useTraverserRequirements(false).create(); try { g.V().repeat(__.out()).emit().program(vp).dedup() .forEachRemaining((Vertex v) -> assertFalse(v.property("pl").isPresent())); } catch (VerificationException ex) { assumeNoException(ex); } }