Given two Gremlin queries q1
and q2
and their results ri = qi.toSet()
, I want to find all nodes in r1
that have a connection to a node in r2
- ignoring edge labels and direction.
My current approach included the calculation of shortest paths between the two result sets:
q1.shortestPath().with_(ShortestPath.target, q2).toList()
However, I found the shortest path calculation in Tinkerpop is unsuitable for this purpose because the result will be empty if there are nodes in r1 without any connection to any node in r2.
Instead, I thought about connected components, but the connectedComponents()
step will yield all connected components found and I would have to filter them to find the connected component that meets the above requirements.
Do you have suggestions on how I could tackle this problem in gremlin-python?