简体   繁体   中英

Gremlin Traversal in Neo4J

In my database, I can extract subgraphs by using a native Neo4J traversal that looks a little like this:

TraversalDescription td = Traversal.description()
.depthFirst()
.relationships(Relation.REL1, Direction.OUTGOING)
.relationships(Relation.REL2, Direction.OUTGOING);

And it works like a charm. Now I would like to do one of two things, but I'm expecting the latter to be a little easier.

  1. I would like to store the traversal in a Tinkerpop blueprints graph object.
  2. I would like to execute the same query in Gremlin (via the java api) and store that in the same type of graph object.

When I say store the traversal as a graph object, what I actually mean is that I want every single node that I passed by during that traversal (so not only the leaf nodes) to be stored in such a graph object and then I want every relation of which both start and endnode exist in the new graph object to be created. That includes relations that I did not include in my traversal description.

I think something like g.outE.filter{it.label == "REL1" || it.label == "REL2"}.inV.loop(3) g.outE.filter{it.label == "REL1" || it.label == "REL2"}.inV.loop(3) or so?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM