Does Gremlin do DFS or BFS?

Does Gremlin perform a Depth First Search (DFS) or Breadth First Search (BFS) when traversing?
S
spmallette395d ago
While it might seem like a simple question, this question requires a bit of explanation. The starting answer is that Gremlin is a mixed BFS/DFS system given barrier() injection by LazyBarrierStrategy to achieve bulking optimizations. There is some reading to do in the links I've supplied below. That said, seach behavior is also graph system dependent. For example, if you are doing Gremlin in gremlin-spark and OLAP then it is BFS and OLTP on a system like Neptune which lets you specify the search behavior explicitly with a query hint. Here is some additional reading on the subject: [1] https://tinkerpop.apache.org/docs/current/reference/#barrier-step [2] https://tinkerpop.apache.org/docs/current/reference/#a-note-on-barrier-steps You will want to understand how to use profile() and explain() to properly see what your traversal is doing on a particular system to ensure it is behaving as you wish it to.
H
HailDevil395d ago
Thanks for the detailed answer @spmallette I went through the links you provided and seems like a bit more research is needed from my side to understand the behavior of the query in my case. 🙂
P
porunov342d ago
@spmallette Thanks for explanation! I’m trying to optimise repeat step in JanusGraph. I was struggling with understanding in what order it’s traversed. I will experiment a bit more next week to understand it, but currently my testing (which could be wrong) showed that even so it’s BFS, the ordering of traversing children steps is strange. I would expect returned elements on the same level should be traversed in the same order, but sometimes it looks like it’s isn’t the case and the newer returned children could be traversed earlier than the older returned children. Again, that could be a bug in my testing, but so far I can’t say in what order will the next level be traversed. After checking it again I found flows in the tests I did. Fixing them I can now confirm that BFS works in correct ordering for repeat step (i.e. oldest accessed children are traversed first on the next loop). Sorry if I confused anyone with the previous question.
Want results from more Discord servers?
Add your server
More Posts
Self-service roles for providers and areas of expertiseWe have roles for providers right now as listed in #roles - they are handed out by moderators. So faMore elaborate sack examples in the docsThere are a few examples for the `sack` step, but it would be good to have a more concrete one. For Isolated vertices vs connected vertices with no join benefitIs there any downside to storing an isolated vertex with references to other nodes? Creating relatioSubgraph Strategy with vertexProperties + project().by("field name") = crashRunning the following query: `g.withStrategies(new SubgraphStrategy(vertexProperties: constant(true)Custom MutationListener on TransactionHello everyone, I'm a beginner regarding tinkerpop and i'm trying to fire my custom listener after Gremlin Query to give all related items in versioned graphI am working on a requirement where I need to store all version of a record in a Graph Database say Order group count result alphabeticallyHi! Given the following query and results in the enclosed image: how would I sort the labels alphabTransactions - tx.commit vs tx.closeI have a question related to transactions. I'm having issues with tx.commit() hanging locally when rExtracting the ProjectStep of a GraphTraversal instance during unit testing**Tl;dr** Given an instance of `GraphTraversal<?, Map<String, Object>>`, is it possible to extract tWhen can we get a non-RC release for Python 3.11 support in Production Envs?There was a bug where the version of aiohttp was too strict and blocked Python 3.11 support. ( httpsSubgraph query returns String instead of TinkerGraph Object in Fluent Java APIHi guys. I am running the following query in the console and it works fine: `g.V().has('user', 'id'Multiple Graphs in Gremlin Server?How do I manage multiple graphs? Is there an option where I can select which graph to use for query Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree objectDid a little bit of debugging and it seems that the issue has to do with a cast to Tree before calliThe query gets slower as the number of vertices that already exist in JanusGraph gets bigger and bigWhen i start JanusGraph and perform any query like : - g.V().has(properties).limit(10).toList() - g.