I wanted minimum and maximum length of the two different connected node types nodes. I got two different queries but both are slow, I want it to be fast.
1st :> This giving me correct ans.
g.withSack(0).V().hasLabel("People").as("from","to").
repeat(both().as("to").dedup("from","to").
sack(sum).by(constant(1))).
emit(hasLabel("People")).
sack().dedup().fold().
project("min", "max").
by(choose(count(local).is(0), constant(0), min(local))).
by(choose(count(local).is(0), constant(0), max(local)))
and
2nd:> This gives me adding from nodes to the length( means min+1, and max+1)
g.V().hasLabel("People")
.as("from" ,"to" )
.repeat(both().as("to").dedup("from", "to")).emit(hasLabel("People")).hasLabel("People")
.select(all, "to").count(local).dedup().as("len").fold()
.project("min", "max")
.by(choose(count(local).is(0), constant(0), min(local)))
.by(choose(count(local).is(0), constant(0), max(local)))
Both query taking the same time for execution, but slow as per the neo4j cypher query does. Gremlin execution time is 50 times more than cypher query. Here is the cypher query