Search code examples
azure-cosmosdbgremlin

How does this Gremlin query be executed?


I'm trying to understand how the following Gremlin query will be executed?

g.V('california').repeat(out('interstate')).emit().repeat(out('highway')).emit().tree()

I assume the travesal finds all the nodes/vertices from california with interstate edge and for each of those interstate vertex, it finds all the highways. Then it makes a tree structure with interstate and it's highways. Is this correct?


Solution

  • Starting from california, traversers follow all out-directed interstate edges until there's no more interstate edge left. From all vertices, that were found along the path, the traversers will then follow all out-directed highway edges, again until there's no highway edge left.

    Both repetitions can very well run into a cyclic path (meaning, the traversal will never come to an end). However, should an end be found, all paths will be merged into a tree structure.