How to traverse a connected component and return the path travelled

已查看 56 次
跳至第一个未读帖子

Shaoor Jan

未读,
2021年7月29日 06:11:572021/7/29
收件人 Gremlin-users
Hi, 
I'm new to Gremlin and would appreciate some help. 

I want to traverse a connected component starting from a node and return the path. I need the path so that I can visualize the graph in AWS Neptune. 

The solutions present online do not return a path.  

The screenshot shows the end result I want to get. 

Thanks! 
Screen Shot 2021-07-29 at 12.37.31 AM.png

HadoopMarc

未读,
2021年7月31日 04:43:142021/7/31
收件人 Gremlin-users
I have no Neptune workbench available to experiment with, but I guess the following should work:

g.V().has('my_prop', 'my_value').
    emit(cyclicPath().or().not(both())).repeat(
        __.where(without('a')).aggregate('a').both()).until(cyclicPath()
    ).path()


Best wishes,   Marc

Op donderdag 29 juli 2021 om 12:11:57 UTC+2 schreef jansh...@gmail.com:

Shaoor Jan

未读,
2021年8月4日 12:14:022021/8/4
收件人 Gremlin-users
Hi Marc, 
Thank you! that was helpful. 

I used a similar query. I posted it below in case it might be helpful for someone. 

g.V().has('my_label', 'my_prop', 'my_value')
     .until(cyclicPath().or().hasLabel('my_label'))        //// I wanted to if I hit a node with a particular label 
     .repeat(bothE().otherV().simplePath()).emit()
     .path()

Thank You!
回复全部
回复作者
转发
0 个新帖子