I want to get the list of friends of all the users of the graph in a 2D array fornat like:
[
[friend, friend, friend],
[friend, friend, friend],
[friend, friend, friend],
]
I've came up with this query:
g.V().hasLabel("user").both("friend");
But that query returns the friends of all the users and puts it in to the same list, not what I want, I want a 2D array where each item is the list of friends for each user.
What do I need to achieve this?
Self response:
bechbd response is correct but a more simple and readable solution is to use flatMap()
like this:
g.hasLabel("user").flatMap(both("friend").fold())