A code snippet for BFS begs some explanation. Let's see how I do. First, let's assume a Gremlin language without optimization - doing:
g.V().out().out()
will result in a depth first search. You can force BFS with barrier():
g.V().out().barrier().out()
which basically will force the step prior to drain before moving on to the next step. You can read more about barrier() here:
What you will read though is that Gremlin is not without optimizations as we first assumed and that LazyBarrierStrategy will automatically inject "small" barriers where it thinks it can optimize with bulking, so even simple:
g.V().out().out()
will actually compile to:
g.V().out().barrier(2500).out()
so depending on how large your graph is, you really get a mixed form of processing.