## Breadth-First Traversal Fact Check
Using the Neptune Query Profiling, I have found out that Gremlin queries seems to use depth first strategy to search things and as a result it tends to be both time and resource intensive especially when what I am looking for is a node just a 1 or 2 levels below.
To do a Breadth-First Traversal the following approach has been suggested, but not sure if this really does the trick.
If my goal is to find nearest nodes quickly, what could be efficient approaches?
Solution:Jump to solution
Neptune uses BFS as the default traversal strategy. You can change the method in which a
repeat()
is executed via the query hint as noted here: https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-query-hints-repeatMode.htmlGremlin repeatMode query hint - Amazon Neptune
The Neptune repeatMode query hint specifies how the Neptune engine evaluates the repeat() step in a Gremlin traversal: breadth first, depth first, or chunked depth first.
1 Reply
Solution
Neptune uses BFS as the default traversal strategy. You can change the method in which a
repeat()
is executed via the query hint as noted here: https://docs.aws.amazon.com/neptune/latest/userguide/gremlin-query-hints-repeatMode.htmlGremlin repeatMode query hint - Amazon Neptune
The Neptune repeatMode query hint specifies how the Neptune engine evaluates the repeat() step in a Gremlin traversal: breadth first, depth first, or chunked depth first.