0

I am using DSE graph 5.X.

Suppose I have two Vertex, Vertex A and Vertex B.

Dse documentation says about getting vertex and edges individually.

But what I am looking for is getting all vertexes of a particular label or all edges between two vertexes.

How can I retrieve all edges between Vertex A and Vertex B in Java code?

E.g List<Edge> edges = graph.getEdges(fromVertex, toVertex);

Thanks you ..!

Erick Ramirez
  • 13,964
  • 1
  • 18
  • 23
Prakash P
  • 3,582
  • 4
  • 38
  • 66

2 Answers2

3

In general, the gremlin recipes page is good for stuff like this http://tinkerpop.apache.org/docs/current/recipes/#between-vertices

If you know the vertex IDs then you can probably go with

g.V(ids).outE().where(inV().id().is(within(ids)))
Bob B
  • 4,484
  • 3
  • 24
  • 32
  • what is `ids` here, id of a particular vertex or group of ids – Prakash P Jan 25 '17 at 12:11
  • g.V() is pretty flexible. Take a look http://tinkerpop.apache.org/javadocs/current/full/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource.html#V-java.lang.Object...- – Bob B Jan 25 '17 at 16:30
2

Hi Let me give you the dse graph query that will count's the No. of edges between two vertices , then you can execute or run the same query in java : -

g.V().hasLabel('users').has('userId','8e4b334a-388e-4623-91d6-fad7570e3129').outE('hasA').as('e').inV().hasLabel('mobileNo').select('e').count()

It finds for The vertex having label 'USERS' and in Particular to Vertex having some USER_ID , to Vertex connecting as 'MOBILE_NO' .

You can skip the user_id part query and can count between any two vertices of specific labels .

Piyush_Rana
  • 305
  • 3
  • 15