1
votes

New to gremlin and need help. I have a graph contains below vertices and relationship.

A ---hasLocation---> B <---uses--- C

Possible cases data stored in the graph are:

1) A --> B <-- C

2) A --> B

3) A

4) C

5) C <-- B

I would like to have a single gremlin query to ONLY return all vertices in above 1) which has the complete path and filter rest of the cases. The gremlin traversal must start from vertex A.

1

1 Answers

4
votes

If I understand you well, you want:

g.V('A')                // Start from vertex A, assuming vertex id is 'A'
    .out('hasLocation') // Traverse in the outgoing direction from 'A' to the 'B' vertex
    .in('uses')         // Traverse in the ingoing direction from 'B' to the 'C' vertex
    .path()             // Display path