Vertex hashmaps

Hi, I'm looking to copy subgraphs, if there are better practices for this in general, please let me know I'm currently looking at emitting a subtree, then creating new vertices, storing a mapping of the original to the copy, and reusing this mapping to build out the relationships for the copied vertices. I'm not sure how I should be doing this, currently I'm trying to use the aggregate step to store the original/copy pairs, but I'm not sure how to select nodes from this in future steps. I'd appreciate any suggestions or help around these kind of operations, thanks I've been able to do this by building edges between the original nodes and the copies and traversing them, but I'm not sure if this is a typical pattern or there may be better approaches
Solution:
since you tagged this question with javascript i think that aggregate() is probably your best approach. in java, you would probably prefer subgraph() because it gives you a Graph representation which you could in turn run Gremlin on and as a result is quite convenient. we hope to see better support for subgraph() in javascript (and other language variants) in future releases.
Jump to solution
5 Replies
Solution
spmallette
spmallette3mo ago
since you tagged this question with javascript i think that aggregate() is probably your best approach. in java, you would probably prefer subgraph() because it gives you a Graph representation which you could in turn run Gremlin on and as a result is quite convenient. we hope to see better support for subgraph() in javascript (and other language variants) in future releases.
Max
Max3mo ago
Is the lack of support for subgraph() in JavaScript simply a feature gap in the JavaScript language variant? Or does it require deeper changes or support from the core Gremlin implementation?
spmallette
spmallette3mo ago
it needed deeper changes (and a mentality change) for years but those are in place now. so at this point its mostly a feature gap. note that, javascript and non jvm language variants still wont be able to execute Gremlin natively on the subgraph, but at least you can get a representation of the aubgraph to work with in other ways. building a Gremlin processing engine in each language would be awesome but thats not a gap we will likely see filled anytime soon :gremlin_smile:
red
redOP3mo ago
great, thanks could you point me to an example of the aggregate step doing some things like this?
spmallette
spmallette3mo ago
stephen mallette
Subgraphing without subgraph()
Subgraphing is a common use case when working with graphs. We often find ourselves wanting to take some small portion of a graph and then operate only upon it. Gremlin provides subgraph() step, which helps to make this operation relatively easy by exposing a way to produce an edge-induced subgraph that is detached from the parent graph.
Want results from more Discord servers?
Add your server