Is it possible to walk 2 different graphs using custom TraversalStrategy in Gremlin?

I have 2 different graphs in 2 different Neptune cluster. Both of them can have few reference vertices referring to vertex in other graph. e.g. As we walk through graph A and reach a reference vertex (referring to vertex in graph B), we should be able to traverse normally further inside Graph B and get the results of the query. Basically Graph A + Graph B should act as single virtual graph.
Solution:
At this time, there would be no easy way to do this and I don't think a custom TraversalStrategy would help in any way i can imagine. Maybe the closest thing I can imagine would be to subgraph the two graphs with their references vertices and merge them to a single TinkerGraph in your application and then run additional queries on that directly. I'm not sure that suits a lot of use cases we hear about though in relation to this feature so that suggestion may not be helpful. cc/ @Dave Bechberg...
Jump to solution
11 Replies
Solution
spmallette
spmallette11mo ago
At this time, there would be no easy way to do this and I don't think a custom TraversalStrategy would help in any way i can imagine. Maybe the closest thing I can imagine would be to subgraph the two graphs with their references vertices and merge them to a single TinkerGraph in your application and then run additional queries on that directly. I'm not sure that suits a lot of use cases we hear about though in relation to this feature so that suggestion may not be helpful. cc/ @Dave Bechberger
Dave
Dave11mo ago
I don't know if it would be quite as seamless as that but I have done some previous POC work on the ability to federate queries across graphs that could be applicable here
RN
RNOP11mo ago
Can you share some codepointers or docs for this?
Dave
Dave11mo ago
GitHub
tinkerpop/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gr...
Apache TinkerPop - a graph computing framework. Contribute to bechbd/tinkerpop development by creating an account on GitHub.
RN
RNOP11mo ago
I am thinking of 2 approaches but not sure if it will work - 1. extending DefaultGraphTraversal and overriding out() to return traversal from other graph/cluster. 2. Writing a custom traversal strategy and manipulate steps to change the cluster that they query when required. Will any of above approach work? cc: @spmallette @Dave Bechberger
spmallette
spmallette11mo ago
i dont think either of those will work. when you work with Neptune (or any remote graph), the traversal is sent to the server for execution. Steps like out() and any strategies are executed there, not locally. You're code will have no effect in that context. i suppose you could take an extreme approach to extending DefaultGraphTraversal to make it do some special things with various Cluster connectivity but i don't see how you would do it with any simple code changes that fit into the model of how TinkerPop currently works. it would be a lot of work that would require significant knowledge of the code base i think.
RN
RNOP11mo ago
Got it, so currently what can be the way forward on this? One approach is the Subgraph as you have mentioned earlier, any other approach apart from this that comes to your mind?
spmallette
spmallette11mo ago
I can't really think of anything besides that one given the way TinkerPop currently works. For this to really work, TinkerPop needs some features defined for federated query which is what Dave was experimenting with.
Dave
Dave11mo ago
I think you would need to write a custom procedure, which is the path I experimented with, in order to do this.
spmallette
spmallette11mo ago
could that really help though without Neptune (or any remote graph) implementing the functionality of that call() step?
Dave
Dave11mo ago
Yeah if you are using a provider like that then neither a strategy or the call() step approach would work. I think the only way to do it is what you pointed to about mergeing into a Tinkergraph
Want results from more Discord servers?
Add your server