Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
627 views
in Technique[技术] by (71.8m points)

tinkerpop - Gremlin Emit Times Loses Lower Hop Solution (Gremlify Example Included)

Relatively new to gremlin and working with this query:

g.V().or(has('LOCATION', eq('IPLTINMYGT0')),
has('LOCATION', eq('IPLTINMYK01'))).
repeat(bothE().otherV()).emit().times(1).has('LOCATION',eq('FSHRIN01K00')).dedup().
path().by(valueMap('LOCATION')).dedup()

And this simple graph on gremlify: https://gremlify.com/grrlq20ig57/1

When I vary the query from times(1) to times(2), the result that shows up in the times(1) query no longer shows up in the times(2) query. I'm guessing this can be read as 'at most 1 hop' or 'at most 2 hops' so I was expecting when I went to higher level hops the times(1) result would still be included. Any way to get the times(1) result to show up (in addition to the times(2) result) when issuing times(2) queries (or greater)? Does this behavior have anything to do with DFS vs BFS? Any help is appreciated. Thanks!

question from:https://stackoverflow.com/questions/65904721/gremlin-emit-times-loses-lower-hop-solution-gremlify-example-included

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Your use of dedup() after has('LOCATION',eq('FSHRIN01K00')) is filtering away one of the vertices emitted when you do times(2). Therefore when you call path() it is only called once on the traverser that survives that filter. If you remove that dedup() you get both paths traversed.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...