Search code examples
graph-databasesgremlintinkerpop3

Return list of Vertex (list-2), whose relationship are only with a subset of another vertexes(list-1)


My question is that I want to return all the vertexes whose relations are only with a subset of another list of vertexes.

For example I will pass a list of person, for ex: Ram, David and Alan. I should return back the person list who are only friend to Ram, David or Alan (in any combination, any of them, with any two or all of them)

How can I do that?


Solution

  • OK so from the comments/discussion - I think this is what you are looking for:

    g.V().hasLabel('person').
       filter(not(out('knows').has('name',without('Ram','David','Alan')))).
       out('knows').
       path().by('name')
    

    Cheers, Kelvin