0

I have a graph like below

a->b
b->c
d->c
a->c
e->d
c->e
e->a
f->g
g->a
c->h

If i select c, it should return all incoming direct and indirect nodes with edges along the path.

It should return a,b,d,e,f,g

I tried below and its not working

g.V(nodeId) 
  .repeat(__.inE().aggregate('edges').inV().aggregate('nodes').simplePath())
  .emit()
  .dedup()
  .cap('edges', 'nodes') 
  .project('edges', 'nodes')
  .by(select('edges').unfold().dedup().id().fold()) 
  .by(select('nodes').unfold().dedup().id().fold()) 
  .next()

it is returning all the direct edges, and only one direct node, im not able to find the issue.

1 Answer 1

1

inE() followed by an inV() would dictate starting from a node, going to the edge, and then going back to the node where you started.

If you're looking to traverse an edge, you need to follow inE().outV() or outE().inV() or bothE().otherV() as the patterns to traverse from one node to the neighboring node.

Not the answer you're looking for? Browse other questions tagged or ask your own question.