Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...