Warm tip: This article is reproduced from stackoverflow.com, please click
gremlin gremlinpython janusgraph

Ego Network using Gremlin

发布于 2020-04-13 10:51:23

I'm new to gremlin and have been working on creating an ego network using Gremlin.

Ego-alter connections are pretty easy to find, but the problem lies in finding alter-alter connections. Is there a way to write a query which extracts all the alter-alter connections along with ego-alter connections in a n-radius ego network ?

enter image description here

For example in the Graph of the gods. 1-Radius ego network for 'jupiter' has ego-alter connections as 'Jupiter-neptune', 'Jupiter-pluto'. While the alter-alter connection is 'Neptune-Pluto'. How do I retrieve these connections.

Thanks in advance.

Questioner
Shubham Yadav
Viewed
31
gremlify 2020-02-22 17:46

This is my attempt for finding the 'alter-alter' connections

g.V().has('name', 'jupiter').as('ego').repeat(out()).times(1).emit()
.dedup().aggregate('alter')
.as('from').out()
.where(within('alter'))
.as('to').select('from', 'to').by('name').dedup()

The number inside the times step is your redius.

In addition I created the graph in gremlify, so you can play with this query:

https://gremlify.com/1p