I have a somewhat a simple question but I am still trying to grasp the gremlin language and graphing databases in general. I have the following items in the graph. This is just a single path but I want to find the nodes attached to the edges with property "ABC".
This is my graph for example:
a = g.addV("building").property("name", "A").next()
b = g.addV("building").property("name", "B").next()
c = g.addV("building").property("name", "C").next()
d = g.addV("building").property("name", "D").next()
e = g.addV("building").property("name", "E").next()
g.addE("path").from(a).to(b).property("ident", "ABC")
g.addE("path").from(b).to(c).property("ident", "ABC")
g.addE("path").from(c).to(d).property("ident", "ABC")
g.addE("path").from(d).to(e).property("ident", "ABC")
g.addE("path").from(a).to(b).property("ident", "XYZ")
g.addE("path").from(b).to(c).property("ident", "XYZ")
g.addE("path").from(c).to(d).property("ident", "XYZ")
g.addE("path").from(d).to(e).property("ident", "XYZ")
What I am trying to do is find the edges with .has("path", "ident", "ABC")
. I can do this, but
I am trying to figure out how to take that and end up showing the graph. I am trying to figure out how to get:
A->path->B->path->C->path->D->path->E
Again thanks in advance and you don't have to solve but help just point me in the right direction.
This can be accomplished using a combination of repeat()
steps with filtering on the edge property ident
using the has()
step like this:
g.V().has('building', 'name', 'A').repeat(outE('path').has('ident', 'ABC').inV()).until(outE('path').count().is(0)).path()