graph
graph copied to clipboard
Add an example that clarifies the effects of dedup having global scope
Cases like this can be confusing to Gremlin users
gremlin> g.V(3).out().out().count()
==>7858
gremlin> g.V(3).out().out().dedup().count()
==>992
gremlin> g.V(4).out().out().count()
==>6817
gremlin> g.V(4).out().out().dedup().count()
==>812
gremlin> g.V(3,4).as('a').out().out().group().by(select('a').id()).by(count())
==>[3:7858,4:6817]
gremlin> g.V(3,4).as('a').out().out().dedup().group().by(select('a').id()).by(count())
==>[3:992]
Once dedup is added the second "a traverser" is only going to get the leftovers. In cases where every vertex is common across each traverser, the second traverser is left with nothing. To fix this requires adding some local scope to part of the query.
gremlin> g.V(3,4).as('a').local(out().out().dedup()).group().by(select('a').id()).by(count())
==>[3:992,4:812]