简体   繁体   中英

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?

Just apply some filter to your edges:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM