Querying Graphs with Gremlin

Tags: , , ,

Please help me with the query on Gremlin lang

I have a graph with 2 types of vertices: User and Group. I need to find friends of ‘U1’. If users have edges ( member or invite ) to ‘Group A’ need to flag them like the below result.

[Graph image](https://ibb.co/D9VPKw4)

Expected result : [ { U2: ‘Member’}, { U3: ‘Invited’ }, { U4: ‘Member’} ]


g.V().has('User', 'name', 'U1')
  .bothE('invited', 'member', 'friend')
  .where(or(inV().has('Group', 'name', 'G1'), outV().has('User', 'name', 'U1')))

Source: stackoverflow