Search code examples
gremlintinkerpop

Gremlin-Python: Switch traversal from edges to vertices


I want to perform a centrality calculation:

g.V().repeat(groupCount('m').by('name').out()).times(5).cap('m')

using only a subset of edges:

g.E().has('some-property', 'some-value')

Unfortunately, the .subgraph() step returns a dict in gremlin-python, so I can't use it to perform further traversals.

Is there another way to combine an edge-oriented traversal with a vertex-oriented one?


Solution

  • Just apply some filter to your edges:

    g.V().
      repeat(groupCount('m').
               by('name').
             outE().has(....).inV()).
        times(5).
      cap('m')