0
votes

I have this schema for the graph database.

I need to find users who have picked calls from all calls labels that it is connected to, for program X.

I am quite new to gremlin and my vocabulary is limited.

I want to find a way to check if the number of incoming edges to users with picked == yes is the same as the total number of incoming edges to the user for a given program X. (that is, if every edge from program X to user via calls contains picked==yes)

I am unable to count twice in the same query and compare those values to decide if user satisfies criteria. My approach is as follows:

g.V().hasLabel("User").filter(inE().count().is(neq(0))).filter(inE().outV().in().has("program","name","X")).filter(inE().has("connected","yes").has("picked","no").count().is(eq(0))).values("name")

Essentially, I am removing all cases that I know do not lead to my expeced result (null nodes in User, Users who connected but did not pick up). This does not generate the right output when I tested it against manual examination result.

Thanks!

1

1 Answers

0
votes

From the description alone I would say that this is your query:

g.V().hasLabel('User').
  filter(project('a','b').
           by(inE().has('picked','yes').count()).
           by(out().has('program','X').count()).
         where('a',eq('b')))

If that doesn't return the expected result, then please provide a snippet that creates a small sample graph along with the expected result.