user2524707 user2524707 - 2 months ago 17
Java Question

Titan receive edge which connects any nodes of two sets

I am trying to retrieve all edges which connect any of the nodes in set A and one of the nodes in set B.
Current approach:

ArrayList<Vertex> nodeStartList = getVertexList(relationshipStorage.getStartNode(), g, snapshotId);
ArrayList<Vertex> nodeEndList = getVertexList(relationshipStorage.getEndNode(), g, snapshotId);

The vertex lists are correctly filled (Already checked that)

GraphTraversal<Vertex, Edge> tempOutput = g.V(nodeStartList.toArray()).bothE().where(;

But I always retrieve an empty list from output.
And I'm sure I have edges matching my query.


Here is something that works:

gremlin> graph =;
==>tinkergraph[vertices:0 edges:0]
gremlin> v1 = graph.addVertex();
gremlin> v2 = graph.addVertex();
gremlin> v3 = graph.addVertex();
gremlin> v4 = graph.addVertex();
gremlin> v5 = graph.addVertex();
gremlin> v6 = graph.addVertex();
gremlin> v1.addEdge("edgeLabel", v4);
gremlin> v2.addEdge("edgeLabel", v5);
gremlin> v3.addEdge("edgeLabel", v6);

The above creates 6 vertices with 3 edges between them. I can then find those edges with:

gremlin> graph.traversal().V(v1, v2, v3).bothE().filter(otherV().is(within(v4, v5, v6)))