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 ?
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.
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:
Welcome to Stack Overflow! Excessive promotion of a specific product/resource may be perceived by the community as spam. Take a look at the help center, specially What kind of behavior is expected of users?'s last section: Avoid overt self-promotion. You might also be interested in How to not be a spammer and How do I advertise on Stack Overflow?.
You should add emit() after times(1) so that the loop outputs all the nodes. Currently it only outputs nodes from the last n-th hop.
There is another bug which results in only alter-alter connections especially in 1-hop network, because it doesn't aggregate source vertex. To resolve this write 'emit()' before repeat step.